@@ -21,7 +21,7 @@ Advantages
2121- gettext is a standard format, which can be edited using any text editor
2222 or GUI editors such as `Poedit <https://poedit.net/ >`_. This can be significant
2323 as it provides a lot of tools for translators, such as marking outdated
24- strings, finding strings that haven't been translated etc.
24+ strings, finding strings that haven't been translated etc.
2525- gettext supports plurals and context.
2626- gettext is supported by translation platforms such as
2727 `Transifex <https://www.transifex.com/ >`_ and `Weblate <https://weblate.org/ >`_,
@@ -39,8 +39,8 @@ Disadvantages
3939- People who maintain localization files will have to install gettext tools
4040 on their system. However, as Godot supports using text-based message files
4141 (``.po ``), translators can test their work without having to install gettext tools.
42- - gettext PO files usually use English as the base language. Translators will use
43- this base language to translate to other languages. You could still user other
42+ - gettext PO files usually use English as the base language. Translators will use
43+ this base language to translate to other languages. You could still user other
4444 languages as the base language, but this is not common.
4545
4646Installing gettext tools
@@ -286,7 +286,7 @@ Using context
286286The ``context `` parameter can be used to differentiate the situation where a translation
287287is used, or to differentiate polysemic words (words with multiple meanings).
288288
289- For example:
289+ For example:
290290
291291::
292292
@@ -295,13 +295,27 @@ For example:
295295 tr("Shop", "Main Menu")
296296 tr("Shop", "In Game")
297297
298+ In a gettext PO file, a string with a context can be defined as follows:
299+
300+ ::
301+
302+ # Example of a string with a translation context.
303+ msgctxt "Main Menu"
304+ msgid "Shop"
305+ msgstr ""
306+
307+ # A different source string that is identical, but with a different context.
308+ msgctxt "In Game"
309+ msgid "Shop"
310+ msgstr ""
311+
298312Updating PO files
299313-----------------
300314
301315Some time or later, you'll add new content to our game, and there will be new strings that need to be translated. When this happens, you'll
302316need to update the existing PO files to include the new strings.
303317
304- First, generate a new POT file containing all the existing strings plus the newly added strings. After that, merge the existing
318+ First, generate a new POT file containing all the existing strings plus the newly added strings. After that, merge the existing
305319PO files with the new POT file. There are two ways to do this:
306320
307321- Use a gettext editor, and it should have an option to update a PO file from a POT file.
@@ -313,12 +327,12 @@ PO files with the new POT file. There are two ways to do this:
313327 # The order matters: specify the message file *then* the PO template!
314328 msgmerge --update --backup=none fr.po messages.pot
315329
316- If you want to keep a backup of the original message file (which would be saved as ``fr.po~ `` in this example),
330+ If you want to keep a backup of the original message file (which would be saved as ``fr.po~ `` in this example),
317331remove the ``--backup=none `` argument.
318332
319333POT generation custom plugin
320334----------------------------
321335
322- If you have any extra file format to deal with, you could write a custom plugin to parse and and extract the strings from the custom file.
336+ If you have any extra file format to deal with, you could write a custom plugin to parse and and extract the strings from the custom file.
323337This custom plugin will extract the strings and write into the POT file when you hit **Generate POT **. To learn more about how to
324338create the translation parser plugin, see :ref: `EditorTranslationParserPlugin <class_EditorTranslationParserPlugin >`.
0 commit comments