I’m having trouble rendering dates (from a date field) in a language other than English. I’d like to output dates in German. I’ve gone through this post discussing a similar issue…
…but was not able to solve the problem.
To summarize my current setup:
-
The site is running on Kirby 3.7.0 and PHP 8.0.8
-
I’m not using the
strftime
handler (as suggested in the post mentioned above) because it is deprecated as of PHP 8.1. -
I’m formatting dates in a controller like so…
$date = $DATA->date();
$date__weekday = substr($date->toDate('l'), 0, 2);
$date__day = $date->toDate('d.');
$date__month = $date->toDate('m.');
$time = $DATA->time()->toDate('H:i\h');
- In my
config.php
, thelocale
is set to German…
'languages' => true,
'locale' => 'de_DE.UTF-8',
- My German language (
/languages/de.php
) is configured like so…
return [
'code' => 'de',
'default' => true,
'direction' => 'ltr',
'locale' => ['LC_ALL' => 'de_DE'],
'name' => 'Deutsch',
//////
'translations' => [],
//////
'url' => NULL
];
- The de_DE locale is installed on the machine on which I’m testing the site…
- When echoing this data, it is always rendered in English i.o. German (in my local build running on MAMP as well as in a live build on the server), like so…
How do I ensure that the dates are rendered in German (or any desired language)?