]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
add pgettext, npgettext docstrings
authorst4lk <myhappydo@gmail.com>
Tue, 27 Jan 2015 12:05:01 +0000 (15:05 +0300)
committerst4lk <myhappydo@gmail.com>
Tue, 27 Jan 2015 12:05:01 +0000 (15:05 +0300)
tornado/locale.py

index 4762c5a86783d8410cbf2b89d47c9d333399a022..ef354d83e520afca5b9f7daf2ba3057a561d0e75 100644 (file)
@@ -461,6 +461,18 @@ class GettextLocale(Locale):
             return self.gettext(message)
 
     def pgettext(self, context, message):
+        """Allows to set context for translation.
+
+        Usage example:
+
+            pgettext("law", "right")
+            pgettext("good", "right")
+
+        To generate POT file with context, add following option to step 1
+        of `load_gettext_translations` sequence:
+
+            xgettext [basic options] --keyword=pgettext:1c,2
+        """
         msg_with_ctxt = "%s%s%s" % (context, CONTEXT_SEPARATOR, message)
         result = self.gettext(msg_with_ctxt)
         if CONTEXT_SEPARATOR in result:
@@ -469,6 +481,18 @@ class GettextLocale(Locale):
         return result
 
     def npgettext(self, context, singular, plural, number):
+        """Allows to set context for translation with plural form.
+
+        Usage example:
+
+            npgettext("organization", "club", "clubs", len(clubs))
+            npgettext("stick", "club", "clubs", len(clubs))
+
+        To generate POT file with context, add following option to step 1
+        of `load_gettext_translations` sequence:
+
+            xgettext [basic options] --keyword=npgettext:1c,2,3
+        """
         msgs_with_ctxt = ("%s%s%s" % (context, CONTEXT_SEPARATOR, singular),
                           "%s%s%s" % (context, CONTEXT_SEPARATOR, plural),
                           number)