2018-09-03 16:43:55 +08:00
|
|
|
from django.conf import settings
|
|
|
|
from django.utils.translation.trans_real import language_code_re
|
|
|
|
|
|
|
|
from . import Error, Tags, register
|
|
|
|
|
2018-09-06 19:49:25 +08:00
|
|
|
E001 = Error(
|
|
|
|
'You have provided an invalid value for the LANGUAGE_CODE setting.',
|
|
|
|
id='translation.E001',
|
|
|
|
)
|
|
|
|
|
2018-09-03 16:43:55 +08:00
|
|
|
|
|
|
|
@register(Tags.translation)
|
|
|
|
def check_setting_language_code(app_configs, **kwargs):
|
|
|
|
"""
|
2018-09-06 19:49:25 +08:00
|
|
|
Errors if language code setting is invalid.
|
2018-09-03 16:43:55 +08:00
|
|
|
"""
|
2018-09-06 19:49:25 +08:00
|
|
|
if not language_code_re.match(settings.LANGUAGE_CODE):
|
|
|
|
return [E001]
|
|
|
|
return []
|