瀏覽代碼

Clarify how to define a context-sensitive string in Localization using gettext

Hugo Locurcio 1 月之前
父節點
當前提交
bfe1d4e874
共有 1 個文件被更改,包括 15 次插入1 次删除
  1. 15 1
      tutorials/i18n/localization_using_gettext.rst

+ 15 - 1
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 <https://poedit.net/>`_. 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 <https://www.transifex.com/>`_ and `Weblate <https://weblate.org/>`_,
   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
 -----------------