Multi-Language Locale Settings Bug

Hey there,
i am not sure if this is really a bug, but:
I have 2 languages active on a site (german as default, english as second) and if i turn off the /de url particle via config (‘url’ => ‘/’) the locale won’t be set anymore for the english language. It stays de_DE.
If i turn back to each having their distinctive url particle, everything works fine…

Is this a feature or a bug?

What does your locale config look like in both languages? Which Kirby version?

Hello @texnixe:
Kirby Version: 3.4.0
Locale config is for german: ‘locale’ => ‘de_DE’, & english: ‘locale’ => ‘en_EN’,
pretty standard…

How do you test that the locale is not correct anymore? Have you set language detection? Or what exactly is the issue?

Hello @texnixe,
i have a date field that should show the weekday in its language. It never did, so i started digging.
here you can see two versions of a kirby install:


&

in Version 2 i have added to the german language file this: ‘url’ => ‘/’

I am currently testing by just asking for the date:

<?php $date = strftime('%A, %d.%m.%Y'); echo $date; ?>

Plus this:

<?php $currentLocale = setlocale(LC_ALL, 0); echo $currentLocale; ?>

The currentLocale gives me in version 1 a de_DE for german and a C for english.
In version 2 it always stays de_DE.

The locale should be set like this

  'locale'       => [
    'LC_ALL' => 'de_DE.utf8'
  ],

I have a current project where dates work without issues with this setting and no language string in the URL for the default language.

Mhh, i changed the locale, but i think my problem is more basic. When i change the language, the locale doesn’t change at all. Stays de.


For my current project i just turned to a /de & /en logic, so it works and i think its no harm to have the /de string in there. i was just wondering, why this is happening, but i have no experience and tools to test anything that would explain it.

Did you try to follow Kirby docs: Introduction - Using different domains for each language added by “.utf8” or “.utf-8” (without “'LC_ALL' =>”)?

If you type locale -a into your terminal, what are the installed locales? You should get a list similar to this one and can then compare if what is set in your language definition is available on the server:

C
C.UTF-8
de_AT.utf8
de_BE.utf8
de_CH.utf8
de_DE.utf8
de_IT.utf8
de_LI.utf8
de_LU.utf8
en_AG
en_AG.utf8
en_AU.utf8
en_BW.utf8
en_CA.utf8
en_DK.utf8
en_GB.utf8
en_HK.utf8
en_IE.utf8
en_IL
en_IL.utf8
en_IN
en_IN.utf8
en_NG
en_NG.utf8
en_NZ.utf8
en_PH.utf8
en_SG.utf8
en_US.utf8
en_ZA.utf8
en_ZM
en_ZM.utf8
en_ZW.utf8
POSIX

The LC_ALL setting should be present.

@possible:

If your webserver runs on Windows OS, then follow

Language Strings and Country/Region Strings

on MSDN for the stings,

e.g. for German you should use 'deu_DEU.utf8'

This tip is based on PHP docs: setlocale:
Windows users will find useful information about locale strings at Microsoft’s MSDN website. Supported language strings can be found in the » language strings documentation and supported country/region strings in the » country/region strings documentation.

Hello @texnixe & @anon77445132,

i think i have to give up, because i tested it on my server and on my local machine, and i have different results (server: de_DE.utf8 for both languages / localhost: de = C, en = en_US).
Both results are unsatisfying, but i found my workaround and leave it now. My knowledge of connecting to a webserver via Terminal or even finding out which system runs on the server (hetzner) is beyond my abilities.
Thanks so far and so much.

1 Like

@possible:
Nevertheless I say thank you very much for your support.

Can you please tell us the OS of your servers here, could be important for further evaluation…

Within my site/config/config.php I set now for my German (one language) websites:

  // set 'locale' to '' (or 'deu_DEU.utf8' or 'German_Germany.utf8') for Windows servers and to 'de_DE.utf8' for the rest
  'locale' => [
    LC_ALL => r((strtoupper(substr(PHP_OS, 0, 3)) === 'WIN'), '', 'de_DE.UTF8')
  ],

So there is no difference between my Windows development environment and the (Linux) live webserver for the file site/config/config.php!
Independent of this I use an additional file site/config/config.127.0.0.1.php for the development environment. This webserver XAMPP runs on my Win10 laptop…

For a multilingual website, you can add a corresponding functionality in the /site/languages/*.php files, if you need this. But I think, this is NOT necessary.

HeinerEF