1👍
You don’t need any third party package to accomplish what you want to do, Django has it built-in.
- You add
django.middleware.locale.LocaleMiddleware
to your middlewares, - configure locales in settings.py,
- wrap your urls in
urls.py
withdjango.conf.urls.i18n.i18n_patterns
, - translate your strings
and you are done.
You get urls like site.com/en/lorem-ipsum
for the urls you wrapped with django.conf.urls.i18n.i18n_patterns
.
To be more specific about your questions:
1) This is the default behaviour. If you wrap admin url with django.conf.urls.i18n.i18n_patterns
, you’ll get admin site in multiple languages, too. With the same url style, like site.com/en/admin/
. Here is an example urls.py
:
from django.conf.urls import url, include, i18n
from django.contrib import admin
urlpatterns += i18n.i18n_patterns(
url(r'^admin/', admin.site.urls),
url(r'^products/', include('your_project.apps.products.urls', namespace='products')),
# ...
)
2) The all urls will be consistent locale-wise. E.g. if the user is on site.com/en/home
and there is a link to the about products page the link will be `site.com/en/about’
3) I can understand, it would be a lot easier to update translations on admin site without editing gettext files and such. However, I like the way django handles translation. Making translation something about admin site would involve database and I don’t think it is a good idea to use database for translation.