我想处理我的网站的法语版本。
我将 Django 2.2 与 i18n 一起使用,并且我已经在 settings.py 中设置了语言环境变量。
# Internationalization
# https://docs.djangoproject.com/en/2.2/topics/i18n/
LANGUAGES = (
('en', _('English')),
('fr', _('French')),
('it', _('Italian')),
('es', _('Spanish')),
)
LOCALE_PATHS = (
os.path.join(BASE_DIR, 'locale'),
)
TIME_ZONE = 'Europe/Paris'
USE_I18N = True
USE_L10N = True
USE_TZ = True
Run Code Online (Sandbox Code Playgroud)
当我使用时./manage.py makemessages -l fr,我正确地有一个 django.po 法语文件,但在./manage.py compilemessages -l fr服务器崩溃后出现以下错误(已修剪):
File "/usr/lib/python3.7/gettext.py", line 93, in _tokenize
raise ValueError('invalid token in plural form: %s' % value)
ValueError: invalid token in plural form: EXPRESSION
Run Code Online (Sandbox Code Playgroud)
英语、意大利语和西班牙语翻译效果很好
编辑: …