翻译

翻译 Xcode String Catalogs (.xcstrings)

String Catalog 将所有语言保存在一个 JSON 文件中,该文件应仅由 Xcode 手动编辑。KAERIS 会将新语言添加到同一个文件中,并保持其中其他内容不变。

KAERIS 翻译了此页面,并通过回译检查了每一行。尚未经过母语人士审阅。 英文原文

String Catalog 的构建方式

一个文件,strings,然后是键,然后是 localizations,然后是语言。每种语言包含复数的 stringUnit 或 variations。文件还包含 comment、extractionState 和 shouldTranslate。缺少源语言条目的键就是其自身的源文本。

源文件Localizable.xcstrings
{
  "sourceLanguage" : "en",
  "strings" : {
    "Welcome back, %@!" : {
      "comment" : "Greeting on the home screen",
      "extractionState" : "manual",
      "localizations" : {
        "en" : { "stringUnit" : { "state" : "translated", "value" : "Welcome back, %@!" } }
      }
    },
    "%lld items" : {
      "localizations" : {
        "en" : {
          "variations" : {
            "plural" : {
              "one" : { "stringUnit" : { "state" : "translated", "value" : "%lld item" } },
              "other" : { "stringUnit" : { "state" : "translated", "value" : "%lld items" } }
            }
          }
        }
      }
    },
    "Cancel" : { }
  },
  "version" : "1.0"
}

在 .xcstrings 翻译中需要注意的事项

实际运行:翻译为德语并进行检查

一次实际运行,27 October 2026,未手动编辑任何内容:kaeris translate Localizable.xcstrings --langs de,使用 kaeris 0.2.35,耗时 2.4 秒,模型为 openai/gpt-4.1-mini(服务的回退模型处理了此任务)。下方是它生成的德语文件以及 kaeris check 的检查结果。

德语结果Localizable.xcstrings
{
  "sourceLanguage": "en",
  "strings": {
    "Welcome back, %@!": {
      "comment": "Greeting on the home screen",
      "extractionState": "manual",
      "localizations": {
        "en": {
          "stringUnit": {
            "state": "translated",
            "value": "Welcome back, %@!"
          }
        },
        "de": {
          "stringUnit": {
            "state": "translated",
            "value": "Willkommen zurück, %@!"
          }
        }
      }
    },
    "%lld items": {
      "localizations": {
        "en": {
          "variations": {
            "plural": {
              "one": {
                "stringUnit": {
                  "state": "translated",
                  "value": "%lld item"
                }
              },
              "other": {
                "stringUnit": {
                  "state": "translated",
                  "value": "%lld items"
                }
              }
            }
          }
        },
        "de": {
          "variations": {
            "plural": {
              "one": {
                "stringUnit": {
                  "state": "translated",
                  "value": "%lld Artikel"
                }
              },
              "other": {
                "stringUnit": {
                  "state": "translated",
                  "value": "%lld Artikel"
                }
              }
            }
          }
        }
      }
    },
    "Cancel": {
      "localizations": {
        "de": {
          "stringUnit": {
            "state": "translated",
            "value": "Abbrechen"
          }
        }
      }
    }
  },
  "version": "1.0"
}
kaeris 检查exit code 0
$ kaeris check --source Localizable.xcstrings --langs de
✓ de: complete & placeholder-safe
✓ all locales complete & placeholder-safe

KAERIS 的处理方式

分三步运行

  1. 安装 CLI

    运行 pip install kaeris。

  2. 翻译字符串目录

    运行 kaeris translate Localizable.xcstrings --langs de,fr,ja。该字符串目录会被原地更新。

  3. 检查结果

    在免费检查页面上传字符串目录;它会从单个文件中读取源文本和翻译。

pip install kaeris
kaeris translate Localizable.xcstrings --langs de,fr,ja --verify

问题

它会覆盖我现有的翻译吗?

文件中已有的语言、注释和提取状态将保持不变,正如 CLI README 中所述。

复数是如何处理的?

复数变体会根据每种语言所需的类别进行展开:英语的 one/other 在俄语中会变成 one/few/many/other,在阿拉伯语中则有六种形式。

免费吗?

是的,无需账户:每个文件 10,000 个字符,每次运行最多 8 种语言。免费的 API 密钥可将文件限制提高到 50,000 个字符。一次性付费 79 美元,使用您自己的 OpenRouter 密钥;月度套餐起价为 19 美元。价格

我可以在终端或 CI 中运行它吗?

是的。pip install kaeris,然后运行 kaeris translate Localizable.xcstrings --langs de,ja。另请参阅 iOS。GitHub Action 在拉取请求中运行相同的翻译。 CLI 文档 · GitHub Action

继续

CLI 参考 · 检查参考 · 在浏览器中翻译 · 免费检查 · 格式转换 · 伪本地化

其他格式:JSON · YAML · .po · ARB · XLIFF · .strings · .properties · .resx · CSV · Markdown · Fluent · Android XML