From a7f6044a58ed1cb1a03ba25bc4f866bf3ec7529f Mon Sep 17 00:00:00 2001 From: Sin-Kang Date: Sat, 8 Aug 2026 18:10:19 +0900 Subject: [PATCH] feat(site): serve English to non-Korean browsers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 , 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, , 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) --- site/index.html | 406 ++++++++++++++++++++++++++++++++++++------------ 1 file changed, 308 insertions(+), 98 deletions(-) diff --git a/site/index.html b/site/index.html index 9925dbf..306f7aa 100644 --- a/site/index.html +++ b/site/index.html @@ -29,6 +29,22 @@ /> +