npx skills add https://smithery.ai/skills/calcitem/arb-translation-updater当新的翻译条目被添加到基础语言(英语和中文)时,此技能帮助批量更新所有语言的 ARB(应用程序资源包)文件。它自动化了在 60 多个语言文件中翻译和分发新条目的过程。
始终在每个 ARB 文件的末尾,紧接在闭合的 } 之前添加新的翻译条目。
intl_en.arb 和 intl_zh.arb)和通过更新脚本的自动添加示例:
{
"existingKey1": "...",
"@existingKey1": {},
"existingKey2": "...",
"@existingKey2": {},
// 在这里添加新条目 ↓
"newKey": "...",
"@newKey": {}
}
所有 ARB 文件(包括非英语语言)的元数据描述必须用英语书写。
"@perfectDatabaseChallengeHint": {"description": "Hint to enable perfect database for greater challenge", ...}"@perfectDatabaseChallengeHint": {"description": "启用完美数据库以获得更大挑战的提示", ...} (在 intl_zh.arb 中)这适用于:
@key 元数据中的 description 字段intl_en.arb、intl_zh.arb、intl_ja.arb 等。理由: Flutter 的 ARB 格式规范要求元数据使用英语,以确保工具兼容性和所有区域设置的一致性。
在添加新翻译之前,始终检查 ARB 文件中是否已存在该键。
添加前检查:
# 检查特定文件中是否存在键
grep -c "keyName" intl_en.arb
# 检查所有文件
for file in intl_*.arb; do
count=$(grep -c "keyName" "$file")
echo "$file: $count occurrences"
done
决策矩阵:
如果存在重复项:
预防措施:
所有 ARB 文件必须使用 4 空格缩进,而不是 2 空格或制表符。
缩进级别:
正确 4 空格缩进的示例:
{
"myKey": "My value",
"@myKey": {
"description": "My description",
"placeholders": {
"param": {
"description": "Parameter description",
"type": "String"
}
}
}
}
❌ 错误(2 空格缩进):
{
"myKey": "My value",
"@myKey": {
"description": "My description",
"placeholders": {
"param": {
"description": "Parameter description",
"type": "String"
}
}
}
}
重要提示:
new-items.txt 时,使用 4 空格缩进update_arb_files.sh 脚本将完全按照写入的方式复制缩进1. 使用 git 识别 intl_en.arb(以及 intl_zh.arb,如果可用)中的新条目
2. 为所有其他 59 种语言生成翻译
3. 创建包含所有翻译的 new-items.txt
4. 运行 update_arb_files.sh 来应用更改
5. 验证更新后文件的 JSON 格式
使用 git 查看最近添加的内容(最可靠的方法):
cd src/ui/flutter_app/lib/l10n
# 检查英语 ARB 文件的最近更改
git log -p --follow -1 intl_en.arb
# 或者查看与上一次提交的差异
git diff HEAD~1 intl_en.arb
# 查看添加的内容(以 + 开头的行)
git diff HEAD~1 intl_en.arb | grep "^+"
# 检查中文文件是否也有新条目
git diff HEAD~1 intl_zh.arb
# 如果 git 中没有最近的更改,检查未提交的更改
git diff intl_en.arb
git diff intl_zh.arb
提取新键:
@ 开头的行)"key": "value" 和 "@key": {}{} - 任何语言文件(包括英语和中文)中都不能有 description 字段优先级:
intl_en.arb 和 intl_zh.arb 都有新条目 → 将两者都用作翻译参考intl_en.arb 有新条目 → 仅从英语翻译检查新键是否存在于其他语言文件中:
# 检查特定键是否存在于所有文件中
grep -l "newKeyName" intl_*.arb
# 计算已有该键的文件数量
grep -l "newKeyName" intl_*.arb | wc -l
# 查找哪些文件缺少该键
for file in intl_*.arb; do
if ! grep -q "newKeyName" "$file"; then
echo "Missing in: $file"
fi
done
为所有需要的语言创建翻译。每个 ARB 文件需要:
支持的语言(总计 59+ 种,不包括 en 和 zh):
update_arb_files.sh 脚本从 new-items.txt 读取,格式如下:
// intl_<locale>.arb
"keyName": "Translated text",
"@keyName": {},
"keyNameDetail": "Detailed translated text",
"@keyNameDetail": {}
// intl_<another_locale>.arb
"keyName": "其他语言的翻译",
"@keyName": {},
...
格式规则:
// intl_<locale>.arb (指示要更新哪个文件)@key 元数据必须是空对象 {} - 永远不要包含 description 或任何其他字段示例 new-items.txt:
// intl_ja.arb
"stopPlacing": "配置を停止",
"@stopPlacing": {},
"stopPlacing_Detail": "ボード上に空きスペースが2つだけ残ったときに配置フェーズが終了します。",
"@stopPlacing_Detail": {}
// intl_fr.arb
"stopPlacing": "Arrêter le placement",
"@stopPlacing": {},
"stopPlacing_Detail": "La phase de placement se termine lorsque le plateau n'a plus que 2 espaces vides.",
"@stopPlacing_Detail": {}
// intl_de.arb
"stopPlacing": "Setzen beenden",
"@stopPlacing": {},
"stopPlacing_Detail": "Die Setzphase endet, wenn das Brett nur noch 2 freie Felder hat.",
"@stopPlacing_Detail": {}
执行更新脚本以应用所有翻译:
cd src/ui/flutter_app/lib/l10n
# 运行更新脚本
./update_arb_files.sh
# 脚本将:
# - 读取 new-items.txt
# - 解析每个区域设置部分
# - 将条目追加到相应的 .arb 文件
# - 保持正确的 JSON 格式
验证所有文件是否正确更新:
# 检查有多少文件包含新键
grep -l "stopPlacing" intl_*.arb | wc -l
# 应返回 63(包括 en 和 zh 在内的所有语言文件)
# 计算 ARB 文件总数
ls -1 intl_*.arb | wc -l
# 应返回 63
# 验证所有文件的 JSON 格式
for file in intl_*.arb; do
if ! python3 -m json.tool "$file" > /dev/null 2>&1; then
echo "❌ JSON Error in $file"
fi
done
echo "✅ JSON validation complete"
# 抽查几种语言
tail -6 intl_ja.arb # 日语
tail -6 intl_fr.arb # 法语
tail -6 intl_ru.arb # 俄语
tail -6 intl_ar.arb # 阿拉伯语
位置: src/ui/flutter_app/lib/l10n/update_arb_files.sh
功能:
new-items.txt// intl_<locale>.arb 标记)工作原理:
}}# append.sh - 将 append.txt 中的内容追加到指定的 ARB 文件
./append.sh <arb_file>
# append-items.sh - 为所有 ARB 文件调用 append.sh
./append-items.sh
# replace-locale.sh - 替换区域设置标识符
./replace-locale.sh
翻译 Mill 游戏术语时,请考虑:
intl_en.arb)intl_zh.arb)- 如果可用且最近更新过从右到左的语言(ar, he, fa, ur):
亚洲语言(zh, ja, ko, th, vi):
欧洲语言:
解决方案:
# 使用 git 查看实际更改
git log -p --since="1 week ago" -- intl_en.arb
# 与当前 HEAD 比较
git diff HEAD intl_en.arb
# 仅查看添加的行
git diff HEAD intl_en.arb | grep "^+[^+]"
解决方案:
解决方案:
new-items.txt 是否存在于 l10n 目录中// 开头)原因: 尾随逗号或格式错误的 JSON
解决方案:
# 找到有问题的文件
for file in intl_*.arb; do
python3 -m json.tool "$file" > /dev/null 2>&1 || echo "Error: $file"
done
# 手动修复 JSON 或重新运行脚本
检查:
# 验证 new-items.txt 中是否包含所有区域设置
grep "^//" new-items.txt | wc -l
# 应该大约有 59-61 个(不包括 en 和 zh 基础文件)
# 列出包含的文件
grep "^//" new-items.txt
问题: 没有正确翻译,只是复制了英语
解决方案: 重新生成翻译,确保每种语言都获得适当的本地化
问题: ARB 文件有 "@key": {"description": "..."} 而不是 "@key": {}
解决方案:
# 修复所有 ARB 文件,使其具有空的元数据对象
import json
for locale in ['en', 'zh', 'ja', 'fr', ...]: # 所有区域设置
file_path = f'intl_{locale}.arb'
with open(file_path, 'r', encoding='utf-8') as f:
data = json.load(f)
# 从所有 @ 键中移除 description
for key in list(data.keys()):
if key.startswith('@'):
data[key] = {}
with open(file_path, 'w', encoding='utf-8') as f:
json.dump(data, f, indent=4, ensure_ascii=False)
f.write('\n')
重要提示:
intl_en.arb 和 intl_zh.arb)都必须具有空的元数据对象 {}description 或任何其他字段使用 git 识别更改
git diff 比 tail 更可靠英语是主要来源
intl_en.arb 中的新条目intl_zh.arb)是可选的参考使用一致的术语
更新后测试
版本控制
i18n: Add translations for [feature]src/ui/flutter_app/lib/l10n/
├── intl_en.arb # 英语(主要基础)
├── intl_zh.arb # 简体中文(可选参考)
├── intl_zh_Hant.arb # 繁体中文
├── intl_*.arb # 60 个其他语言文件
├── new-items.txt # 临时文件:要添加的新翻译
├── update_arb_files.sh # 主更新脚本
├── append.sh # 辅助脚本
├── append-items.sh # 辅助脚本
└── replace-locale.sh # 辅助脚本
运行更新过程后:
# 1. 导航到 l10n 目录
cd src/ui/flutter_app/lib/l10n
# 2. 使用 git 识别新内容
git diff HEAD~1 intl_en.arb
# 或者,如果是未提交的更改:
git diff intl_en.arb
# 输出显示:
# +"newFeature": "Stop placing when empty",
# +"@newFeature": {},
# +"newFeature_Detail": "Detailed explanation...",
# +"@newFeature_Detail": {}
# 3. 检查中文是否也有这些内容(可选)
git diff HEAD~1 intl_zh.arb
# 如果没找到,仅使用英语继续
# 4. 提取新键
# newFeature
# newFeature_Detail
# 5. 为所有语言生成翻译
# (使用 AI 或翻译服务创建 new-items.txt)
# 记住:不要包含 intl_en.arb 或 intl_zh.arb
# 6. 验证 new-items.txt 格式
head -30 new-items.txt
# 应该以:// intl_af.arb 或类似内容开头(不是 intl_en.arb)
# 7. 运行更新脚本
./update_arb_files.sh
# 8. 验证结果
grep -l "newFeature" intl_*.arb | wc -l
# 输出:63 ✓(包括 en 和 zh 在内的所有文件)
# 9. 验证 JSON
for file in intl_*.arb; do
python3 -m json.tool "$file" > /dev/null 2>&1 || echo "Error: $file"
done
echo "✅ All files valid"
# 10. 抽查翻译
tail -8 intl_ja.arb
tail -8 intl_de.arb
tail -8 intl_ar.arb
# 11. 使用 git 验证
git diff intl_ja.arb
git diff intl_de.arb
# 12. 清理
rm new-items.txt # 可选:保留以供参考
# 13. 提交更改
# 导航到项目根目录
git add src/ui/flutter_app/lib/l10n/intl_*.arb
git commit -m "i18n: Add translations for new feature across all languages"
使用 AI 生成所有翻译时:
重要提示: 从英语翻译,可选地参考中文
# AI 翻译的提示模板:
Translate the following Mill game UI strings from English to all these languages:
[List of target languages]
English source:
"newFeature": "Stop placing when only two empty squares remain"
"newFeature_Detail": "When enabled, the placing phase ends and moving phase begins when the board has only 2 empty spaces left, regardless of pieces in hand. This rule only applies to 12-piece games."
Optional Chinese reference (if available):
"newFeature": "棋盘只剩两个空位时停止放子"
"newFeature_Detail": "启用后,当棋盘只剩2个空位时,无论手中是否还有棋子,放子阶段都会结束并进入走子阶段。此规则仅适用于12子棋。"
Context:
- This is for a Mill board game app (Nine Men's Morris)
- "newFeature" is a short settings label
- "newFeature_Detail" is a detailed description shown in settings
Please provide natural, fluent translations for each language.
Format as new-items.txt (do NOT include English or Chinese).
然后将响应格式化为 new-items.txt 格式。
# 查看添加到英语 ARB 的内容
git diff HEAD~1 intl_en.arb | grep "^+"
# 检查所有文件是否都有某个键
grep -l "keyName" intl_*.arb | wc -l
# 验证所有 JSON 文件
for f in intl_*.arb; do python3 -m json.tool "$f" >/dev/null 2>&1 || echo "Bad: $f"; done
# 计算 new-items.txt 中的语言数量
grep "^//" new-items.txt | wc -l
# 更新所有 ARB 文件
./update_arb_files.sh
# 查看最近的 ARB 提交
git log --oneline --follow -10 intl_en.arb
src/ui/flutter_app/lib/l10n/update_arb_files.shgit diff 可靠地识别新条目每周安装次数
–
来源
首次出现
–
This skill helps batch update all language ARB (Application Resource Bundle) files when new translation entries are added to the base languages (English and Chinese). It automates the process of translating and distributing new entries across 60+ language files.
ALWAYS add new translation entries at the very end of each ARB file, just before the closing}.
intl_en.arb and intl_zh.arb) AND automated additions via the update scriptExample:
{
"existingKey1": "...",
"@existingKey1": {},
"existingKey2": "...",
"@existingKey2": {},
// Add new entries HERE ↓
"newKey": "...",
"@newKey": {}
}
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
质量优于速度
ALL ARB files (including non-English languages) must have metadata descriptions written in English.
"@perfectDatabaseChallengeHint": {"description": "Hint to enable perfect database for greater challenge", ...}"@perfectDatabaseChallengeHint": {"description": "启用完美数据库以获得更大挑战的提示", ...} (in intl_zh.arb)This applies to:
description field in @key metadataintl_en.arb, intl_zh.arb, intl_ja.arb, etc.Rationale: Flutter's ARB format specification requires metadata to be in English for tooling compatibility and consistency across all locales.
Before adding new translations, ALWAYS check if the key already exists in the ARB files.
Check before adding:
# Check if key exists in a specific file
grep -c "keyName" intl_en.arb
# Check all files
for file in intl_*.arb; do
count=$(grep -c "keyName" "$file")
echo "$file: $count occurrences"
done
Decision matrix:
If duplicates exist:
Prevention:
ALL ARB files MUST use 4-space indentation, NOT 2-space or tabs.
Indentation levels:
Example with correct 4-space indentation:
{
"myKey": "My value",
"@myKey": {
"description": "My description",
"placeholders": {
"param": {
"description": "Parameter description",
"type": "String"
}
}
}
}
❌ WRONG (2-space indentation):
{
"myKey": "My value",
"@myKey": {
"description": "My description",
"placeholders": {
"param": {
"description": "Parameter description",
"type": "String"
}
}
}
}
Important:
new-items.txt, use 4-space indentationupdate_arb_files.sh script will copy indentation exactly as written1. Use git to identify new entries in intl_en.arb (and intl_zh.arb if available)
2. Generate translations for all 59 other languages
3. Create new-items.txt with all translations
4. Run update_arb_files.sh to apply changes
5. Validate JSON format of updated files
Use git to see what was recently added (most reliable method):
cd src/ui/flutter_app/lib/l10n
# Check recent changes to English ARB file
git log -p --follow -1 intl_en.arb
# Or see diff from last commit
git diff HEAD~1 intl_en.arb
# See what was added (lines starting with +)
git diff HEAD~1 intl_en.arb | grep "^+"
# Check if Chinese file also has new entries
git diff HEAD~1 intl_zh.arb
# If no recent changes in git, check uncommitted changes
git diff intl_en.arb
git diff intl_zh.arb
Extract the new keys:
@)"key": "value" and "@key": {}{} - NO description field in any language file (including English and Chinese)Priority:
intl_en.arb and intl_zh.arb have new entries → use both as translation referenceintl_en.arb has new entries → translate from English onlyCheck if the new keys exist in other language files:
# Check if a specific key exists in all files
grep -l "newKeyName" intl_*.arb
# Count how many files already have the key
grep -l "newKeyName" intl_*.arb | wc -l
# Find which files are missing the key
for file in intl_*.arb; do
if ! grep -q "newKeyName" "$file"; then
echo "Missing in: $file"
fi
done
Create translations for all required languages. Each ARB file needs:
Supported Languages (59+ total excluding en and zh):
The update_arb_files.sh script reads from new-items.txt with this format:
// intl_<locale>.arb
"keyName": "Translated text",
"@keyName": {},
"keyNameDetail": "Detailed translated text",
"@keyNameDetail": {}
// intl_<another_locale>.arb
"keyName": "其他语言的翻译",
"@keyName": {},
...
Format Rules:
// intl_<locale>.arb (indicates which file to update)@key metadata must be empty objects {} - NEVER include description or any other fieldsExample new-items.txt:
// intl_ja.arb
"stopPlacing": "配置を停止",
"@stopPlacing": {},
"stopPlacing_Detail": "ボード上に空きスペースが2つだけ残ったときに配置フェーズが終了します。",
"@stopPlacing_Detail": {}
// intl_fr.arb
"stopPlacing": "Arrêter le placement",
"@stopPlacing": {},
"stopPlacing_Detail": "La phase de placement se termine lorsque le plateau n'a plus que 2 espaces vides.",
"@stopPlacing_Detail": {}
// intl_de.arb
"stopPlacing": "Setzen beenden",
"@stopPlacing": {},
"stopPlacing_Detail": "Die Setzphase endet, wenn das Brett nur noch 2 freie Felder hat.",
"@stopPlacing_Detail": {}
Execute the update script to apply all translations:
cd src/ui/flutter_app/lib/l10n
# Run the update script
./update_arb_files.sh
# The script will:
# - Read new-items.txt
# - Parse each locale section
# - Append entries to corresponding .arb files
# - Maintain proper JSON formatting
Verify that all files were updated correctly:
# Check how many files contain the new key
grep -l "stopPlacing" intl_*.arb | wc -l
# Should return 63 (all language files including en and zh)
# Count total arb files
ls -1 intl_*.arb | wc -l
# Should return 63
# Validate JSON format of all files
for file in intl_*.arb; do
if ! python3 -m json.tool "$file" > /dev/null 2>&1; then
echo "❌ JSON Error in $file"
fi
done
echo "✅ JSON validation complete"
# Spot check a few languages
tail -6 intl_ja.arb # Japanese
tail -6 intl_fr.arb # French
tail -6 intl_ru.arb # Russian
tail -6 intl_ar.arb # Arabic
Location: src/ui/flutter_app/lib/l10n/update_arb_files.sh
What it does:
new-items.txt from the same directory// intl_<locale>.arb)How it works:
} from target file} back# append.sh - Appends content from append.txt to specified ARB file
./append.sh <arb_file>
# append-items.sh - Calls append.sh for all ARB files
./append-items.sh
# replace-locale.sh - Replace locale identifiers
./replace-locale.sh
When translating Mill game terms, consider:
intl_en.arb)intl_zh.arb) - if available and recently updatedRight-to-Left Languages (ar, he, fa, ur):
Asian Languages (zh, ja, ko, th, vi):
European Languages:
Solution:
# Use git to see the actual changes
git log -p --since="1 week ago" -- intl_en.arb
# Compare with current HEAD
git diff HEAD intl_en.arb
# See only added lines
git diff HEAD intl_en.arb | grep "^+[^+]"
Solution:
Solution:
new-items.txt exists in l10n directory//)Cause: Trailing comma or malformed JSON
Solution:
# Find the problematic file
for file in intl_*.arb; do
python3 -m json.tool "$file" > /dev/null 2>&1 || echo "Error: $file"
done
# Manually fix JSON or re-run script
Check:
# Verify all locales are in new-items.txt
grep "^//" new-items.txt | wc -l
# Should be around 59-61 (excluding en and zh base files)
# List which files are included
grep "^//" new-items.txt
Problem: Not properly translated, just English copied
Solution: Regenerate translations ensuring each language gets proper localization
Problem: ARB files have "@key": {"description": "..."} instead of "@key": {}
Solution:
# Fix all ARB files to have empty metadata objects
import json
for locale in ['en', 'zh', 'ja', 'fr', ...]: # all locales
file_path = f'intl_{locale}.arb'
with open(file_path, 'r', encoding='utf-8') as f:
data = json.load(f)
# Remove description from all @ keys
for key in list(data.keys()):
if key.startswith('@'):
data[key] = {}
with open(file_path, 'w', encoding='utf-8') as f:
json.dump(data, f, indent=4, ensure_ascii=False)
f.write('\n')
Important:
intl_en.arb and intl_zh.arb) must have empty metadata objects {}description or any other fields to metadataUse git to identify changes
git diff is more reliable than tailEnglish is the primary source
intl_en.arb for new entriesintl_zh.arb) is optional referenceUse consistent terminology
Test after updating
Version control
i18n: Add translations for [feature]Quality over speed
src/ui/flutter_app/lib/l10n/
├── intl_en.arb # English (primary base)
├── intl_zh.arb # Chinese Simplified (optional reference)
├── intl_zh_Hant.arb # Chinese Traditional
├── intl_*.arb # 60 other language files
├── new-items.txt # Temporary: new translations to add
├── update_arb_files.sh # Main update script
├── append.sh # Helper script
├── append-items.sh # Helper script
└── replace-locale.sh # Helper script
After running the update process:
# 1. Navigate to l10n directory
cd src/ui/flutter_app/lib/l10n
# 2. Use git to identify what's new
git diff HEAD~1 intl_en.arb
# OR if uncommitted:
git diff intl_en.arb
# Output shows:
# +"newFeature": "Stop placing when empty",
# +"@newFeature": {},
# +"newFeature_Detail": "Detailed explanation...",
# +"@newFeature_Detail": {}
# 3. Check if Chinese also has these (optional)
git diff HEAD~1 intl_zh.arb
# If not found, proceed with English only
# 4. Extract the new keys
# newFeature
# newFeature_Detail
# 5. Generate translations for all languages
# (Use AI or translation service to create new-items.txt)
# Remember: do NOT include intl_en.arb or intl_zh.arb
# 6. Verify new-items.txt format
head -30 new-items.txt
# Should start with: // intl_af.arb or similar (NOT intl_en.arb)
# 7. Run update script
./update_arb_files.sh
# 8. Validate results
grep -l "newFeature" intl_*.arb | wc -l
# Output: 63 ✓ (all files including en and zh)
# 9. Validate JSON
for file in intl_*.arb; do
python3 -m json.tool "$file" > /dev/null 2>&1 || echo "Error: $file"
done
echo "✅ All files valid"
# 10. Spot check translations
tail -8 intl_ja.arb
tail -8 intl_de.arb
tail -8 intl_ar.arb
# 11. Verify with git
git diff intl_ja.arb
git diff intl_de.arb
# 12. Clean up
rm new-items.txt # Optional: keep for reference
# 13. Commit changes
# Navigate to project root directory
git add src/ui/flutter_app/lib/l10n/intl_*.arb
git commit -m "i18n: Add translations for new feature across all languages"
When using AI to generate all translations:
Important: Translate from English, optionally reference Chinese
# Prompt template for AI translation:
Translate the following Mill game UI strings from English to all these languages:
[List of target languages]
English source:
"newFeature": "Stop placing when only two empty squares remain"
"newFeature_Detail": "When enabled, the placing phase ends and moving phase begins when the board has only 2 empty spaces left, regardless of pieces in hand. This rule only applies to 12-piece games."
Optional Chinese reference (if available):
"newFeature": "棋盘只剩两个空位时停止放子"
"newFeature_Detail": "启用后,当棋盘只剩2个空位时,无论手中是否还有棋子,放子阶段都会结束并进入走子阶段。此规则仅适用于12子棋。"
Context:
- This is for a Mill board game app (Nine Men's Morris)
- "newFeature" is a short settings label
- "newFeature_Detail" is a detailed description shown in settings
Please provide natural, fluent translations for each language.
Format as new-items.txt (do NOT include English or Chinese).
Then format the response into new-items.txt format.
# See what was added to English ARB
git diff HEAD~1 intl_en.arb | grep "^+"
# Check if all files have a key
grep -l "keyName" intl_*.arb | wc -l
# Validate all JSON files
for f in intl_*.arb; do python3 -m json.tool "$f" >/dev/null 2>&1 || echo "Bad: $f"; done
# Count languages in new-items.txt
grep "^//" new-items.txt | wc -l
# Update all ARB files
./update_arb_files.sh
# View recent ARB commits
git log --oneline --follow -10 intl_en.arb
src/ui/flutter_app/lib/l10n/update_arb_files.shgit diff to identify new entries reliablyWeekly Installs
–
Source
First Seen
–
agent-browser 浏览器自动化工具 - Vercel Labs 命令行网页操作与测试
147,400 周安装