Hi Everyone, I am now trying to implement the internationalisation into my website and I have the i18n_patterns set like this, with the prefix_default_language=False:
urlpatterns += i18n_patterns(
path('', include("landing.urls")),
path('event/', include("event.urls")),
prefix_default_language=False
)
My language setting in settings.py
LANGUAGE_CODE = 'zh-Hant'
LANGUAGES = (
('en', _('English')),
('zh-Hant', _('TraditionalChinese')),
)
And i use this in the view to activate the language:
def translate(request, lang):
print("lang", lang)
if lang=="zh":
newlang="zh-Hant"
else:
newlang="en"
activate(newlang)
return redirect("index")
It works some how, which when I enter mydomain.com/ is working (showing the default language), and mydomain.com/en is showing the another language. However, whenever I click any link inside the page, or using the redirect function through the views.py, it will show the url like mydomain com/zh-Hant/event or mydomain com/en/event for the next page. This means the prefix=False is now only working when I type the url.
As i have set prefix_default_language=False, isn’t my default language zh-Hant should hide the prefix url in all time and the url should be like mydomain com/event? How can i hide this when using inpage redirect or clicking a link inside the page? I have found many articles about it but I still can’t find an answer. Can anyone help me with this?