editor_and_docs_localization.rst 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  1. .. _doc_editor_and_docs_localization:
  2. Editor and documentation localization
  3. =====================================
  4. .. highlight:: none
  5. Godot aims to make game development available to everyone, including people who
  6. may not know or be comfortable with English. Therefore, we do our best to make
  7. the most important resources available in many languages, thanks to the
  8. translation effort of the community.
  9. These resources include:
  10. 1. The `Godot editor's interface <https://hosted.weblate.org/projects/godot-engine/godot/>`__
  11. (ca. 15,000 words).
  12. 2. The `online documentation <https://hosted.weblate.org/projects/godot-engine/godot-docs/>`__
  13. (editor manual and tutorials, ca. 300,000 words).
  14. 3. The `class reference <https://hosted.weblate.org/projects/godot-engine/godot-class-reference/>`__,
  15. available both online and in the editor (ca. 200,000 words).
  16. To manage translations, we use the GNU gettext file format (``PO`` files), and
  17. the open source `Weblate <https://weblate.org>`__ web-based localization
  18. platform, which allows easy collaboration of many contributors to complete the
  19. translation for the various components, and keep them up to date. Click the bold
  20. links above to access each resource on Weblate.
  21. This page gives an overview of the general translation workflow on Weblate, and
  22. some resource-specific instructions on e.g. how to handle some keywords or the
  23. localization of images.
  24. .. tip::
  25. Translating all the official Godot content is a massive undertaking, so we
  26. advise prioritizing the resources as they are listed above: first the editor
  27. interface, then the online documentation, and eventually the class reference
  28. if there are enough translators to keep up with updates.
  29. Using Weblate for translations
  30. ------------------------------
  31. While our translations eventually reside in the Git repositories of the Godot
  32. engine and its documentation, all translation updates are handled through
  33. Weblate, and thus direct pull requests to the Git repositories are not accepted.
  34. Translations are synced manually between Weblate and the Godot repositories by
  35. maintainers.
  36. You should therefore `register on Weblate <https://hosted.weblate.org/accounts/register/>`__
  37. to contribute to Godot's translations.
  38. Once signed in, browse to the Godot resource which you want to contribute to (in
  39. this page we will use the `editor translation <https://hosted.weblate.org/projects/godot-engine/godot/>`__
  40. as an example) to find the list of all languages:
  41. .. image:: img/l10n_01_language_list.png
  42. .. seealso::
  43. Feel free to consult Weblate's own documentation on the `translation
  44. workflow <https://docs.weblate.org/en/latest/user/translating.html>`__ for
  45. more details.
  46. Adding a new language
  47. ^^^^^^^^^^^^^^^^^^^^^
  48. If your language is already listed, click on its name to access the overview,
  49. and skip the rest of this section.
  50. If your language is not listed, scroll to the bottom of the list of languages
  51. and click the "Start new translation" button, and select the language you want
  52. to translate to:
  53. .. image:: img/l10n_02_new_translation.png
  54. .. important::
  55. If your language is spoken in several countries with only limited regional
  56. variations, please consider adding it with its generic variant (e.g. ``fr``
  57. for French) instead of a regional variant (e.g. ``fr_FR`` for French
  58. (France), ``fr_CA`` for French (Canada), or ``fr_DZ`` for French (Algeria)).
  59. Godot has a huge amount of content to translate, so duplicating the work for
  60. regional variants should only be done if the language variations are
  61. significant enough. Additionally, if a translation is done with for a
  62. regional variant, it will only be available automatically for users located
  63. in this region (or having their system language configured for this region).
  64. When regional variations are significant enough to warrant separate
  65. translations, we advise to focus on completing a generic variant first if
  66. possible, then duplicate the fully completed translation for regional
  67. variants and do the relevant edits. This is typically a good strategy for
  68. e.g. Spanish (work on ``es`` first, then duplicate it to ``es_AR``,
  69. ``es_ES``, ``es_MX``, etc. if necessary) or Portuguese (``pt_BR`` vs
  70. ``pt_PT``).
  71. Translation interface
  72. ^^^^^^^^^^^^^^^^^^^^^
  73. Once a language has been selected, you will see an overview of the translation
  74. status, including how many strings are left to translate or review. Each item
  75. can be clicked and used to browse through the corresponding list. You can also
  76. click the "Translate" button to get started on the list of strings needing
  77. action.
  78. .. image:: img/l10n_03_translation_overview.png
  79. After selecting a list of clicking "Translate", you will see the main
  80. translation interface where all the work happens:
  81. .. image:: img/l10n_04_translation_interface.png
  82. On that page, you have:
  83. - A toolbar which lets you cycle through strings of the current list, change
  84. to another predefined list or do a custom search, etc. There is also a "Zen"
  85. editing mode with a simplified interface.
  86. - The actual string you are working on in the "Translation" panel. By default,
  87. there should be the English source string and an edit box for your language.
  88. If you are familiar with other languages, you can add them in your user
  89. settings to give you more context for translation.
  90. Once you are done editing the current string, press "Save" to confirm changes
  91. and move to the next entry. Alternatively, use the "Skip" button to skip it.
  92. The "Needs editing" checkbox means that the original string was updated, and
  93. the translation therefore needs review to take those changes into account (in
  94. PO jargon, these are so-called "fuzzy" strings). Such strings won't be used
  95. in the translation until fixed.
  96. - The bottom panel has various tools which can help with the translation
  97. effort, such as context from nearby strings (usually from the same editor
  98. tool or documentation page, so they might use similar terms), comments from
  99. other translators, machine translations, and a list of all other existing
  100. translations for that string.
  101. - On the top right, the glossary shows terms for which an entry has been added
  102. previously, and which are included in the current string. For example, if
  103. you decided with fellow translators to use a specific translation for the
  104. "node" term in Godot, you can add it to the glossary to ensure that other
  105. translators use the same convention.
  106. - The bottom right panel includes information on the source string. The most
  107. relevant item is the "source string location", which links you to the
  108. original string on GitHub. You may need to search for the string in the page
  109. to locate it and its surrounding context.
  110. Locating original content
  111. -------------------------
  112. PO files are an ordered list of source strings (``msgid``) and their translation
  113. (``msgstr``), and by default, Weblate will present the strings in that order. It
  114. can therefore be useful to understand how the content is organized in the PO
  115. files to help you locate the original content and use it as a reference when
  116. translating.
  117. .. important::
  118. It is primordial to use the original context as reference when translating,
  119. as many words have several possible translations depending on the context.
  120. Using the wrong translation can actually be detrimental to the user and make
  121. things harder to understand than if they stayed in English.
  122. Using the context also makes the translation effort much easier and more
  123. enjoyable, as you can see directly if the translation you wrote will make
  124. sense in context.
  125. - The editor interface's translation template is generated by parsing all the
  126. C++ source code in **alphabetical order**, so all the strings defined in a
  127. given file will be grouped together. For example, if the "source string
  128. location" indicates ``editor/code_editor.cpp``, the current string (and the
  129. nearby ones) is defined in the ``editor/code_editor.cpp`` code file, and is
  130. thereby related to the code editors in Godot (GDScript, shaders).
  131. - The online documentation's translation template is generated from the source
  132. RST files in the same order as seen in the **table of contents**, so for
  133. example the first strings are from the front page of the documentation.
  134. The recommended workflow is therefore to find a unique string corresponding to
  135. a page that you want to translate, and then translate all the strings with the
  136. same source string location while comparing with the online version of that
  137. page in English. An example of source string location could be
  138. ``getting_started/step_by_step/nodes_and_scenes.rst`` for the
  139. page :ref:`doc_nodes_and_scenes`.
  140. - The class reference's translation template is generated from the source XML
  141. files in **alphabetical order**, which is also the same as the order of the
  142. table of contents for the online version. You can therefore locate the source
  143. string corresponding to the brief description of a given class to find the
  144. first string to translate and all other descriptions from that class should be
  145. in the subsequent strings on Weblate. For example, the descriptions for the
  146. :ref:`class_Node2D` class would have the source string location
  147. ``doc/classes/Node2D.xml``.
  148. A handy tool to locate specific pages/classes is to use Weblate's advanced
  149. search feature, and especially the "Location strings" query (which can also be
  150. used with the ``location:`` token, e.g. ``location:nodes_and_scenes.rst``):
  151. .. image:: img/l10n_05_search_location.png
  152. .. image:: img/l10n_06_browse_by_location.png
  153. .. note::
  154. When a given source string is used in multiple source locations, they will
  155. all be concatenated into one. For example, the above
  156. ``location:nodes_and_scenes.rst`` query would land first on the
  157. "Introduction" source string which is used in dozens of pages, including
  158. some that come before ``nodes_and_scenes.rst`` in the template. Clicking the
  159. "Next" button then brings us to the "Scene and nodes" title string displayed
  160. above.
  161. So it may happen that a given paragraph or section title is not at the
  162. location you'd expect it when reading the online version of a page.
  163. Respecting the markup syntax
  164. ----------------------------
  165. Each translation resource originates from a different source code format, and
  166. having some notions on the markup language used for each resource is important
  167. to avoid creating syntax errors in your translations.
  168. Editor interface (C++)
  169. ^^^^^^^^^^^^^^^^^^^^^^
  170. The editor translations originate from C++ strings, and may use:
  171. - **C format specifiers** such as ``%s`` (a string) or ``%d`` (a number). These
  172. specifiers are replaced by content at runtime, and should be preserved and
  173. placed in your translation where necessary for it to be meaningful after
  174. substitution. You may need to refer to the source string location to
  175. understand what kind of content will be substituted if it's not clear from the
  176. sentence. Example (``%s`` will be substituted with a file name or path)::
  177. # PO file:
  178. "There is no '%s' file."
  179. # Weblate:
  180. There is no '%s' file.
  181. - **C escape characters** such as ``\n`` (line break) or ``\t`` (tabulation). In
  182. the Weblate editor, the ``\n`` characters are replaced by ``↵`` (return) and
  183. ``\t`` by ``↹``. Tabs are not used much, but you should make sure to use line
  184. breaks in the same way as the original English string (Weblate will issue a
  185. warning if you don't). Line breaks might sometimes be used for vertical
  186. spacing, or manual wrapping of long lines which would otherwise be too long
  187. especially in the editor translation). Example::
  188. # PO file:
  189. "Scene '%s' is currently being edited.\n"
  190. "Changes will only take effect when reloaded."
  191. # Weblate:
  192. Scene '%s' is currently being edited.↵
  193. Changes will only take effect when reloaded.
  194. .. note::
  195. Only logical order of the characters matters, in the right-to-left text, format
  196. specifiers may be displayed as ``s%``.
  197. Online documentation (RST)
  198. ^^^^^^^^^^^^^^^^^^^^^^^^^^
  199. The documentation translations originate from reStructuredText (RST) files,
  200. which also use their own markup syntax to style text, create internal and
  201. external links, etc. Here are some examples::
  202. # "development" is styled bold.
  203. # "Have a look here" is a link pointing to https://docs.godotengine.org/en/latest.
  204. # You should translate "Have a look here", but not the URL, unless there is
  205. # a matching URL for the same content in your language.
  206. # Note: The `, <, >, and _ characters all have a meaning in the hyperlink
  207. # syntax and should be preserved.
  208. Looking for the documentation of the current **development** branch?
  209. `Have a look here <https://docs.godotengine.org/en/latest>`_.
  210. # "|supported|" is an inline reference to an image and should stay unchanged.
  211. # "master" uses the markup for inline code, and will be styled as such.
  212. # Note: Inline code in RST uses 2 backticks on each side, unlike Markdown.
  213. # Single backticks are used for hyperlinks.
  214. |supported| Backwards-compatible new features (backported from the ``master``
  215. branch) as well as bug, security, and platform support fixes.
  216. # The :ref: Sphinx "role" is used for internal references to other pages of
  217. # the documentation.
  218. # It can be used with only the reference name of a page (which should not be
  219. # changed), in which case the title of that page will be displayed:
  220. See :ref:`doc_ways_to_contribute`.
  221. # Or it can be used with an optional custom title, which should thus be translated:
  222. See :ref:`how to contribute <doc_ways_to_contribute>`.
  223. # You may encounter other Sphinx roles, such as :kbd: used for shortcut keys.
  224. # You can translate the content between backticks to match the usual key names,
  225. # if it's different from the English one.
  226. Save the scene. Click Scene -> Save, or press :kbd:`Ctrl + S` on Windows/Linux
  227. or :kbd:`Cmd + S` on macOS.
  228. .. seealso::
  229. See Sphinx's `reStructured Text primer <https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html>`__
  230. for a quick overview of the markup language you may find in source strings.
  231. You may encounter especially the inline markup (bold, italics, inline code)
  232. and the internal and external hyperlink markup.
  233. Class reference (BBCode)
  234. ^^^^^^^^^^^^^^^^^^^^^^^^
  235. The class reference is documented in the main Godot repository using XML files,
  236. and with BBCode-like markup for styling and internal references.
  237. Some of the tags used are from the original BBCode (e.g. ``[b]Bold[/b]`` and
  238. ``[i]Italics[/i]``), while others are Godot-specific and used for advanced
  239. features such as inline code (e.g. ``[code]true[/code]``), linking to another
  240. class (e.g. ``[Node2D]``) or to a property in a given class (e.g.
  241. ``[member Node2D.position]``), or for multiline code blocks. Example::
  242. Returns a color according to the standardized [code]name[/code] with [code]alpha[/code] ranging from 0 to 1.
  243. [codeblock]
  244. red = ColorN("red", 1)
  245. [/codeblock]
  246. Supported color names are the same as the constants defined in [Color].
  247. In the above example, ``[code]name[/code]``, ``[code]alpha[/code]``, and
  248. ``[Color]`` should *not* be translated, as they refer respectively to argument
  249. names and a class of the Godot API. Similarly, the contents of the
  250. ``[codeblock]`` should not be translated, as ``ColorN`` is a function of the
  251. Godot API and ``"red"`` is one of the named colors it supports. At most, you can
  252. translate the name of the variable which holds the result (``red = ...``).
  253. Note also that in the XML, each line is a paragraph, so you should not add line
  254. breaks if they are not part of the original translation.
  255. .. seealso::
  256. See our documentation for class reference writers for the :ref:`list of
  257. BBCode-like tags <doc_class_reference_bbcode>` which are used
  258. throughout the class reference.
  259. Offline translation and testing
  260. -------------------------------
  261. While we advise using the Weblate interface to write translations, you also have
  262. the possibility to download the PO file locally to translate it with your
  263. preferred PO editing application, such as `Poedit <https://poedit.net/>`__ or
  264. `Lokalize <https://userbase.kde.org/Lokalize>`__.
  265. To download the PO file locally, browse to the translation overview for your
  266. language, and select the first item in the "Files" menu:
  267. .. image:: img/l10n_07_download_po_file.png
  268. Once you are done with a series of edits, use the "Upload translation" item in
  269. that same menu and select your file. Choose "Add as translation" for the file
  270. upload mode.
  271. .. note::
  272. If a significant amount of time has passed between your download of the PO
  273. file and the upload of the edited version, there is a risk to overwrite the
  274. translations authored by other contributors in the meantime. This is why we
  275. advise to use the online interface so that you always work on the latest
  276. version.
  277. If you want to test changes locally (especially for the editor translation), you
  278. can use the downloaded PO file and :ref:`compile Godot from source <toc-devel-compiling>`.
  279. Rename the editor translation PO file to ``<lang>.po`` (e.g. ``eo.po`` for
  280. Esperanto) and place it in the ``editor/translations/`` folder
  281. (`GitHub <https://github.com/godotengine/godot/tree/master/editor/translations>`__).
  282. You can also test class reference changes the same way by renaming the PO file
  283. similarly and placing it in the ``doc/translations/`` folder
  284. (`GitHub <https://github.com/godotengine/godot/tree/master/doc/translations>`__).
  285. Localizing documentation images
  286. -------------------------------
  287. The online documentation includes many images, which can be screenshots of the
  288. Godot editor, custom-made graphs, of any other kind of visual content. Some of
  289. it includes text and might thus be relevant to localize in your language.
  290. This part is not handled via Weblate, but directly on the `godot-docs-l10n
  291. <https://github.com/godotengine/godot-docs-l10n>`_ Git repository where the
  292. documentation translations are synced from Weblate.
  293. .. note::
  294. The workflow is not the most straightforward and requires some knowledge of
  295. Git. We plan to work on a simplified Web tool which could be used to manage
  296. image localization in a convenient way, abstracting away these steps.
  297. To translate an image, you should first locate it in the original English
  298. documentation. To do so, browse the relevant page in the docs, e.g.
  299. :ref:`doc_intro_to_the_editor_interface`. Click the "Edit on GitHub" link in the
  300. top right corner:
  301. .. image:: img/l10n_08_edit_on_github.png
  302. On GitHub, click on the image you want to translate. If relevant, click on
  303. "Download" to download it locally and edit it with an image edition tool.
  304. Note the full path to the image as it will be needed further down (here
  305. ``getting_started/step_by_step/img/project_manager_first_open.png``).
  306. .. image:: img/l10n_09_path_to_image.png
  307. Create your localized version of the image, either by editing the English one,
  308. or by taking a screenshot of the editor with your language, if it's an editor
  309. screenshot. Some images may also have source files available in SVG format, so
  310. you can browse the ``img/`` folder which contains them to check for that.
  311. Name your localized image like the original one, but with the language code
  312. added before the extension, e.g. ``project_manager_first_open.png`` would become
  313. ``project_manager_first_open.fr.png`` for the French localization.
  314. Finally, on godot-docs-l10n_, recreate the same folder structure as for the
  315. original image in the ``images`` subfolder
  316. (`GitHub <https://github.com/godotengine/godot-docs-l10n/tree/master/images>`_),
  317. and place your translated image there. In our example, the end result should be
  318. ``images/getting_started/step_by_step/img/project_manager_first_open.fr.png``.
  319. Repeat this for other images and :ref:`make a Pull Request <doc_pr_workflow>`.