summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorNick Pope <nick.pope@flightdataservices.com>2018-09-06 12:49:25 +0100
committerCarlton Gibson <carlton.gibson@noumenal.es>2018-09-06 13:49:25 +0200
commit570402ffd7efd529eb597d86525b80a6fbfca0e7 (patch)
tree6c0c75d664f7715290682c5d82923f07aac4805c /django
parentccf870ebf5a9f9b44711a08549833f97ef3f7a41 (diff)
Refs #29713 -- Improved error message from translation system check.
Diffstat (limited to 'django')
-rw-r--r--django/core/checks/translation.py24
1 files changed, 9 insertions, 15 deletions
diff --git a/django/core/checks/translation.py b/django/core/checks/translation.py
index 5c183aad2d..cf69a5c084 100644
--- a/django/core/checks/translation.py
+++ b/django/core/checks/translation.py
@@ -1,25 +1,19 @@
-import re
-
from django.conf import settings
from django.utils.translation.trans_real import language_code_re
from . import Error, Tags, register
+E001 = Error(
+ 'You have provided an invalid value for the LANGUAGE_CODE setting.',
+ id='translation.E001',
+)
+
@register(Tags.translation)
def check_setting_language_code(app_configs, **kwargs):
"""
- Errors if language code is in the wrong format. Language codes specification outlined by
- https://en.wikipedia.org/wiki/IETF_language_tag#Syntax_of_language_tags
+ Errors if language code setting is invalid.
"""
- match_result = re.match(language_code_re, settings.LANGUAGE_CODE)
- errors = []
- if not match_result:
- errors.append(Error(
- "LANGUAGE_CODE in settings.py is {}. It should be in the form ll or ll-cc where ll is the language and cc "
- "is the country. Examples include: it, de-at, es, pt-br. The full set of language codes specifications is "
- "outlined by https://en.wikipedia.org/wiki/IETF_language_tag#Syntax_of_language_tags".format(
- settings.LANGUAGE_CODE),
- id="translation.E001",
- ))
- return errors
+ if not language_code_re.match(settings.LANGUAGE_CODE):
+ return [E001]
+ return []