4.2. Locale i18n
i18n = internationalization
4.2.1. Examples
pl_PL.UTF-8:
hello = 'witaj'
en_US.UTF-8:
hello = 'hello'
en_GB.UTF-8:
hello = 'good morning'
4.2.2. Gettext
.po
files.mo
filesUsing
gettext
in codeGenerating translation files
Compiling translation files
Updating translation files
Transifex (
tx push
andtx pull
)
4.2.3. Django
django-admin makemessages -l en
django-admin compilemessages
{% blocktranslate %}
and{% endblocktranslate %}
{% translate %}
from django.utils.translation import gettext_lazy as _
transifex-client
gettext
poedit
# Internationalization
# https://docs.djangoproject.com/en/dev/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
$ cd myproject
$ mkdir locale
$ django-admin makemessages -l en
processing locale en
$ django-admin makemessages -l pl
processing locale pl
$ django-admin compilemessages
processing file django.po in /tmp/myproject/locale/en/LC_MESSAGES
processing file django.po in /tmp/myproject/locale/pl/LC_MESSAGES