Skip to content

Commit c1986a6

Browse files
committed
Add more thorough check to language configuration in 'check' command
1 parent 1138ee5 commit c1986a6

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

cms/utils/check.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from django.conf import settings
1111
from django.utils.decorators import method_decorator
1212
from django.utils.termcolors import colorize
13+
from django.utils.translation.trans_real import accept_language_re
1314
from sekizai.helpers import validate_template
1415

1516
SUCCESS = 1
@@ -187,6 +188,16 @@ def check_i18n(output):
187188
section.success("New style CMS_LANGUAGES")
188189
else:
189190
section.warn("Old style (tuple based) CMS_LANGUAGES, please switch to the new (dictionary based) style")
191+
if getattr(settings, 'LANGUAGE_CODE', '').find('_') > -1:
192+
section.warn("LANGUAGE_CODE must contain a valid language code, not a locale ('%s' provided)" % getattr(settings, 'LANGUAGE_CODE', ''))
193+
for lang in getattr(settings, 'LANGUAGES', ()):
194+
if lang[0].find('_') > -1:
195+
section.warn("LANGUAGES must contain valid language codes, not locales ('%s' provided)" % lang[0])
196+
for site, items in get_cms_setting('LANGUAGES').items():
197+
if type(site) == int:
198+
for lang in items:
199+
if lang['code'].find('_') > -1:
200+
section.warn("CMS_LANGUAGES entries must contain valid language codes, not locales ('%s' provided)" % lang['code'])
190201
for deprecated in ['CMS_HIDE_UNTRANSLATED', 'CMS_LANGUAGE_FALLBACK', 'CMS_LANGUAGE_CONF', 'CMS_SITE_LANGUAGES', 'CMS_FRONTEND_LANGUAGES']:
191202
if hasattr(settings, deprecated):
192203
section.warn("Deprecated setting %s found. This setting is now handled in the new style CMS_LANGUAGES and can be removed" % deprecated)

0 commit comments

Comments
 (0)