judbd
1
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:
dump($kirby->language()->locale(LC_ALL));
judbd
3
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: http://k2.getkirby.com/docs/languages/setup
judbd
5
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.
judbd
7
Ha yes good idea, but I will rely on the php locale so it’s just in one place. Thank you.