
數秒內翻譯 Flutter ARB 檔案
元數據完整,保留預留位置,複數形式符合 CLDR。翻譯 ARB 檔案時不會破壞 flutter gen-l10n。
ARB 翻譯會導致 Flutter 構建失敗
ARB 檔案看似 JSON,其實並非如此。它包含以 @ 開頭的元數據條目、帶類型註解的預留位置定義,以及必須嚴格遵守 CLDR 規則的 ICU 複數形式。通用翻譯工具會破壞所有這些內容,導致 flutter gen-l10n 無提示地失敗或拋出難懂的錯誤。
以 @ 開頭的元數據條目被翻譯或刪除,導致預留位置定義和描述失效
大括號內的預留位置名稱被翻譯、重命名或刪除,從而導致執行階段崩潰
ICU 複數形式需要每種語言準確的 CLDR 類別,但通用工具不是跳過它們,就是產生無效結構
@@locale 標頭被損壞或不匹配,導致 flutter gen-l10n 將譯文分配給錯誤的語言
來源檔案(英語)
lib/l10n/app_en.arb
{
"@@locale": "en",
"appTitle": "My Flutter App",
"@appTitle": {
"description": "The title of the application"
},
"greeting": "Hello, {name}!",
"@greeting": {
"description": "A greeting with the user's name",
"placeholders": {
"name": {
"type": "String",
"example": "John"
}
}
},
"itemCount": "{count, plural, =0{No items} =1{1 item} other{{count} items}}",
"@itemCount": {
"description": "Number of items in the cart",
"placeholders": {
"count": {
"type": "int"
}
}
},
"lastLogin": "Last login: {date}",
"@lastLogin": {
"placeholders": {
"date": {
"type": "DateTime",
"format": "yMMMd"
}
}
}
}譯文(日語)
lib/l10n/app_ja.arb
{
"@@locale": "de",
"appTitle": "Meine Flutter-App",
"@appTitle": {
"description": "The title of the application"
},
"greeting": "Hallo, {name}!",
"@greeting": {
"description": "A greeting with the user's name",
"placeholders": {
"name": {
"type": "String",
"example": "John"
}
}
},
"itemCount": "{count, plural, =0{Keine Artikel} =1{1 Artikel} other{{count} Artikel}}",
"@itemCount": {
"description": "Number of items in the cart",
"placeholders": {
"count": {
"type": "int"
}
}
},
"lastLogin": "Letzte Anmeldung: {date}",
"@lastLogin": {
"placeholders": {
"date": {
"type": "DateTime",
"format": "yMMMd"
}
}
}
}i18n Agent 會保留哪些內容
@ 元數據條目
所有以 @ 開頭的元數據,包括描述、預留位置和類型註解,都會按定義精確保留
預留位置安全
能夠檢測 {userName}、{count} 和 {price} 等命名預留位置,並在所有譯文中保持不變
CLDR 複數形式
根據 CLDR 規則,為每種目標語言正確產生 ICU 複數類別(zero、one、two、few、many、other)
JSON 結構
鍵順序、嵌套結構和 ARB 專用格式均與來源檔案一致,便於清晰比較差異
相容你的 Flutter 技術堆疊
flutter gen-l10n(官方)
Easy Localization
GetX 國際化
工作原理

1
2
3
terminal
$translate_filesrc/messages/en.json
--target["de", "ja", "es"]
Done.3 languages, 142 keys translated.
無需手動複製粘貼,無需提取字串,直接獲得翻譯檔案。
立即試用 i18n Agent
將翻譯檔案拖放到此處
JSON, YAML, PO, XML, CSV, Markdown, Properties
或點擊選擇檔案
目標語言
無需註冊即時估價
常見問題
企業團隊?
仍受困於 TMS 合同?歡迎與我們討論遷移方案。