[Fixed]-Django โ€“ Suffix all urls with language code

1๐Ÿ‘

โœ…

As indicated in the comment by @Bogdan above I resorted to using the built-in prefixing feature in django.

  • I added the LocaleMiddleware in my MIDDLEWARE_CLASSES setting

  • I added a LANGUAGES setting to specify the languages in my site, in my case it was only English and Arabic so my languages looked like


    LANGUAGES = (
    ('ar', _('Arabic')),
    ('en', _('English')),
    )

  • In my views I used request.LANGUAGE_CODE to access the language code and display the appropriate language in my template

๐Ÿ‘คmotatoes

Leave a comment