From bfe1d4e87410c3b187074f949b8b916780efb585 Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Wed, 5 Nov 2025 01:09:57 +0100 Subject: [PATCH] Clarify how to define a context-sensitive string in Localization using gettext --- tutorials/i18n/localization_using_gettext.rst | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/tutorials/i18n/localization_using_gettext.rst b/tutorials/i18n/localization_using_gettext.rst index 181abc4d5..9210635c2 100644 --- a/tutorials/i18n/localization_using_gettext.rst +++ b/tutorials/i18n/localization_using_gettext.rst @@ -21,7 +21,7 @@ Advantages - gettext is a standard format, which can be edited using any text editor or GUI editors such as `Poedit `_. This can be significant as it provides a lot of tools for translators, such as marking outdated - strings, finding strings that haven't been translated etc. + strings, finding strings that haven't been translated, etc. - gettext is supported by translation platforms such as `Transifex `_ and `Weblate `_, which makes it easier for people to collaborate to localization. @@ -294,6 +294,20 @@ For example: tr("Shop", "Main Menu") tr("Shop", "In Game") +In a gettext PO file, a string with a context can be defined as follows: + +:: + + # Example of a string with a translation context. + msgctxt "Main Menu" + msgid "Shop" + msgstr "" + + # A different source string that is identical, but with a different context. + msgctxt "In Game" + msgid "Shop" + msgstr "" + Updating PO files -----------------