feat: internationalization (i18n) support with i18next + Simplified Chinese locale - #97
Open
JaneConan wants to merge 1 commit into
Open
feat: internationalization (i18n) support with i18next + Simplified Chinese locale#97JaneConan wants to merge 1 commit into
JaneConan wants to merge 1 commit into
Conversation
- Add src/i18n/ (i18next init, en/zh-CN locale resources, LanguageSwitcher) - Wrap hardcoded UI strings across App/Header and 18 components with t() - Mount I18nextProvider in main.tsx - Language switcher is always visible in the header (globe + select pill), works on both desktop and mobile, persists choice via localStorage - zh-CN resolves correctly with explicit supportedLngs (no nonExplicit fallback); <html lang> synced on change for a11y/SEO - deps: i18next, react-i18next, i18next-browser-languagedetector
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds internationalization support to Ontology Playground using
i18next / react-i18next, and ships Simplified
Chinese (zh-CN) as the first additional locale.
Motivation
Ontology Playground is a great learning tool, but all UI strings are
hardcoded in English. This PR extracts them into locale resources so the
community can contribute translations, lowering the barrier for non-English
learners (the ontology/knowledge-graph learning audience is very global).
What's changed
src/i18n/module (no build-config changes):index.ts— i18next init: follows the OS/browser language by default,persists manual choice to
localStorage(op-lang), falls back to Englishlocales/en.ts/locales/zh-CN.ts— ~230 keys each, kept as TS modules(no
resolveJsonModule/ tsconfig changes needed)LanguageSwitcher.tsx— a small 🌐 dropdown, mounted at the right end ofthe header
App.tsx,Header.tsxand18 components (modals, panels,
designer/*, LearnPage chrome) are wrappedwith
t(). Replacements are minimal and inline — no logic or markuprestructuring — to keep this diff reviewable.
i18next,react-i18next,i18next-browser-languagedetector(~15 kB gzip total added to the bundle).
What's NOT changed
content/learn/(Markdown) is untouched —course translation is a much larger effort and better handled separately.
tsconfig.en(pure refactor path).Testing
npm run buildpasses (tsc type-check + vite build + embed build)vite preview: command palette, headeractions/themes, all modals/panels render correctly in en and zh-CN
Notes for reviewers
header.*,welcome.*,quest.*, …)src/i18n/locales/and oneentry to
SUPPORTED_LANGUAGESsmaller reviews