amazon web services - Django translation does not work in deployment -
the translation works on own computer, when website deployed aws elastic beanstalk, not work anymore...
i have followed django v1.9 documentation. mark translation string {% trans %}, generate message file , compile it, add locale path , middleware in 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 tried different path, 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 django issue or configuration problem of aws? tested website on windows computer, server on aws running linux, matter? please advise...
Comments
Post a Comment