feat(i18n): 支持官网、桌面端与管理端多语言#209
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cb0cdc03ca
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| for (const [original, translated] of sortedEntries) { | ||
| if (original.length > 1 && output.includes(original)) output = output.split(original).join(translated) |
There was a problem hiding this comment.
Stop translating dynamic evidence names
Because the DOM translator is installed on the whole document and this loop replaces any matching Chinese substring in every text node, user data rendered by the app is translated too. For example, the desktop records list renders r.file_name/r.file_path as plain text, and a real evidence file named 测试存证.txt will be displayed as sample-evidence.txt in English because that string is in the message table; paths or tenant/client names containing UI words can be altered the same way. That makes the UI show different evidence metadata from what was actually submitted, so dynamic record data needs to be excluded or translations need to be applied only to explicit UI copy.
Useful? React with 👍 / 👎.
| const saved = localStorage.getItem(storageKey); | ||
| if (saved && supported.has(saved)) return saved; | ||
| } catch { /* local storage can be unavailable in embedded shells */ } | ||
| return normalizeLocale(navigator.languages?.[0] || navigator.language); |
There was a problem hiding this comment.
Honor secondary browser language preferences
This only consults navigator.languages[0], so users whose primary browser locale is unsupported but whose next preference is supported, such as ['de-DE', 'en-US'], fall all the way back to Simplified Chinese instead of English. Since the feature is supposed to choose from the browser language preferences automatically, iterate the full navigator.languages list and select the first supported normalized locale before defaulting to zh-CN.
Useful? React with 👍 / 👎.
改动内容
影响
用户可以在三套界面中统一切换语言;官网展示的客户端画面会和官网语言保持一致。
验证
website: npm run buildclients/desktop/frontend: npm run buildclients/web: npm run buildclients/web: npm run test:unit(10 个测试文件、26 项测试通过)git diff --check