Feature/vscode i18n#219
Merged
Merged
Conversation
…on in package.json
- Integrated translation functionality using `useT` from `I18nProvider` across multiple components including CustomProviderManager, EnvSetupGuide, FileList, LogViewer, PasswordInput, Select, and various views (CancelledView, ConfigView, DoneView, EmptyView, FailedView, IdleView, RunningView). - Replaced hardcoded strings with localized strings to enhance user experience for different languages. - Updated button labels, titles, and hints to reflect the new translation implementation.
…n(预存代码,非本次 PR 引入,阻塞了 lint,这里进行修复)
Comment on lines
+30
to
+38
| const getPrimaryLabel = () => { | ||
| if (!configured) return t('view.idle.configFirst'); | ||
| if (running) return t('view.idle.reviewing'); | ||
| if (!selectionReady) { | ||
| return mode === 'branch' ? t('view.idle.selectBranch') : t('view.idle.selectCommit'); | ||
| } | ||
| if (files.length === 0) return t('view.idle.noFiles'); | ||
| return t('view.idle.reviewAll'); | ||
| }; |
Contributor
There was a problem hiding this comment.
The getPrimaryLabel function references selectionReady and files, which are declared later (lines 52–58). Although this works at runtime because the function is only invoked during rendering (after all const bindings are initialized), it hurts readability. Consider moving getPrimaryLabel below the declarations of files, selectionReady, etc., so the dependency order is top-to-bottom and easier to follow.
Contributor
Author
There was a problem hiding this comment.
不需要修改变量声明顺序,和之前版本顺序保持一致,运行时完全正常,移动反而增加 diff 噪音
- Fix singular '1 hour ago' / '1 小时前' in GitService.formatRelative - Replace hardcoded 'en' locale with dynamic resolveLocale in CliService.install - Move hardcoded full-width colon into i18n translation strings - Narrow locale type from string to SupportedLocale in messages, stores - Extract toHtmlLang() helper to deduplicate locale→HTML lang mapping - Replace nested ternary with mapping object in ConfigView - Add missing trailing newlines to 7 files - Add jest __mocks__/vscode.js for CliService test
Contributor
Author
|
在 vs code的中英文端侧都没有发现问题 |
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.
Description
Implement i18n (internationalization) support for the VS Code extension, resolving all hardcoded Chinese/English UI strings across the extension host, WebView, and
package.jsoncontributions.What was done
package.jsoncontributions — Migrated hardcoded strings to%key%placeholders resolved by VS Code's nativepackage.nls.json/package.nls.zh-cn.jsonmechanism (requiresengines.vscode >= 1.74.0).src/shared/i18n.ts) — 260+ translation entries covering all UI strings, witht()lookup function andresolveLocale()locale detector.I18nContext+useT()hook wrapping all 13 view/component files. Locale passed from extension host viainit/configPanelInitmessages.CommentProvider,ConfigPanelProvider,SidebarProvider,GitService,CliServiceall uset()/resolveLocale()for user-facing strings.Architecture
vscode.env.language→resolveLocale()→'en'or'zh-cn''en'; missing keys → English defaultI18nContext.Provider→useT()hookType of Change
How Has This Been Tested?
make testpasses locallynpx webpack --mode developmentpasses (3 bundles: extension, webview, configPanel)npx jest --no-coveragepasses (74/74 tests, 9 suites)yarn lintpasses (1 pre-existing warning in shellEnv.ts, unrelated, fixed)yarn testpasses (all tests, 9 suites)Checklist
go fmt,go vet)Related Issues
Closes #205