Dates are always returned in English translation (locale config. not working)?

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:

  1. The site is running on Kirby 3.7.0 and PHP 8.0.8

  2. I’m not using the strftime handler (as suggested in the post mentioned above) because it is deprecated as of PHP 8.1.

  3. 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');
  1. In my config.php, the locale is set to German…
'languages' => true,
'locale'    => 'de_DE.UTF-8',
  1. 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 
  1. The de_DE locale is installed on the machine on which I’m testing the site…

  1. 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)?

You have to set the date handler to intl and update to I think 3.8.x, because 3.7 has a bug in the handler.

1 Like

Yeah, interesting. When setting the handler to intl as you suggest, something is happening, but it doesn’t look right… :smiley:

I guess this related to the bug you’ve mentioned.

Never mind, I simply had to adjust the formatting…

$date          = $DATA->date();
$date__weekday = substr($date->toDate('E'), 0, 2);
$date__day     = $date->toDate('dd.');
$date__month   = $date->toDate('MM.');
$time          = $DATA->time()->toDate('k:mm');