The translation works on my own computer, but when the website is deployed to AWS Elastic Beanstalk, it does not work anymore...
I have followed the Django v1.9 documentation. Mark the translation string by {% trans %}, generate the message file and compile it, add the locale path and middleware in the settings.py file.
MIDDLEWARE CLASSES:
MIDDLEWARE_CLASSES = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
LOCALE PATH: (I just tried different path, the directories contain identical message files.)
LOCALE_PATHS = [
os.path.join(BASE_DIR, "locale/"),
os.path.join(BASE_DIR, "translations/locale/"),
]
File structure:
myproject/
manage.py
myproject/
settings.py
locale/
zh_HANT/
LC_MESSAGES/
django.po
django.mo
translation/
locale/
zh_HANT/
LC_MESSAGES/
django.po
django.mo
account_management/
LANGUAGE SETTING:
LANGUAGE_CODE = 'en-us'
LANGUAGES = [
('zh-hant', _('Traditional Chinese')),
('en', _('English')),
]
USE_I18N = True
USE_L10N = True
USE_TZ = True
urls.py
urlpatterns += i18n_patterns(
url(r'^', include('account_management.urls')),
)
Error shown in AWS log:
`[Thu Apr 21 21:02:30.179229 2016] [:error] [pid 16295] ('locale_path', '/opt/python/current/app/locale/')
[Thu Apr 21 21:02:30.179235 2016] [:error] [pid 16295] ('locale_path', '/opt/python/current/app/translations/locale/')`
Is this a django issue or the configuration problem of the AWS? I tested the website on my Windows computer, but the server on AWS is running Linux, does this matter? Please advise...