1
0
mirror of https://github.com/django/django.git synced 2025-10-25 22:56:12 +00:00

Fixed #21488 -- Multiple locales treatment in i18n commands.

Removed multiple locales separated by commas variation (that wasn't
working as documented) in favor of simply allowing use of the
``--locale``/``-l`` options more than once for ``makemessages`` and
``compilemessages``.

Thanks Romain Beylerian for the report and Claude, Simon for their help.

8750296918 from stable/1.6.x.
This commit is contained in:
Ramiro Morales
2013-11-22 23:47:04 -03:00
parent ffc37e2343
commit 62b393c5ae
6 changed files with 37 additions and 45 deletions

View File

@@ -35,7 +35,7 @@ def compile_messages(stdout, locale=None):
for basedir in basedirs:
if locale:
dirs = [os.path.join(basedir, l, 'LC_MESSAGES') for l in (locale if isinstance(locale, list) else [locale])]
dirs = [os.path.join(basedir, l, 'LC_MESSAGES') for l in locale]
else:
dirs = [basedir]
for ldir in dirs:
@@ -61,7 +61,7 @@ def compile_messages(stdout, locale=None):
class Command(BaseCommand):
option_list = BaseCommand.option_list + (
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='locale(s) to process (e.g. de_AT). Default is to process all. Can be used multiple times.'),
)
help = 'Compiles .po files to .mo files for use with builtin gettext support.'

View File

@@ -169,7 +169,7 @@ class Command(NoArgsCommand):
option_list = NoArgsCommand.option_list + (
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.'),
'Can be used multiple times.'),
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',
@@ -265,7 +265,7 @@ class Command(NoArgsCommand):
# Build po files for each selected locale
locales = []
if locale is not None:
locales += locale.split(',') if not isinstance(locale, list) else locale
locales = locale
elif process_all:
locale_dirs = filter(os.path.isdir, glob.glob('%s/*' % localedir))
locales = [os.path.basename(l) for l in locale_dirs]