From 9c6ba876928fd20194ac3238dc06aeae66d7bd50 Mon Sep 17 00:00:00 2001 From: Josh Santos Date: Tue, 27 Oct 2020 19:52:48 +0700 Subject: [PATCH] Fixed #32145 -- Improved makemessages error message when app's locale directory doesn't exist. --- django/core/management/commands/makemessages.py | 5 +++-- tests/i18n/test_extraction.py | 8 ++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/django/core/management/commands/makemessages.py b/django/core/management/commands/makemessages.py index 04bb6c958b..c411c25e28 100644 --- a/django/core/management/commands/makemessages.py +++ b/django/core/management/commands/makemessages.py @@ -583,8 +583,9 @@ class Command(BaseCommand): 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) diff --git a/tests/i18n/test_extraction.py b/tests/i18n/test_extraction.py index 73336816cb..ee8257175b 100644 --- a/tests/i18n/test_extraction.py +++ b/tests/i18n/test_extraction.py @@ -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'))