Skip to content

Commit

Permalink
Fixed #32145 -- Improved makemessages error message when app's locale…
Browse files Browse the repository at this point in the history
… directory doesn't exist.
  • Loading branch information
thatnerdjosh authored and felixxm committed Feb 9, 2021
1 parent d4ac23b commit 9c6ba87
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
5 changes: 3 additions & 2 deletions django/core/management/commands/makemessages.py
Original file line number Diff line number Diff line change
Expand Up @@ -583,8 +583,9 @@ def process_locale_dir(self, locale_dir, files):
if locale_dir is NO_LOCALE_DIR:
file_path = os.path.normpath(build_files[0].path)
raise CommandError(
'Unable to find a locale path to store translations for '
'file %s' % file_path
"Unable to find a locale path to store translations for "
"file %s. Make sure the 'locale' directory exist in an "
"app or LOCALE_PATHS setting is set." % file_path
)
for build_file in build_files:
msgs = build_file.postprocess_messages(msgs)
Expand Down
8 changes: 6 additions & 2 deletions tests/i18n/test_extraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -758,9 +758,13 @@ class CustomLayoutExtractionTests(ExtractorTests):
work_subdir = 'project_dir'

def test_no_locale_raises(self):
msg = "Unable to find a locale path to store translations for file"
msg = (
"Unable to find a locale path to store translations for file "
"__init__.py. Make sure the 'locale' directory exist in an app or "
"LOCALE_PATHS setting is set."
)
with self.assertRaisesMessage(management.CommandError, msg):
management.call_command('makemessages', locale=LOCALE, verbosity=0)
management.call_command('makemessages', locale=[LOCALE], verbosity=0)

def test_project_locale_paths(self):
self._test_project_locale_paths(os.path.join(self.test_dir, 'project_locale'))
Expand Down

0 comments on commit 9c6ba87

Please sign in to comment.