Skip to content

feat(site): 브라우저 언어 감지 — 한국어가 아니면 영문 - #34

Merged
jlc488 merged 1 commit into
mainfrom
feat/site-i18n
Aug 8, 2026
Merged

feat(site): 브라우저 언어 감지 — 한국어가 아니면 영문#34
jlc488 merged 1 commit into
mainfrom
feat/site-i18n

Conversation

@jlc488

@jlc488 jlc488 commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

랜딩 페이지가 한국어 전용이었는데 패키지는 글로벌 npm 사용자를 대상으로 합니다. 헤더의 "English" 링크도 GitHub README로 튕겨낼 뿐이었습니다. 이제 페이지 자체가 적응합니다.

동작

언어 결정은 <head>에서 렌더 전에 끝냅니다 — 명시적 선택(localStorage) → ?lang= → 브라우저(/^ko/면 한국어, 그 외 영문). 헤더 링크는 선택을 저장하는 실제 토글이 됐습니다.

구조

한국어는 마크업에 그대로 두어 단일 진실 원천으로 삼고, 영문은 data-i18n 키 기반 오버레이 사전입니다(마커 68개, 항목 55개). 키가 없으면 빈 칸이 아니라 한국어로 폴백하므로 번역이 미완이어도 읽을 수 있는 상태로 degrade합니다. 최초 적용 시 원문을 WeakMap에 스냅샷해서 되돌리기가 무손실입니다.

데모 콘텐츠도 번역합니다PRESETS를 ko/en 소스 기반 buildPresets(lang)으로 바꾸고, __setDemoLang이 전환 시 활성 프리셋을 다시 적용해 에디터에 이전 언어가 남지 않습니다.

검증 (grep이 아니라 브라우저 실측)

  • ?lang=en에서 data-i18n 요소에 남은 한글 0개
  • 토글이 텍스트·데모 콘텐츠·<html lang>·토글 라벨을 왕복 전환하고 localStorage에 저장
  • navigator.languageko-KR로 스텁 → ko, de-DE → en (요구사항 자체를 검증)
  • 언어 전환 2회 후에도 줄자 정상 동작 — 키보드 드래그로 문단 여백 60px→70px 이동 확인. 콘텐츠 재주입이 에디터/줄자 바인딩을 깨지 않음
  • 신규 콘솔 오류 없음 (404 1건은 기존 favicon 누락)

별건 (미처리)

favicon이 없어 404가 납니다. 이번 변경과 무관한 기존 사항이라 범위에 넣지 않았습니다.

The landing page was Korean-only while the package targets a global npm
audience, and the header's 'English' link just bounced people to the
GitHub README. Now the page itself adapts.

Language resolution runs in <head>, before anything paints: an explicit
choice (localStorage) wins, then ?lang=, then the browser — /^ko/ keeps
Korean, everything else gets English. The header link became a real
toggle that persists the choice.

Korean stays in the markup as the single source of truth and English is
an overlay dictionary keyed by data-i18n (68 markers, 55 entries). A
missing key falls back to the Korean rather than rendering empty, so a
partial translation degrades to readable. Originals are snapshotted in a
WeakMap on first apply, which is what makes switching back lossless.

Demo copy is translated too, not just the chrome: PRESETS became
buildPresets(lang) over a ko/en source, and __setDemoLang re-applies the
active preset on switch so the editors never hold stale-language content.

Verified in a browser, not just by grep:
- ?lang=en leaves zero Korean in any data-i18n element
- toggling round-trips text, demo content, <html lang>, and the toggle
  label, and persists to localStorage
- navigator.language stubbed to ko-KR resolves ko; de-DE resolves en
- the ruler still works after two switches (keyboard drag moved a
  paragraph 60px -> 70px), so re-injecting content doesn't break the
  editor/ruler binding
- no new console errors (the one 404 is a pre-existing missing favicon)
@jlc488
jlc488 merged commit 0518fd3 into main Aug 8, 2026
1 check passed
@jlc488
jlc488 deleted the feat/site-i18n branch August 8, 2026 09:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant