将 .strings 文件转换为 .strings.json 文件

如需将 .strings 文件转换为 .strings.json 文件,请执行以下操作:

  1. 如果您使用的是 7.12 之前的 Looker 版本,请关闭需要本地化的旧版 .strings 文件旧版功能。
  2. 点击项目文件列表右上角的 + 图标,然后选择创建语言区域字符串文件,为项目创建一个新的 .strings.json 文件。
  3. 为新的 .strings.json 文件命名。.strings 文件的标题必须与分配给使用该语言区域的用户或群组的语言区域代码一致,并且默认语言区域文件的标题必须与项目清单文件default_locale 的值一致。
  4. .strings.json 文件中出现的代码段提供了 JSON 格式设置的示例。请删除此示例,并将其替换为一对大括号:{}
  5. 从原来的 .strings 文件中复制键值对,并将其粘贴到大括号内。
  6. 将所有等号替换为冒号。
  7. 移除所有注释;或者将它们重新设置为单个注释或一组注释,如下图所示。
  8. 用逗号替换所有分号。

键值对的典型 .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 demonstrated below",
        "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"
    }
}