tobi
November 26, 2019, 10:12am
1
I have set the following points in the configuration of my page to display the date format in German. This works fine on the start page, but on the articles the language is still English. Cache options are disabled.
'debug' => true,
'home' => 'blog',
'locale' => 'de_DE.utf-8',
'date.handler' => 'strftime'
Code in my meta.php file:
<time>
<?= $page->published()->toDate('%A, %d. %B %Y') ?>
</time>
Output home page: Montag, 25. November 2019
Output article page: Monday, 25. November 2019
I already tried options like this:
<?php
setlocale(LC_ALL, 'de_DE');
?>
texnixe
November 26, 2019, 10:24am
2
Are you really calling this same snippet everywhere?
tobi
November 26, 2019, 10:25am
3
Yes. Its in a snippet called meta.php.
<?= snippet('article/meta', ['page' => $page]) ?>
texnixe
November 26, 2019, 10:28am
4
Are you using the latest Kirby version?
tobi
November 26, 2019, 10:35am
5
I’m currently using 3.3.0, could updating to 3.3.1 fix the issue?
texnixe
November 26, 2019, 10:39am
6
As far as I remember, there was an issue with the locale but that should have been fixed in 3.3.0 and I can’t reproduce your issue in a fresh Starterkit.
tobi
November 26, 2019, 10:41am
7
Updated to 3.3.1, same issue.
I also tried to echo <time><?= $page->published()->toDate('%A, %d. %B %Y') ?></time> in every single article template. The issue still remains.
Maybe my routes are part of the problem here?
return [
'debug' => true,
'home' => 'blog',
'locale' => 'de_DE.utf-8',
'date.handler' => 'strftime',
'panel.install' => true,
'routes' => [
[
'pattern' => '(:any).html',
'action' => function() {
return site()->visit('error');
}
],
[
'pattern' => '(:any)',
'action' => function($uid) {
$page = page($uid);
if (($page) && $page->id() === 'blog') {
$this->next();
}
if(!$page) $page = page('blog/' . $uid);
if(!$page) $page = site()->errorPage();
return site()->visit($page);
}
],
[
'pattern' => 'blog/(:any)',
'action' => function($uid) {
go($uid);
}
]
],
'cache' => [
'pages' => [
'active' => false
]
]
];
texnixe
November 26, 2019, 10:44am
8
And the locale is actually correct? And you have removed your other manual locale settings?
tobi
November 26, 2019, 10:56am
9
Yes. This is the only locale that is working.
There are no other manual locale settings. I removed the ‘setlocale’ code above.
My output from
$currentLocale = setlocale(LC_ALL, 0);
echo $currentLocale;
On the home page:
LC_CTYPE=de_DE.utf-8;
LC_NUMERIC=de_DE.utf-8;
LC_TIME=de_DE.utf-8;
LC_COLLATE=de_DE.utf-8;
LC_MONETARY=de_DE.utf-8;
LC_MESSAGES=de_DE.utf-8;
LC_PAPER=C;
LC_NAME=C;
LC_ADDRESS=C;
LC_TELEPHONE=C;
LC_MEASUREMENT=C;
LC_IDENTIFICATION=C
On the article page:
C
tobi
November 26, 2019, 11:00am
10
Now it works on all pages with this:
<?php
setlocale(LC_ALL, 'de_DE.utf-8');
?>
Strange.