Loading AUTHORS +1 −0 Original line number Diff line number Diff line Loading @@ -98,6 +98,7 @@ answer newbie questions, and generally made Django that much better: Mark Biggers <biggers@utsl.com> Paul Bissex <http://e-scribe.com/> Simon Blanchard Craig Blaszczyk <masterjakul@gmail.com> David Blewett <david@dawninglight.net> Matt Boersma <matt@sprout.org> Artem Gnilov <boobsd@gmail.com> Loading django/core/management/commands/compilemessages.py +10 −6 Original line number Diff line number Diff line Loading @@ -28,10 +28,14 @@ def compile_messages(stderr, locale=None): for basedir in basedirs: if locale: basedir = os.path.join(basedir, locale, 'LC_MESSAGES') for dirpath, dirnames, filenames in os.walk(basedir): dirs = [os.path.join(basedir, l, 'LC_MESSAGES') for l in (locale if isinstance(locale, list) else [locale])] else: dirs = [basedir] for ldir in dirs: for dirpath, dirnames, filenames in os.walk(ldir): for f in filenames: if f.endswith('.po'): if not f.endswith('.po'): continue stderr.write('processing file %s in %s\n' % (f, dirpath)) fn = os.path.join(dirpath, f) if has_bom(fn): Loading @@ -53,8 +57,8 @@ def compile_messages(stderr, locale=None): class Command(BaseCommand): option_list = BaseCommand.option_list + ( make_option('--locale', '-l', dest='locale', help='The locale to process. Default is to process all.'), make_option('--locale', '-l', dest='locale', action='append', help='locale(s) to process (e.g. de_AT). Default is to process all. Can be used multiple times, accepts a comma-separated list of locale names.'), ) help = 'Compiles .po files to .mo files for use with builtin gettext support.' Loading django/core/management/commands/makemessages.py +3 −3 Original line number Diff line number Diff line Loading @@ -304,7 +304,7 @@ def make_messages(locale=None, domain='django', verbosity=1, all=False, locales = [] if locale is not None: locales.append(str(locale)) locales += locale.split(',') if not isinstance(locale, list) else locale elif all: locale_dirs = filter(os.path.isdir, glob.glob('%s/*' % localedir)) locales = [os.path.basename(l) for l in locale_dirs] Loading Loading @@ -341,8 +341,8 @@ def make_messages(locale=None, domain='django', verbosity=1, all=False, class Command(NoArgsCommand): option_list = NoArgsCommand.option_list + ( make_option('--locale', '-l', default=None, dest='locale', help='Creates or updates the message files for the given locale (e.g. pt_BR).'), make_option('--locale', '-l', default=None, dest='locale', action='append', help='Creates or updates the message files for the given locale(s) (e.g. pt_BR). Can be used multiple times, accepts a comma-separated list of locale names.'), make_option('--domain', '-d', default='django', dest='domain', help='The domain of the message files (default: "django").'), make_option('--all', '-a', action='store_true', dest='all', Loading docs/ref/django-admin.txt +25 −3 Original line number Diff line number Diff line Loading @@ -107,12 +107,21 @@ compilemessages Compiles .po files created with ``makemessages`` to .mo files for use with the builtin gettext support. See :doc:`/topics/i18n/index`. Use the :djadminopt:`--locale` option to specify the locale to process. If not provided, all locales are processed. Use the :djadminopt:`--locale` option (or its shorter version ``-l``) to specify the locale(s) to process. If not provided, all locales are processed. Example usage:: django-admin.py compilemessages --locale=pt_BR django-admin.py compilemessages --locale=pt_BR --locale=fr django-admin.py compilemessages -l pt_BR django-admin.py compilemessages -l pt_BR -l fr django-admin.py compilemessages --locale=pt_BR,fr django-admin.py compilemessages -l pt_BR,fr .. versionchanged:: 1.6 Added the ability to specify multiple locales. createcachetable ---------------- Loading Loading @@ -422,11 +431,24 @@ Separate multiple extensions with commas or use -e or --extension multiple times django-admin.py makemessages --locale=de --extension=html,txt --extension xml Use the :djadminopt:`--locale` option to specify the locale to process. Use the :djadminopt:`--locale` option (or its shorter version ``-l``) to specify the locale(s) to process. Example usage:: django-admin.py makemessages --locale=pt_BR django-admin.py makemessages --locale=pt_BR --locale=fr django-admin.py makemessages -l pt_BR django-admin.py makemessages -l pt_BR -l fr You can also use commas to separate multiple locales:: django-admin.py makemessages --locale=de,fr,pt_BR django-admin.py makemessages -l de,fr,pt_BR .. versionchanged:: 1.6 Added the ability to specify multiple locales. .. django-admin-option:: --domain Loading tests/regressiontests/i18n/commands/compilation.py +31 −0 Original line number Diff line number Diff line Loading @@ -68,3 +68,34 @@ class PercentRenderingTests(MessageCompilationTests): t = Template('{% load i18n %}{% trans "Completed 50%% of all the tasks" %}') rendered = t.render(Context({})) self.assertEqual(rendered, 'IT translation of Completed 50%% of all the tasks') @override_settings(LOCALE_PATHS=(os.path.join(test_dir, 'locale'),)) class MultipleLocaleCompilationTests(MessageCompilationTests): MO_FILE_HR = None MO_FILE_FR = None def setUp(self): super(MultipleLocaleCompilationTests, self).setUp() self.localedir = os.path.join(test_dir, 'locale') self.MO_FILE_HR = os.path.join(self.localedir, 'hr/LC_MESSAGES/django.mo') self.MO_FILE_FR = os.path.join(self.localedir, 'fr/LC_MESSAGES/django.mo') self.addCleanup(self._rmfile, os.path.join(self.localedir, self.MO_FILE_HR)) self.addCleanup(self._rmfile, os.path.join(self.localedir, self.MO_FILE_FR)) def _rmfile(self, filepath): if os.path.exists(filepath): os.remove(filepath) def test_one_locale(self): os.chdir(test_dir) call_command('compilemessages', locale='hr', stderr=StringIO()) self.assertTrue(os.path.exists(self.MO_FILE_HR)) def test_multiple_locales(self): os.chdir(test_dir) call_command('compilemessages', locale=['hr', 'fr'], stderr=StringIO()) self.assertTrue(os.path.exists(self.MO_FILE_HR)) self.assertTrue(os.path.exists(self.MO_FILE_FR)) Loading
AUTHORS +1 −0 Original line number Diff line number Diff line Loading @@ -98,6 +98,7 @@ answer newbie questions, and generally made Django that much better: Mark Biggers <biggers@utsl.com> Paul Bissex <http://e-scribe.com/> Simon Blanchard Craig Blaszczyk <masterjakul@gmail.com> David Blewett <david@dawninglight.net> Matt Boersma <matt@sprout.org> Artem Gnilov <boobsd@gmail.com> Loading
django/core/management/commands/compilemessages.py +10 −6 Original line number Diff line number Diff line Loading @@ -28,10 +28,14 @@ def compile_messages(stderr, locale=None): for basedir in basedirs: if locale: basedir = os.path.join(basedir, locale, 'LC_MESSAGES') for dirpath, dirnames, filenames in os.walk(basedir): dirs = [os.path.join(basedir, l, 'LC_MESSAGES') for l in (locale if isinstance(locale, list) else [locale])] else: dirs = [basedir] for ldir in dirs: for dirpath, dirnames, filenames in os.walk(ldir): for f in filenames: if f.endswith('.po'): if not f.endswith('.po'): continue stderr.write('processing file %s in %s\n' % (f, dirpath)) fn = os.path.join(dirpath, f) if has_bom(fn): Loading @@ -53,8 +57,8 @@ def compile_messages(stderr, locale=None): class Command(BaseCommand): option_list = BaseCommand.option_list + ( make_option('--locale', '-l', dest='locale', help='The locale to process. Default is to process all.'), make_option('--locale', '-l', dest='locale', action='append', help='locale(s) to process (e.g. de_AT). Default is to process all. Can be used multiple times, accepts a comma-separated list of locale names.'), ) help = 'Compiles .po files to .mo files for use with builtin gettext support.' Loading
django/core/management/commands/makemessages.py +3 −3 Original line number Diff line number Diff line Loading @@ -304,7 +304,7 @@ def make_messages(locale=None, domain='django', verbosity=1, all=False, locales = [] if locale is not None: locales.append(str(locale)) locales += locale.split(',') if not isinstance(locale, list) else locale elif all: locale_dirs = filter(os.path.isdir, glob.glob('%s/*' % localedir)) locales = [os.path.basename(l) for l in locale_dirs] Loading Loading @@ -341,8 +341,8 @@ def make_messages(locale=None, domain='django', verbosity=1, all=False, class Command(NoArgsCommand): option_list = NoArgsCommand.option_list + ( make_option('--locale', '-l', default=None, dest='locale', help='Creates or updates the message files for the given locale (e.g. pt_BR).'), make_option('--locale', '-l', default=None, dest='locale', action='append', help='Creates or updates the message files for the given locale(s) (e.g. pt_BR). Can be used multiple times, accepts a comma-separated list of locale names.'), make_option('--domain', '-d', default='django', dest='domain', help='The domain of the message files (default: "django").'), make_option('--all', '-a', action='store_true', dest='all', Loading
docs/ref/django-admin.txt +25 −3 Original line number Diff line number Diff line Loading @@ -107,12 +107,21 @@ compilemessages Compiles .po files created with ``makemessages`` to .mo files for use with the builtin gettext support. See :doc:`/topics/i18n/index`. Use the :djadminopt:`--locale` option to specify the locale to process. If not provided, all locales are processed. Use the :djadminopt:`--locale` option (or its shorter version ``-l``) to specify the locale(s) to process. If not provided, all locales are processed. Example usage:: django-admin.py compilemessages --locale=pt_BR django-admin.py compilemessages --locale=pt_BR --locale=fr django-admin.py compilemessages -l pt_BR django-admin.py compilemessages -l pt_BR -l fr django-admin.py compilemessages --locale=pt_BR,fr django-admin.py compilemessages -l pt_BR,fr .. versionchanged:: 1.6 Added the ability to specify multiple locales. createcachetable ---------------- Loading Loading @@ -422,11 +431,24 @@ Separate multiple extensions with commas or use -e or --extension multiple times django-admin.py makemessages --locale=de --extension=html,txt --extension xml Use the :djadminopt:`--locale` option to specify the locale to process. Use the :djadminopt:`--locale` option (or its shorter version ``-l``) to specify the locale(s) to process. Example usage:: django-admin.py makemessages --locale=pt_BR django-admin.py makemessages --locale=pt_BR --locale=fr django-admin.py makemessages -l pt_BR django-admin.py makemessages -l pt_BR -l fr You can also use commas to separate multiple locales:: django-admin.py makemessages --locale=de,fr,pt_BR django-admin.py makemessages -l de,fr,pt_BR .. versionchanged:: 1.6 Added the ability to specify multiple locales. .. django-admin-option:: --domain Loading
tests/regressiontests/i18n/commands/compilation.py +31 −0 Original line number Diff line number Diff line Loading @@ -68,3 +68,34 @@ class PercentRenderingTests(MessageCompilationTests): t = Template('{% load i18n %}{% trans "Completed 50%% of all the tasks" %}') rendered = t.render(Context({})) self.assertEqual(rendered, 'IT translation of Completed 50%% of all the tasks') @override_settings(LOCALE_PATHS=(os.path.join(test_dir, 'locale'),)) class MultipleLocaleCompilationTests(MessageCompilationTests): MO_FILE_HR = None MO_FILE_FR = None def setUp(self): super(MultipleLocaleCompilationTests, self).setUp() self.localedir = os.path.join(test_dir, 'locale') self.MO_FILE_HR = os.path.join(self.localedir, 'hr/LC_MESSAGES/django.mo') self.MO_FILE_FR = os.path.join(self.localedir, 'fr/LC_MESSAGES/django.mo') self.addCleanup(self._rmfile, os.path.join(self.localedir, self.MO_FILE_HR)) self.addCleanup(self._rmfile, os.path.join(self.localedir, self.MO_FILE_FR)) def _rmfile(self, filepath): if os.path.exists(filepath): os.remove(filepath) def test_one_locale(self): os.chdir(test_dir) call_command('compilemessages', locale='hr', stderr=StringIO()) self.assertTrue(os.path.exists(self.MO_FILE_HR)) def test_multiple_locales(self): os.chdir(test_dir) call_command('compilemessages', locale=['hr', 'fr'], stderr=StringIO()) self.assertTrue(os.path.exists(self.MO_FILE_HR)) self.assertTrue(os.path.exists(self.MO_FILE_FR))