[Fixed]-How to maintain different country versions of same language in Django?


A workaround to the issue would be to add following snippet to your settings.py file.

import locale
locale.locale_alias.pop('en', None)

Special credit to Venelin Stoykov who was able to investigate the behavior of the Python locale module.


This is a quirk of Python (not specifically Django) and the gettext module.

Ticket 8626 was raised on the Django issue tracker around the time of the 1.0 release and after some suggestions and debate, the Django devs deemed it a “won’t fix”.

There are suggestions in the ticket thread to use ‘en-en’ as the default. My memory is a little rough but if I recall correctly this approach didn’t play well with other parts of my i18n tooling (e.g. the pox library). I gave up and settled for using en-US as the default for the project and listing the other variants (e.g. en-au) as alternatives.


may I suggest you to put a breakpoint into the LocaleMiddleware Class?

In this way, you might found out a clue which thing was actually getting your way from getting the right Language.

Becaue according the source code of LocaleMiddleware Class and the How Django discovers language preference
, there could be so many things can affect the result.

Leave a comment