-
-
Notifications
You must be signed in to change notification settings - Fork 892
feat: add i18n framework with Chinese (zh-CN) localization #3184
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jiaminghua
wants to merge
3
commits into
wavetermdev:main
Choose a base branch
from
jiaminghua:feat/i18n-chinese-localization
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| import i18n from "i18next"; | ||
| import { initReactI18next } from "react-i18next"; | ||
|
|
||
| import en from "./locales/en.json"; | ||
| import zhCN from "./locales/zh-CN.json"; | ||
|
|
||
| // Detect system language and map to supported locale | ||
| function detectLanguage(): string { | ||
| const sysLang = navigator.language || "en"; | ||
| if (sysLang.startsWith("zh")) { | ||
| return "zh-CN"; | ||
| } | ||
| return "en"; | ||
| } | ||
|
|
||
| // Allow override via localStorage | ||
| const savedLang = localStorage.getItem("wave:language"); | ||
| const initialLang = savedLang || detectLanguage(); | ||
|
|
||
| i18n.use(initReactI18next).init({ | ||
| resources: { | ||
| en: { translation: en }, | ||
| "zh-CN": { translation: zhCN }, | ||
| }, | ||
| lng: initialLang, | ||
| fallbackLng: "en", | ||
| interpolation: { | ||
| escapeValue: false, | ||
| }, | ||
| }); | ||
|
|
||
| // Save language preference on change | ||
| i18n.on("languageChanged", (lng: string) => { | ||
| localStorage.setItem("wave:language", lng); | ||
| }); | ||
|
|
||
| export default i18n; | ||
|
|
||
| // Expose a global t function for use in non-React contexts (e.g. event handlers, menus) | ||
| declare global { | ||
| interface Window { | ||
| __waveI18n: { t: typeof i18n.t; changeLanguage: typeof i18n.changeLanguage }; | ||
| } | ||
| } | ||
| window.__waveI18n = { t: i18n.t.bind(i18n), changeLanguage: i18n.changeLanguage.bind(i18n) }; | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| { | ||
| "app.tabBarPosition": "Tab Bar Position", | ||
| "app.top": "Top", | ||
| "app.left": "Left", | ||
| "app.renameTab": "Rename Tab", | ||
| "app.copyTabId": "Copy TabId", | ||
| "app.flagTab": "Flag Tab", | ||
| "app.none": "None", | ||
| "app.green": "Green", | ||
| "app.teal": "Teal", | ||
| "app.blue": "Blue", | ||
| "app.purple": "Purple", | ||
| "app.red": "Red", | ||
| "app.orange": "Orange", | ||
| "app.yellow": "Yellow", | ||
| "app.backgrounds": "Backgrounds", | ||
| "app.default": "Default", | ||
| "app.closeTab": "Close Tab", | ||
| "app.magnifyBlock": "Magnify Block", | ||
| "app.unMagnifyBlock": "Un-Magnify Block", | ||
| "app.copyBlockId": "Copy BlockId", | ||
| "app.closeBlock": "Close Block", | ||
| "app.addToLayout": "Add to Layout", | ||
| "app.splitHorizontally": "Split Horizontally", | ||
| "app.splitVertically": "Split Vertically", | ||
| "app.settings": "Settings", | ||
| "app.close": "Close", | ||
| "app.connectTo": "Connect to (username@host)...", | ||
| "app.local": "Local", | ||
| "app.remote": "Remote", | ||
| "app.editConnections": "Edit Connections", | ||
| "app.reconnectTo": "Reconnect to {{connection}}", | ||
| "app.disconnect": "Disconnect {{connection}}", | ||
| "app.newConnection": "{{name}} (New Connection)", | ||
| "app.gitBash": "Git Bash", | ||
| "app.waveAI": "Wave AI", | ||
| "app.context": "Context", | ||
| "app.widgetContext": "Widget Context", | ||
| "app.widgetAccess": "Widget Access {{state}}", | ||
| "app.on": "ON", | ||
| "app.off": "OFF", | ||
| "app.moreOptions": "More options", | ||
| "app.newChat": "New Chat", | ||
| "app.maxOutputTokens": "Max Output Tokens", | ||
| "app.configureModes": "Configure Modes", | ||
| "app.hideWaveAI": "Hide Wave AI", | ||
| "app.about": "About", | ||
| "app.waveTerminal": "Wave Terminal", | ||
| "app.version": "Version", | ||
| "app.configFiles": "Config Files", | ||
| "app.connections": "Connections", | ||
| "app.themes": "Themes", | ||
| "app.keybindings": "Keybindings", | ||
| "app.errorRenderingViewHeader": "Error Rendering View Header: {{error}}", | ||
| "app.cancel": "Cancel", | ||
| "app.ok": "OK", | ||
| "app.aboutDescription": "Open-Source AI-Integrated Terminal", | ||
| "app.aboutTagline": "Built for Seamless Workflows", | ||
| "app.clientVersion": "Client Version", | ||
| "app.updateChannel": "Update Channel", | ||
| "app.github": "GitHub", | ||
| "app.website": "Website", | ||
| "app.openSource": "Open Source", | ||
| "app.sponsor": "Sponsor", | ||
| "app.viewDocumentation": "View documentation", | ||
| "app.visual": "Visual", | ||
| "app.rawJson": "Raw JSON", | ||
| "app.saving": "Saving...", | ||
| "app.save": "Save", | ||
| "app.unsavedChanges": "Unsaved changes", | ||
| "app.loading": "Loading...", | ||
| "app.configError": "Config Error", | ||
| "app.deprecated": "Deprecated", | ||
| "app.saveWithShortcut": "Save ({{shortcut}})" | ||
| } |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.