Django discovers language preference by domain

10 views Asked by At

I want to use the sites framework in Django: https://docs.djangoproject.com/en/4.2/ref/contrib/sites/

I have currently a multilinguale website with several domains for each language:

www.example.com (only English)
www.example.de (only German)
www.example.it (only Italien)

Currently I run for each website a new gunicorn process with a different settings.py to set the SITE_ID and the LANGUAGE.

Because we started to translate to several languages, this approach is creating a lot of duplication code and eats a lot of ram we decided to find a more efficient way. (more than 20 languages at the moment)

As I can see, I could automatically setup the SITE_ID with the sites framework but how can I tell Django to change the language according to the domain? (For example example.it/foo/bar content should be always Italien)

Or is my current approach already the only and correct way?

0

There are 0 answers