Hey, first time poster here.
I’m using the set_language
helper function and ran into a small issue. I found that the language would switch from the default language to some other language, but I couldn’t switch back to the default language.
There are two ways to fix the problem. The first way was to set prefix_default_language=True
in i18n_patterns. The second way was to slightly modify set_language
as so:
def set_language(request):
# next_url setup at the beginning
# Strip out the language code from the url before translating the url.
for lang_code, lang_name in settings.LANGUAGES:
prefix = '/' + lang_code + '/'
if next_url.startswith(prefix):
next_url = next_url[len(prefix) - 1:]
break
...
This makes set_language work even if the prefix_default_language
in i18n_patterns is set to False.
Is there a good reason to keep prefix_default_language
set to True, besides SEO?