Ticket #10004: comment-extraction-3.patch
File comment-extraction-3.patch, 4.8 KB (added by , 14 years ago) |
---|
-
django/core/management/commands/makemessages.py
196 196 'xgettext -d %s -L Perl %s --keyword=gettext_noop ' 197 197 '--keyword=gettext_lazy --keyword=ngettext_lazy:1,2 ' 198 198 '--keyword=pgettext:1c,2 --keyword=npgettext:1c,2,3 ' 199 '--from-code UTF-8 - o - "%s"' % (199 '--from-code UTF-8 --add-comments=L10n -o - "%s"' % ( 200 200 domain, wrap, os.path.join(dirpath, thefile) 201 201 ) 202 202 ) … … 240 240 '--keyword=ugettext_noop --keyword=ugettext_lazy ' 241 241 '--keyword=ungettext_lazy:1,2 --keyword=pgettext:1c,2 ' 242 242 '--keyword=npgettext:1c,2,3 --keyword=pgettext_lazy:1c,2 ' 243 '--keyword=npgettext_lazy:1c,2,3 --from-code UTF-8 -o - ' 244 '"%s"' % (domain, wrap, os.path.join(dirpath, thefile)) 243 '--keyword=npgettext_lazy:1c,2,3 --from-code UTF-8 ' 244 '--add-comments=L10n -o - "%s"' % ( 245 domain, wrap, os.path.join(dirpath, thefile)) 245 246 ) 246 247 msgs, errors = _popen(cmd) 247 248 if errors: -
tests/regressiontests/i18n/commands/__init__.py
1 from django.utils.translation import ugettext as _ 2 3 # L10n: This comment should be extracted 4 dummy1 = _("This is a translatable string.") 5 6 # This comment should not be extracted 7 dummy2 = _("This is another translatable string.") 8 -
tests/regressiontests/i18n/commands/extraction.py
38 38 return self.assert_(not re.search('^msgid %s' % msgid, s, re.MULTILINE)) 39 39 40 40 41 class TemplateExtractorTests(ExtractorTests):41 class BasicExtractorTests(ExtractorTests): 42 42 43 def test_comments_extractor(self): 44 os.chdir(self.test_dir) 45 management.call_command('makemessages', locale=LOCALE, verbosity=0) 46 self.assert_(os.path.exists(self.PO_FILE)) 47 po_contents = open(self.PO_FILE, 'r').read() 48 self.assert_('#. L10n: This comment should be extracted' in po_contents) 49 self.assert_('This comment should not be extracted' not in po_contents) 50 43 51 def test_templatize(self): 44 52 os.chdir(self.test_dir) 45 53 management.call_command('makemessages', locale=LOCALE, verbosity=0) -
docs/topics/i18n/internationalization.txt
100 100 have more than a single parameter. If you used positional interpolation, 101 101 translations wouldn't be able to reorder placeholder text. 102 102 103 .. _translator-comments: 104 105 Comments for translators 106 ------------------------ 107 108 .. versionadded:: 1.3 109 110 If you would like to give translators any hint about a translatable string, you 111 can add a comment prefixed with the ``L10n`` keyword on the line just before the 112 string marked for translation: 113 114 def my_view(request): 115 # L10n: This message appears on the home page only 116 output = ugettext("Welcome to my site.") 117 118 The comment will then appear in the resulting .po file and should also be 119 displayed by most translation tools. 120 103 121 Marking strings as no-op 104 122 ------------------------ 105 123 -
docs/releases/1.3.txt
86 86 87 87 For more information, see :ref:`transaction-management-functions`. 88 88 89 Contextual markers intranslatable strings90 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 89 Contextual markers and comments for translatable strings 90 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 91 91 92 92 For translation strings with ambiguous meaning, you can now 93 93 use the ``pgettext`` function to specify the context of the string. 94 94 95 For more information, see :ref:`contextual-markers` 95 And if you just want to add some information aimed at translators, you 96 can also add special translator comments in the source. 96 97 98 For more information, see :ref:`contextual-markers` and :ref:`translator-comments`. 99 97 100 Everything else 98 101 ~~~~~~~~~~~~~~~ 99 102