如要將 .strings
檔案轉換為 .strings.json
檔案,請按照下列步驟操作:
- 如果您使用的是 7.12 之前的 Looker 版本,請關閉舊版 .strings 檔案,用於本地化舊版功能。
- 按一下專案檔案清單右上方的「+」圖示,然後選取「Create Locale Strings File」,即可為專案建立新的
.strings.json
檔案。 - 為新的
.strings.json
檔案命名。.strings
檔案的標題必須與指派給使用該語言代碼的使用者或群組的語言代碼相符,且預設語言代碼檔案的標題必須與專案資訊清單檔案中的default_locale
值相符。 - 新
.strings.json
檔案中顯示的程式碼片段,提供 JSON 格式範例。刪除這個範例,並用一對大括號替換:{}
- 從舊的
.strings
檔案複製鍵/值組合,然後貼到大括號內。 - 將所有等號替換為冒號。
- 移除所有註解,或將其重新格式化為個別註解或註解陣列,如下方所示。
- 將所有分號替換為逗號。
鍵/值組合的一般 .strings.json
格式如下所示:
{ "flight_info" : "Flight Info", "id" : "Identifier", "airline" : "Air Carrier" }
如要設定註解格式,可以使用下列格式:
{ " My Comment": { "my_comment_array": [ "The name of this file should be the associated locale code followed by '.strings.json'", "There is one .strings.json file per locale.", "Define your translated strings one key at a time", "Keys can be any string; choose whatever scheme helps you stay organized", "Then, set your Lookml label and description parameters to the desired key values.", "To choose this file as the master key list and as the one to validate against", "set its locale code ('test') as the default_locale in the manifest file" ], "value": "Translation for My Comment" }, "My Key": { "value": "Translation for My Key", "comment": "Define your translated strings with a comment or an array of comments" } }