问题
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