编辑器和文档本地化

Godot的目标是让游戏开发提供给每个人, 包括那些可能不知道或不习惯英语的人. 因此, 多亏了社区的翻译工作, 我们尽最大努力使最重要的资源以多种语言提供.

这些资源包括:

  1. Godot 编辑器界面(约15,000个字)。

  2. 在线文档 <https://hosted.weblate.org/projects/godot-engine/godot-docs/&gt; __(编辑器手册和教程,约 30 万字)。

  3. 类参考手册,可在线和编辑器中查看(约 200000 单词)。

为了管理翻译,我们使用 GNU getext 文件格式(PO 文件)和开源的 Weblate 基于 Web 的本地化平台,允许许多贡献者轻松协作来完成各种组件的翻译,并使其保持最新。单击上面粗体的链接访问 Weblate 上的每个资源。

本页概述了 Weblate 上的一般翻译工作流程,以及一些特定于资源的说明,例如如何处理某些关键字或图像的本地化。

小技巧

翻译所有的官方Godot内容是一项艰巨的任务, 因此我们建议优先考虑上面列出的资源: 首先是编辑器界面, 然后是在线文档, 如果有足够的翻译人员跟上更新, 最后是类参考.

使用 Weblate 进行翻译

虽然我们的翻译最终驻留在Godot引擎及其文档的Git存储库中, 但所有翻译更新都是通过Weblate处理的, 因此不接受对Git存储库的直接pull请求. 维护人员在Weblate和Godot存储库之间手动同步翻译.

因此,您应该在 Weblate 上注册,来为 Godot 的翻译贡献力量。

登录后,浏览到您要参与的 Godot 资源(在本页中,我们将使用编辑器翻译为例)要查找所有语言的列表:

../../_images/l10n_01_language_list.png

参见

更多细节请随意查阅 Weblate 自己的翻译工作流程文档

增加新的语言

如果您的语言已经列出, 请单击其名称以访问概述, 然后跳过本节的其余部分.

如果您的语言未列出,请滚动到语言列表的底部,单击“开始新翻译”按钮,然后选择要翻译的语言:

../../_images/l10n_02_new_translation.png

重要

如果您的语言在多个国家使用,但地区差异有限,请考虑将其添加为通用变体(如 fr 表示法语)而不是区域变体(如 fr_FR 表示法语(法国)、fr_CA 表示法语(加拿大)、fr_DZ 表示法语(阿尔及利亚))。

Godot有大量的内容需要翻译, 因此只有在语言差异足够显著的情况下, 才应该复制区域变体的工作. 此外, 如果对区域变体进行了翻译, 则该翻译将仅对位于该区域的用户(或为该区域配置了系统语言)自动可用.

当地区差异大到需要单独翻译时,如果可能的话,我们建议先集中精力完成一个通用的变体,然后将完全完成的翻译复制到地区变体中,并进行相关的编辑。这通常是一个很好的策略,例如西班牙语(先完成 es ,然后必要时复制到 es_ARes_ESes_MX 等)或葡萄牙语( pt_BRpt_PT )。

翻译界面

一旦选择了一种语言,您将看到翻译状态的概述,包括还有多少字符串需要翻译或审阅。每个项目都可以单击并用于浏览相应的列表。您还可以点击“翻译”按钮开始操作字符串列表。

../../_images/l10n_03_translation_overview.png

选择“翻译”列表后,您将看到所有工作发生的主要翻译界面:

../../_images/l10n_04_translation_interface.png

在那一页, 你有:

  • A toolbar which lets you cycle through strings of the current list, change to another predefined list or do a custom search, etc. There is also a “Zen” editing mode with a simplified interface.

  • 在 “翻译” 面板中处理的实际字符串. 默认情况下, 应该有英语源字符串和您的语言的编辑框. 如果您熟悉其他语言, 可以将其添加到用户设置中, 以提供更多翻译上下文. 编辑完当前字符串后, 按 “保存” 确认更改并移到下一个条目. 或者, 使用 “跳过” 按钮跳过它.”需要编辑” 复选框意味着原始字符串已更新, 因此需要检查翻译以考虑这些更改(在PO术语中, 这些是所谓的 “模糊” 字符串). 在修复之前, 这些字符串不会在翻译中使用.

  • 底部面板有各种工具可以帮助翻译工作, 例如来自附近字符串的上下文(通常来自同一编辑器工具或文档页, 因此它们可能使用类似的术语), 来自其他翻译人员的注释, 机器翻译以及该字符串的所有其他现有翻译的列表.

  • 在右上角, 术语表显示了先前添加了条目的术语, 以及当前字符串中包含的术语. 例如, 如果您与其他翻译人员一起决定对Godot中的 “node” 术语使用特定的翻译, 您可以将其添加到词汇表中, 以确保其他翻译人员使用相同的约定.

  • 右下面板包含有关源字符串的信息。最相关的项目是“源字符串位置”,它将您链接到 GitHub 上的原始字符串。您可能需要在页面中搜索字符串来定位它及其周围的上下文。

定位原始内容

PO 文件是源字符串(msgid)及其翻译(msgstr)的有序列表。默认情况下,Weblate 将按该顺序显示字符串。因此,了解 PO 文件中内容的组织方式非常有用,可以帮助您定位原始内容,并在翻译时将其用作参考。

重要

翻译时以原文语境为参照是最原始的, 因为许多词根据语境有几种可能的翻译. 使用错误的翻译实际上会对用户造成伤害, 并且会比使用英语更难理解. 使用上下文也使翻译工作更容易和更愉快, 因为你可以直接看到你写的翻译是否在上下文中有意义.

  • 编辑器接口的翻译模板是通过按照字母顺序解析所有 C++ 源代码生成的,所以在给定文件中定义的所有字符串将被分组在一起。例如,如果“源字符串位置”指示 editor/code_editor.cpp,则当前字符串(以及附近的字符串)在 editor/code_editor.cpp 代码文件,因此与 Godot(GDScript、着色器)中的代码编辑器相关。

  • The online documentation’s translation template is generated from the source RST files in the same order as seen in the table of contents, so for example the first strings are from the front page of the documentation. The recommended workflow is therefore to find a unique string corresponding to a page that you want to translate, and then translate all the strings with the same source string location while comparing with the online version of that page in English. An example of source string location could be getting_started/step_by_step/nodes_and_scenes.rst for the page Nodes and Scenes.

  • 类引用的翻译模板是按照字母顺序从源 XML 文件中生成的,这与联机版本的目录顺序相同。因此,您可以定位与给定类的简要描述相对应的源字符串,以找到要翻译的第一个字符串,并且该类中的所有其他描述都应位于 Weblate 上的后续字符串中。例如 Node2D 类的描述将具有源字符串位置 doc/classes/Node2D.xml

A handy tool to locate specific pages/classes is to use Weblate’s advanced search feature, and especially the “Location strings” query (which can also be used with the location: token, e.g. location:nodes_and_scenes.rst):

../../_images/l10n_05_search_location.png ../../_images/l10n_06_browse_by_location.png

注解

When a given source string is used in multiple source locations, they will all be concatenated into one. For example, the above location:nodes_and_scenes.rst query would land first on the “Introduction” source string which is used in dozens of pages, including some that come before nodes_and_scenes.rst in the template. Clicking the “Next” button then brings us to the “Scene and nodes” title string displayed above. So it may happen that a given paragraph or section title is not at the location you’d expect it when reading the online version of a page.

遵守标记语法

每个翻译资源源于不同的源代码格式, 对每个资源使用的标记语言有一些概念对于避免在翻译中产生语法错误非常重要.

编辑器界面(C++)

编辑器的翻译源于 C++ 字符串,可能使用:

  • C 格式说明符,如 %s(字符串)或 %d(数字)。这些说明符在运行时会被替换为具体的内容,并且应该在必要时保留并放置在翻译中,以便在替换后有意义。您可能需要参考源字符串的位置,以了解如果句子中不清楚将替换什么类型的内容。示例(%s 将被替换为文件名或路径):

    1. # PO file:
    2. "There is no '%s' file."
    3. # Weblate:
    4. There is no '%s' file.
  • C 转义字符,如 \n(换行符)或 \t(制表符)。在 Weblate 编辑器中,\n 字符由 替换,\t 替换。制表符的使用并不多,但您应该确保使用与原始英文字符串相同的换行符(如果不使用,Weblate 将发出警告)。换行符有时可能用于垂直间距,或手动换行,否则会太长(特别是在编辑器翻译中)。例子:

    1. # PO file:
    2. "Scene '%s' is currently being edited.\n"
    3. "Changes will only take effect when reloaded."
    4. # Weblate:
    5. Scene '%s' is currently being edited.↵
    6. Changes will only take effect when reloaded.

注解

Only logical order of the characters matters, in the right-to-left text, format specifiers may be displayed as s%.

在线文档(RST)

文档翻译源于 reStructuredText(RST)文件,这些文件还使用自己的标记语法来设置文本样式,创建内部和外部链接等。以下是一些示例:

  1. # "development" is styled bold.
  2. # "Have a look here" is a link pointing to https://docs.godotengine.org/en/latest.
  3. # You should translate "Have a look here", but not the URL, unless there is
  4. # a matching URL for the same content in your language.
  5. # Note: The `, <, >, and _ characters all have a meaning in the hyperlink
  6. # syntax and should be preserved.
  7. Looking for the documentation of the current **development** branch?
  8. `Have a look here <https://docs.godotengine.org/en/latest>`_.
  9. # "|supported|" is an inline reference to an image and should stay unchanged.
  10. # "master" uses the markup for inline code, and will be styled as such.
  11. # Note: Inline code in RST uses 2 backticks on each side, unlike Markdown.
  12. # Single backticks are used for hyperlinks.
  13. |supported| Backwards-compatible new features (backported from the ``master``
  14. branch) as well as bug, security, and platform support fixes.
  15. # The :ref: Sphinx "role" is used for internal references to other pages of
  16. # the documentation.
  17. # It can be used with only the reference name of a page (which should not be
  18. # changed), in which case the title of that page will be displayed:
  19. See :ref:`doc_ways_to_contribute`.
  20. # Or it can be used with an optional custom title, which should thus be translated:
  21. See :ref:`how to contribute <doc_ways_to_contribute>`.
  22. # You may encounter other Sphinx roles, such as :kbd: used for shortcut keys.
  23. # You can translate the content between backticks to match the usual key names,
  24. # if it's different from the English one.
  25. Save the scene. Click Scene -> Save, or press :kbd:`Ctrl + S` on Windows/Linux
  26. or :kbd:`Cmd + S` on macOS.

参见

参见 Sphinx 的 reStructured Text 入门 有关标记语言的快速概述, 请参阅源字符串. 您可能会特别遇到内联标记(粗体, 斜体, 内联代码)以及内部和外部超链接标记.

类参考(BBCode)

类引用使用XML文件记录在Godot主存储库中, 并使用类似BBCode的标记进行样式设置和内部引用.

使用的一些标记来自原始 BBCode(例如 [b]Bold[/b][i]Italics[/i])而其他标记是 Godot 特定的,用于高级功能,例如内联代码(例如 [code]true[/code]),链接到另一个类(例如 [Node2D]),或链接到给定类中的属性(例如 [member Node2D.position]),或用于多行代码块。例子:

  1. Returns a color according to the standardized [code]name[/code] with [code]alpha[/code] ranging from 0 to 1.
  2. [codeblock]
  3. red = ColorN("red", 1)
  4. [/codeblock]
  5. Supported color names are the same as the constants defined in [Color].

在上面的例子中, [code]name[/code] , [code]alpha[/code][Color] 不应被翻译, 因为它们分别指的是参数名和Godot API的一个类. 同样, [codeblock] 的内容也不应该翻译, 因为 ColorN 是Godot API的一个函数, 而 "red" 是它支持的一个命名颜色. 你最多可以翻译持有结果的变量名称( red = ... ).

另请注意, 在XML中, 每一行都是一个段落, 因此如果换行符不是原始翻译的一部分, 则不应添加换行符.

参见

See our documentation for class reference writers for the list of BBCode-like tags which are used throughout the class reference.

离线翻译和测试

虽然我们建议使用Weblate接口来编写翻译, 但您也可以在本地下载PO文件, 用您喜欢的PO编辑应用程序(如 “Poedit”)进行翻译 PoeditLokalize.

要在本地下载PO文件, 请浏览到您所用语言的翻译概述, 然后选择 “文件” 菜单中的第一项:

../../_images/l10n_07_download_po_file.png

完成一系列编辑后, 使用同一菜单中的 “上载翻译” 项并选择文件. 选择 “添加为翻译” 作为文件上载模式.

注解

如果在您下载PO文件和上载编辑版本之间经过了相当长的时间, 则有可能同时覆盖其他贡献者编写的翻译. 这就是为什么我们建议使用在线界面, 以便您始终使用最新版本.

如果您想在本地测试更改(特别是编辑器翻译),可以使用下载的 PO 文件并从源码编译 Godot

将编辑器翻译PO文件重命名为 <lang>.PO``(例如 ``环氧乙烷 , 并将其放入 editor/translations/ 文件夹(`GitHub<https://github.com/godotengine/godot/tree/master/editor/translations>`__ ).

你也可以用同样的方法测试类的引用变化, 方法是对PO文件进行类似的重命名, 并将其放在 doc/translations/ 文件夹中( GitHub).

本地化文档图像

在线文档包括许多图像, 这些图像可以是Godot编辑器的屏幕截图, 定制的图形以及任何其他类型的视觉内容. 其中一些包含文本, 因此可能与您的语言中的本地化相关.

这部分不通过Weblate处理, 而是直接在 godot-docs-l10n <https://github.com/godotengine/godot-docs-l10n&gt; _ Git仓库中处理, 文档翻译从Weblate同步过来.

注解

工作流不是最简单的, 需要一些Git知识. 我们计划开发一个简化的Web工具, 用它可以方便地管理图像定位, 抽象出这些步骤.

要翻译图像,你应该首先在原始的英文文档中找到它。为此,请浏览文档中的相关页面,例如 First look at Godot’s editor。单击右上角的“Edit on GitHub”链接:

../../_images/l10n_08_edit_on_github.png

在GitHub上, 单击要翻译的图像. 如果相关, 请单击 “下载” 在本地下载, 并使用图像编辑工具进行编辑. 请注意图像的完整路径, 因为它需要进一步向下(这里是 getting_started/step_by_step/img/project_manager_first_open.png ).

../../_images/l10n_09_path_to_image.png

创建图像的本地化版本, 或者编辑英文版本, 或者用你的语言截取编辑器的屏幕截图(如果是编辑器截图的话). 有些图像还可能有SVG格式的源文件, 因此您可以浏览包含它们的 img/ 文件夹以进行检查.

将你的本地化图片名改为原始图片名称, 并在扩展名前加上语言代码, 例如用于法语本地化的 project_manager_first_open.png 将变成 project_manager_first_open.fr.png .

最后,在 godot-docs-l10n 上,在 images 子文件夹中重新创建相同的文件夹结构(GitHub),并将翻译后的图像放在那里。在我们的示例中,最终结果应该是 images/getting_started/step_by_step/img/project_manager_first_open.fr.png

对其他图片重复这样做, 然后 发送一个 Pull Request.