wagtail-localize icon indicating copy to clipboard operation
wagtail-localize copied to clipboard

Django's settings LANGUAGE_CODE not taken into account

Open pikpoket opened this issue 3 years ago • 3 comments

Hi everyone,

I've followed the tutorial from https://www.wagtail-localize.org/tutorial/2-configure-wagtail-localize/, Except my LANGUAGE_CODE is fr-FR and not en-gb. The redirection by the middleware is working as expected.

When I log into the admin, my home page is set as English :(. I'd want my default language to be French, so that others languages could sync with my french pages.

image image

I've tried to reinstall the app and recreate my home page, but the issue persist.

pikpoket avatar Aug 01 '22 08:08 pikpoket

the LANGUAGE_CODE needs to be one of the language codes defined in LANGUAGES/WAGTAIL_CONTENT_LANGUAGES.

Have you tried setting it to fr? Note that you will want start from scratch, or create a new home page since the one that's there already has the locale set to English as per https://docs.wagtail.org/en/stable/advanced_topics/i18n.html#changing-the-primary-language-of-your-wagtail-installation

zerolab avatar Aug 01 '22 10:08 zerolab

Thanks for your input, yes I've also tried with "fr" alone and creating a new homepage.

Edit: Starting from scratch (new environment) it works.

pikpoket avatar Aug 01 '22 12:08 pikpoket

the LANGUAGE_CODE needs to be one of the language codes defined in LANGUAGES/WAGTAIL_CONTENT_LANGUAGES.

I use 'en' in my content languages but language code set to en-GB because otherwise Django assumes en to mean en-US and formats all the short dates to US date format mm/dd/yy.

LANGUAGE_CODE = 'en-gb'
WAGTAIL_CONTENT_LANGUAGES = LANGUAGES = [
    ('en', "English"),
    ('es', "Español"),
    ('fr', "Français"),
]

enzedonline avatar Nov 22 '22 12:11 enzedonline