Skip to content

Commit 1de8ca3

Browse files
authored
Merge pull request #11442 from Calinou/localization-using-gettext-contexts
Clarify how to define a context-sensitive string in Localization using gettext
2 parents 8584b05 + bfe1d4e commit 1de8ca3

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

tutorials/i18n/localization_using_gettext.rst

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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 is supported by translation platforms such as
2626
`Transifex <https://www.transifex.com/>`_ and `Weblate <https://weblate.org/>`_,
2727
which makes it easier for people to collaborate to localization.
@@ -294,6 +294,20 @@ For example:
294294
tr("Shop", "Main Menu")
295295
tr("Shop", "In Game")
296296

297+
In a gettext PO file, a string with a context can be defined as follows:
298+
299+
::
300+
301+
# Example of a string with a translation context.
302+
msgctxt "Main Menu"
303+
msgid "Shop"
304+
msgstr ""
305+
306+
# A different source string that is identical, but with a different context.
307+
msgctxt "In Game"
308+
msgid "Shop"
309+
msgstr ""
310+
297311
Updating PO files
298312
-----------------
299313

0 commit comments

Comments
 (0)