Fixed #29712 -- Made makemessages warn if locales have hyphens and skip them.
This commit is contained in:
parent
8ed024b9b9
commit
f63f3cdf09
1
AUTHORS
1
AUTHORS
|
@ -564,6 +564,7 @@ answer newbie questions, and generally made Django that much better:
|
||||||
Mads Jensen <https://github.com/atombrella>
|
Mads Jensen <https://github.com/atombrella>
|
||||||
Makoto Tsuyuki <mtsuyuki@gmail.com>
|
Makoto Tsuyuki <mtsuyuki@gmail.com>
|
||||||
Malcolm Tredinnick
|
Malcolm Tredinnick
|
||||||
|
Manav Agarwal <dpsman13016@gmail.com>
|
||||||
Manuel Saelices <msaelices@yaco.es>
|
Manuel Saelices <msaelices@yaco.es>
|
||||||
Manuzhai
|
Manuzhai
|
||||||
Marc Aymerich Gubern
|
Marc Aymerich Gubern
|
||||||
|
|
|
@ -383,6 +383,14 @@ class Command(BaseCommand):
|
||||||
|
|
||||||
# Build po files for each selected locale
|
# Build po files for each selected locale
|
||||||
for locale in locales:
|
for locale in locales:
|
||||||
|
if '-' in locale:
|
||||||
|
self.stdout.write(
|
||||||
|
'invalid locale %s, did you mean %s?' % (
|
||||||
|
locale,
|
||||||
|
locale.replace('-', '_'),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
continue
|
||||||
if self.verbosity > 0:
|
if self.verbosity > 0:
|
||||||
self.stdout.write('processing locale %s' % locale)
|
self.stdout.write('processing locale %s' % locale)
|
||||||
for potfile in potfiles:
|
for potfile in potfiles:
|
||||||
|
|
|
@ -600,6 +600,10 @@ Miscellaneous
|
||||||
* The password reset mechanism now invalidates tokens when the user email is
|
* The password reset mechanism now invalidates tokens when the user email is
|
||||||
changed.
|
changed.
|
||||||
|
|
||||||
|
* :djadmin:`makemessages` command no longer processes invalid locales specified
|
||||||
|
using :option:`makemessages --locale` option, when they contain hyphens
|
||||||
|
(``'-'``).
|
||||||
|
|
||||||
.. _deprecated-features-3.2:
|
.. _deprecated-features-3.2:
|
||||||
|
|
||||||
Features deprecated in 3.2
|
Features deprecated in 3.2
|
||||||
|
|
|
@ -152,6 +152,20 @@ class BasicExtractorTests(ExtractorTests):
|
||||||
with self.assertRaisesRegex(CommandError, msg):
|
with self.assertRaisesRegex(CommandError, msg):
|
||||||
management.call_command('makemessages')
|
management.call_command('makemessages')
|
||||||
|
|
||||||
|
def test_valid_locale(self):
|
||||||
|
out = StringIO()
|
||||||
|
management.call_command('makemessages', locale=['de'], stdout=out, verbosity=1)
|
||||||
|
self.assertNotIn('invalid locale de', out.getvalue())
|
||||||
|
self.assertIn('processing locale de', out.getvalue())
|
||||||
|
self.assertIs(Path(self.PO_FILE).exists(), True)
|
||||||
|
|
||||||
|
def test_invalid_locale(self):
|
||||||
|
out = StringIO()
|
||||||
|
management.call_command('makemessages', locale=['pl-PL'], stdout=out, verbosity=1)
|
||||||
|
self.assertIn('invalid locale pl-PL, did you mean pl_PL?', out.getvalue())
|
||||||
|
self.assertNotIn('processing locale pl-PL', out.getvalue())
|
||||||
|
self.assertIs(Path('locale/pl-PL/LC_MESSAGES/django.po').exists(), False)
|
||||||
|
|
||||||
def test_comments_extractor(self):
|
def test_comments_extractor(self):
|
||||||
management.call_command('makemessages', locale=[LOCALE], verbosity=0)
|
management.call_command('makemessages', locale=[LOCALE], verbosity=0)
|
||||||
self.assertTrue(os.path.exists(self.PO_FILE))
|
self.assertTrue(os.path.exists(self.PO_FILE))
|
||||||
|
|
Loading…
Reference in New Issue