Internationalization doesn't work or I don't know how to make it work

北城以北 提交于 2019-12-20 04:29:16

问题


Settings.py constants

TIME_ZONE = 'Europe/Vilnius'
LANGUAGE_CODE = 'lt'
USE_I18N = True
USE_L10N = True
USE_TZ = True

MIDDLEWARE_CLASSES = (
    'django.middleware.common.CommonMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
)

If I add LocaleMiddleware to the middleware classes and edit source code so that it would print my locale, it prints lt as expected.

Moreover:

./manage.py makemessages -l lt generated the file and I translated text occurences.

./manage.py compilemessages returns processing file django.po in /Users/aemdy/PycharmProjects/rezervavau_v2/locale/lt/LC_MESSAGES

But sadly I still see english text in my pages.

I use django admin and the phrases included in the basic django admin are translated (Change password, password, edit and some others). Still, my own defined phrases are shown in english.


回答1:


Well, I have found the answer myself.

I needed to add the following line in settings.py:

LOCALE_PATHS = (os.path.join(os.path.dirname(__file__), '../locale/'),)



来源:https://stackoverflow.com/questions/14031753/internationalization-doesnt-work-or-i-dont-know-how-to-make-it-work

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!