From: st4lk Date: Tue, 27 Jan 2015 12:05:01 +0000 (+0300) Subject: add pgettext, npgettext docstrings X-Git-Tag: v4.2.0b1~96^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cf2af0980e685c934706bd4fd42336c7c710a6cd;p=thirdparty%2Ftornado.git add pgettext, npgettext docstrings --- diff --git a/tornado/locale.py b/tornado/locale.py index 4762c5a86..ef354d83e 100644 --- a/tornado/locale.py +++ b/tornado/locale.py @@ -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)