翻译

翻译 Java .properties 文件

一个 .properties 文件是 key=value 行的集合,其中值包含 MessageFormat 的 {0} 参数。KAERIS 会翻译这些值,保留您的注释和键的顺序,并以纯 ASCII 格式写入文件,以便 Java 在任何地方都能读取。

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

.properties 文件是如何构建的

key=value、key: value 或 key value,注释以 # 或 ! 开头,行续接以反斜杠结尾。旧版 Java 将资源包读取为 ISO-8859-1,因此非拉丁字符会写成 \uXXXX,所有版本都能读取。

源文件messages.properties
# Login form
login.title=Sign in to {0}
login.attempts=You have {0} attempts left
cart.total=Total: {0,number,currency}
about.url=https\://example.com/about
help.text=Need help?\nWrite to [email protected]

.properties 翻译中需要注意的事项

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

实际运行,27 October 2026,未手动编辑:kaeris translate messages.properties --langs de 使用 kaeris 0.2.35,耗时 3.3 秒,模型 openai/gpt-4.1-mini(服务端的备用模型处理了此任务)。下方是它生成的德语文件以及 kaeris check 的检查结果。

德语结果de/messages.properties
# Generated by KAERIS i18n Tool - de
# Login form
login.title=Anmelden bei {0}
login.attempts=Sie haben noch {0} Versuche
cart.total=Gesamt: {0,number,currency}
about.url=https://example.com/about
help.text=Brauchen Sie Hilfe?\nSchreiben Sie an [email protected]
kaeris 检查exit code 0
$ kaeris check --source messages.properties --langs de
✓ de: complete & placeholder-safe
✓ all locales complete & placeholder-safe

KAERIS 的处理方式

分三步运行

  1. 安装 CLI

    运行 pip install kaeris。

  2. 翻译包

    运行 kaeris translate messages.properties --langs de,ja。

  3. 检查结果

    在免费检查页面上传源文件和翻译后的包。

pip install kaeris
kaeris translate src/main/resources/messages.properties --langs de,ja --verify

问题

它写入 UTF-8 还是 \u 转义符?

转义符。输出文件是 ASCII 格式,非 ASCII 字符以 \uXXXX 的形式写入。

我的注释会被保留吗?

是的。注释和空行会按原样写回,并添加一个命名语言的标题行。

免费吗?

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

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

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

继续

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

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