mirror of
https://github.com/django/django.git
synced 2024-12-22 17:16:24 +00:00
Fixed #27868 -- Filtered locale path subdirectories
Thanks Tim Graham for the review.
This commit is contained in:
parent
e6065c7b83
commit
30c984b3f9
@ -337,8 +337,12 @@ class Command(BaseCommand):
|
||||
os.makedirs(self.default_locale_path)
|
||||
|
||||
# Build locale list
|
||||
looks_like_locale = re.compile(r'[a-z]{2}')
|
||||
locale_dirs = filter(os.path.isdir, glob.glob('%s/*' % self.default_locale_path))
|
||||
all_locales = map(os.path.basename, locale_dirs)
|
||||
all_locales = [
|
||||
lang_code for lang_code in map(os.path.basename, locale_dirs)
|
||||
if looks_like_locale.match(lang_code)
|
||||
]
|
||||
|
||||
# Account for excluded locales
|
||||
if process_all:
|
||||
|
@ -604,6 +604,7 @@ class KeepPotFileExtractorTests(ExtractorTests):
|
||||
class MultipleLocaleExtractionTests(ExtractorTests):
|
||||
PO_FILE_PT = 'locale/pt/LC_MESSAGES/django.po'
|
||||
PO_FILE_DE = 'locale/de/LC_MESSAGES/django.po'
|
||||
PO_FILE_KO = 'locale/ko/LC_MESSAGES/django.po'
|
||||
LOCALES = ['pt', 'de', 'ch']
|
||||
|
||||
def test_multiple_locales(self):
|
||||
@ -611,6 +612,18 @@ class MultipleLocaleExtractionTests(ExtractorTests):
|
||||
self.assertTrue(os.path.exists(self.PO_FILE_PT))
|
||||
self.assertTrue(os.path.exists(self.PO_FILE_DE))
|
||||
|
||||
def test_all_locales(self):
|
||||
"""
|
||||
When the `locale` flag is absent, all dirs from the parent locale dir
|
||||
are considered as language directories, except if the directory doesn't
|
||||
start with two letters (which excludes __pycache__, .gitignore, etc.).
|
||||
"""
|
||||
os.mkdir(os.path.join('locale', '_do_not_pick'))
|
||||
# Excluding locales that do not compile
|
||||
management.call_command('makemessages', exclude=['ja', 'es_AR'], verbosity=0)
|
||||
self.assertTrue(os.path.exists(self.PO_FILE_KO))
|
||||
self.assertFalse(os.path.exists('locale/_do_not_pick/LC_MESSAGES/django.po'))
|
||||
|
||||
|
||||
class ExcludedLocaleExtractionTests(ExtractorTests):
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user