dimanche 5 décembre 2021

Change django language code from URL pattern

I have this languages code setup on my Django application.

LANGUAGES = [
   ('en', _('English (US)')),
   ('de', _('Deutsch')),
   ('fr',_('Français')),
   ('ja',_('日本語')),# -> JP
   ('ko',_('한국어')),# -> KR
]

And on the url patterns i have the following setup:

urlpatterns = i18n_patterns(
    path('', include('main.urls')),
    prefix_default_language=False
)

So my application has the languages folder prefixed on the URLs.

But i need the languages ja and ko to work from other prefixes, jp and kr, respectively.

I tried using a middleware to override the request.path_info and the site responds on the required urls but it builds the internal links on the bad urls.

Aucun commentaire:

Enregistrer un commentaire