JSON 檔案¶
在 4.3 版的變更: 即使對於在之前發佈版本中中斷的複雜情況,JSON 文件的結構也適當保留。
JSON 格式主要用於翻譯 Javascript 中實施的應用。
Weblate 目前支援 JSON 翻譯的幾個變體:
簡單的鍵/值文件,由例如 vue-i18n 或 react-intl 使用。
具有巢狀鍵的文件。
JSON 翻譯通常是單語言的,因此推薦指定帶有(最經常使用的)英語字串的翻譯範本文件。
提示
JSON file 和 JSON nested structure file 都可以處理相同類型的文件。翻譯時都保留現有的 JSON 架構。
The only difference between them is when adding new strings using Weblate.
The nested structure format parses the newly added key and inserts the new
string into the matching structure. For example app.name key is inserted as:
{
"app": {
"name": "Weblate"
}
}
也參考
範例檔案¶
範例檔案:
{
"Hello, world!\n": "Ahoj světe!\n",
"Orangutan has %d banana.\n": "",
"Try Weblate at https://demo.weblate.org/!\n": "",
"Thank you for using Weblate.": ""
}
也支援巢狀文件(要求請參閱上面),這樣的文件看起來像:
{
"weblate": {
"hello": "Ahoj světe!\n",
"orangutan": "",
"try": "",
"thanks": ""
}
}
Weblate 配置¶
典型的 Weblate 組件配置 |
|
|---|---|
檔案遮罩 |
|
單語的基底語言檔案 |
|
新翻譯的範本 |
空白 |
檔案格式 |
JSON nested structure file |
檔案格式參數¶
檔案格式參數 with the pattern json_* can be used to configure the behavior of the JSON format.