Language()->locale() string becomes an array in 3.1.3

How can I get the current language with the new returning array?

$kirby->language()->locale() doesn’t work anymore (returns Array instead of the current locale).

Edit: I think I have to do something like this: $kirby->language(language()->code())->locale() but it’s weird.

You can get it like this:


thank you, this works too: $kirby->language()->locale()[0]

Can I ask why it’s an array now?

Because that was a missing feature we had in Kirby 2, where you could set the different locale settings in an array:

OK I see. Can I add my own LC_html in this array for having fr-FR instead of fr_FR in html lang? Or should I just keep my strreplace ?

The locales are passed to PHP’s setlocale() function, therefore you shouldn’t add any custom ones there.

You can however put it into a translation string.

Ha yes good idea, but I will rely on the php locale so it’s just in one place. Thank you.