翻译指南
在 Discourse 中,所有消息格式字符串的键都以 _MF 结尾。Crowdin 编辑器中有一个预览功能,允许您尝试各种值,这对于检查您的翻译非常有帮助。
重要提示: 如果您的语言使用的复数形式多于“one”和“other”这两种,则需要修改翻译的复数形式。您可以在 { FOO, plural, ... } 块中添加或删除形式,以使其适用于您的语言。如果您的翻译存在问题,Crowdin 编辑器中的预览将显示“语法错误”。
可用的复数形式有:
- zero
- one
- two
- few
- many
- other(必需——通用复数形式——也用于没有单复数区分的语言)
有时您可能会在英文源字符串中看到一个空的 =0 {} 块,这意味着该变量的值不能为 0。
开发者指南
消息格式字符串目前仅可用于客户端翻译。如果您的字符串包含多个数字或许多变量,这会导致大量排列组合,那么使用它们就很有用。
-
消息格式字符串的键需要以
**_MF**结尾 -
数字使用以下格式(
#将被替换为数字):{ variable_name, plural, one: {# singular text} other: {# plural text} } -
选择使用以下格式:
{ variable_name, select, foo: {This is foo} bar: {This is bar} baz: {This is baz} } -
在 JavaScript 中这样使用:
I18n.messageFormat("key_MF", { variable1: "foo", variable2: 42, }); -
建议: 如果可能,将复杂的参数作为消息的最外层结构,并在其子消息中编写完整的句子。如果您有嵌套的选择和复数参数,请将选择参数(带有其固定的选择集)放在外部,并将复数参数(希望最多一个)嵌套在内部。请参阅 Formatting Messages | ICU Documentation -
使它们易于阅读——请参阅 client.en.yml 中的现有示例。
差There {currentTopics, plural, one {is <strong>#</strong> topic} other {are <strong>#</strong> topics}}. Visitors need more to read and reply to – we recommend at least { requiredTopics, plural, one {<strong>#</strong> topic} other {<strong>#</strong> topics}}. Only staff can see this message.
好There { currentTopics, plural, one {is <strong>#</strong> topic} other {are <strong>#</strong> topics} }. Visitors need more to read and reply to – we recommend at least { requiredTopics, plural, one {<strong>#</strong> topic} other {<strong>#</strong> topics} }. Only staff can see this message.
工具和进一步信息
-
Online ICU Message Editor 允许您测试消息格式字符串,以防 Crowdin 编辑器出现问题。请禁用“Parse simple xml/html tags”选项,否则您可能会看到错误消息。
此文档是版本控制的——请在 github 上建议更改。
