Requirements

Release notes

Behaviour

There are two modes:

settings.SOLID_I18N_USE_REDIRECTS = False (default). In that case
i18n will not use redirects at all. If request doesn’t have language
prefix, then default language will be used. If request does have
prefix, language from that prefix will be used.

settings.SOLID_I18N_USE_REDIRECTS = True. In that case, for root
paths (without prefix), django will try to
discover
user preferred language. If it doesn’t equal to default language,
redirect to path with corresponding prefix will occur. If preferred
language is the same as default, then that request path will be
processed (without redirect). Also see notes below.

Example site

Located
here,
it is ready to use, just install solid_i18n (this package):

pip install solid_i18n

clone example site:

git clone https://github.com/st4lk/django-solid-i18n-urls.git

step in example/ and run development server:

cd django-solid-i18n-urls/example
python manage.py runserver

Notes

When using SOLID_I18N_USE_REDIRECTS = True, there is some nasty
case. Suppose django has determined user preferred language
incorrectly (maybe in user’s browser preferred language is not equal
to his realy preferred language, because for example it is not his
computer) and it is Russian. Then on access to url without prefix,
i.e. '/', he will be redirected to '/ru/' (according to
browsers preferred language). He wants to look english content (that
is default language), but he can’t, because he is always being
redirected to '/ru/' from '/'. To avoid this, it is needed to
set preferred language in his cookies (just
<a href="{{ specific language url}}"> will not work). For that
purporse django’s set_language redirect
view
shall be used. See example in this package.