- Fixed 20 translation entries with concatenated words and incorrect formatting - Fixed critical bug in DOM replacer that caused partial translations - Sort translation patches by length (longest first) to prevent substring replacement issues - Fixed TypeScript and ESLint errors - Added comprehensive documentation of fixes
5.1 KiB
Translation Fixes Applied
Summary
Fixed 20 translation issues in proxycast/src/i18n/patches/en.json where English translations had concatenated words or incorrect formatting, plus fixed a critical bug in the DOM replacement algorithm that caused partial translations.
Critical Bug Fix: DOM Replacement Order
Problem
The DOM replacer was applying translations in an arbitrary order (based on Object.entries() iteration), which caused partial replacements when shorter strings were replaced before longer strings containing them.
Example of the bug:
- Text: "初次设置向导"
- If "初次" was replaced first → "First-time设置向导"
- Then "设置" was replaced → "First-timeSettings向导"
- Result: Broken translation like "初timesSettings向导"
Solution
Modified proxycast/src/i18n/dom-replacer.ts to sort translation entries by length (longest first) before applying replacements. This ensures that longer, more specific phrases are translated before their component parts.
// Sort patches by length (longest first) to avoid partial replacements
const sortedPatches = Object.entries(patches)
.filter(([zh]) => !zh.startsWith('//'))
.sort(([a], [b]) => b.length - a.length);
This fix ensures:
- "初次设置向导" is replaced as a complete phrase before "初次" or "设置" individually
- No partial translations or broken text
- Consistent and accurate translations throughout the UI
Issues Fixed
1. Concatenated Words in Translations
These translations had words incorrectly concatenated without spaces:
| Chinese | Before | After |
|---|---|---|
| 请输入或选择配置文件 | Please enter InputorSelectConfigureFile | Please enter or select configuration file |
| 和其他设置 | andOther settings | and other settings |
| 名称和类型 | Nameand type | Name and type |
| 标签管理此插件的凭证 | TagsManageThisplugin's Credentials | tab to manage this plugin's credentials |
| 输入本地插件目录路径或 | InputLocalplugin directory path or | Enter local plugin directory path or |
| 或输入新的 | or InputNew's | or enter new |
| 请检查内容 | Please Checkcontent | Please check content |
2. Incorrect Technical Term Formatting
These translations had technical terms incorrectly formatted:
| Chinese | Before | After |
|---|---|---|
| 凭证加载成功 | CredentialsLoad successful | Credentials loaded successfully |
| 配置保存成功 | ConfigureSave successful | Configuration saved successfully |
| 凭证添加成功 | CredentialsAdd successful | Credential added successfully |
| 凭证刷新成功 | CredentialsRefresh successful | Credential refreshed successfully |
| 已复制凭证 | CopyCredentials | Credential copied |
| 检查模型名称 | CheckModel name | Check model name |
| 上传新文件 | UploadNew file | Upload new file |
| 导入凭证文件 | ImportCredentials file | Import credentials file |
| 打开链接失败 | Failed to OpenLink | Failed to open link |
| 等待授权中 | WaitingAuthorizationing | Waiting for authorization |
| 未登录状态 | Not LoginStatus | Not logged in |
| 配置文件同步失败 | Failed to ConfigureFileSync | Failed to sync configuration file |
| 检查同步状态失败 | Failed to CheckSyncStatus | Failed to check sync status |
| 安装完成后点击 | Click after InstallComplete | Click after installation completes |
Impact
These fixes improve the quality and readability of English translations throughout the ProxyCast application, ensuring:
- Proper spacing between words
- Natural English phrasing
- Consistent terminology
- Professional presentation
- No more partial or broken translations
Files Modified
proxycast/src/i18n/patches/en.json- 20 translation entries correctedproxycast/src/i18n/dom-replacer.ts- Fixed replacement order algorithm
Testing Recommendations
- Restart the application to ensure patches apply with the new algorithm
- Switch language to English in Settings > General > Language
- Navigate through all pages to verify translations display correctly
- Specifically check the "初次设置向导" (First-time Setup) section in General Settings
- Check for any remaining Chinese text that may not be covered by the translation files
Technical Details
Why Sorting by Length Matters
When replacing text, if a shorter substring is replaced before a longer string containing it, the longer string will never match. For example:
Original: "初次设置向导"
Translations:
"初次" → "First-time"
"设置" → "Settings"
"向导" → "Wizard"
"初次设置向导" → "First-time Setup"
Without sorting (wrong order):
"初次设置向导" → "First-time设置向导" (after replacing "初次")
→ "First-timeSettings向导" (after replacing "设置")
→ "First-timeSettingsWizard" (after replacing "向导")
Result: ❌ "First-timeSettingsWizard"
With sorting (correct order):
"初次设置向导" → "First-time Setup" (replaced as complete phrase)
Result: ✅ "First-time Setup"
This is why sorting by length (longest first) is critical for accurate translations.