fix(web): 完善 Files 页面 i18n#607
Open
junxin367 wants to merge 2 commits intotiann:mainfrom
Open
Conversation
| return t('files.changes.error.gitStatusUnavailable') | ||
| } | ||
|
|
||
| const unstagedDetail = stripPrefix(detail, 'Unstaged diff unavailable: ') |
There was a problem hiding this comment.
[Minor] This only handles one prefixed failure, but useGitStatusFiles can concatenate both diff errors into a single string (Unstaged ... Staged ...), so the second failure is folded into the translated detail and lost.
Suggested fix:
const segments = detail.split(/(?=Unstaged diff unavailable: |Staged diff unavailable: )/).filter(Boolean)
if (segments.length > 1) {
return segments.map((segment) => {
const unstaged = stripPrefix(segment, 'Unstaged diff unavailable: ')\n if (unstaged) return t('files.changes.error.unstagedDiffUnavailableWithDetail', { error: unstaged })\n const staged = stripPrefix(segment, 'Staged diff unavailable: ')\n if (staged) return t('files.changes.error.stagedDiffUnavailableWithDetail', { error: staged })\n return segment\n }).join(' ')\n}\n```
Contributor
Author
There was a problem hiding this comment.
Fixed in 3417f90. formatGitStatusError now splits combined Unstaged ... Staged ... failures into segments and translates each one independently, so both errors are preserved. Added regression coverage in web/src/lib/files-i18n.test.ts.
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.
概述
Diff原因
影响范围
web/src/routes/sessions/files.tsxweb/src/routes/sessions/file.tsxweb/src/components/SessionFiles/DirectoryTree.tsxweb/src/lib/files-i18n.tsweb/src/lib/locales/en.tsweb/src/lib/locales/zh-CN.ts验证
bun test web/src/lib/files-i18n.test.tsbun typecheck风险 / 回滚
Reviewer Notes
web/src/lib/files-i18n.ts的错误映射是否符合预期Diff在中文下刻意保留英文detached在中文下改为“游离 HEAD”截图