Strftime localization issue

Hi,

I’ve got a curious problem with strftime and languages - on my locale machine with XAMPP the date / time for the articles work fine, but not at the webspace. So if I read any article on the locale webserver I have the correct Date:
DE: Donnerstag, 08.08.2019
EN: Thursday, 8/8/2019

but on the Webserver I have
DE: Thursday, 8/8/2019
EN: Thursday, 8/8/2019

My config.php:

<?php
return [
	'locale' => 'de_DE.utf-8',
	'date.handler' => 'strftime',
	'languages' => true,
	'languages.detect' => true,
];

My article.php:

<time datetime="<?= $page->date()->toDate('c') ?>" pubdate="pubdate">
  <?= $page->date()->toDate('%A, %Ex') ?>
</time>

At this point i am not sure if there is a problem in the sourcecode, or if the webserver on which the website is hosted can’t deal with this.

Thanks
Felix

The correct locale setting might be different on the remote host. Often, the differences are not big but enough to not make it work.

Do you have ssh access to your host? Then you can use terminal and type

locale -a

to get a list of the installed locales.

locale: Command not found.

Hm, that’s a pretty standard linux command…

You could try some alternatives to your dev locale:

de_DE
de_DE.UTF-8
de_DE.utf8

no changes :frowning:

Where is the site hosted?

strato

Hm :thinking:, you could try a few other variations

de_DE.UTF8
de_DE@euro
deutsch
german

or contact their support.

What you get when add following codes? Maybe it’il help about information after setting locale.

Add to site/controllers/home.php or any file in kirby

$currentLocale = setlocale(LC_ALL, 0);
echo $currentLocale;

What you could also try in any template:

dump(ResourceBundle::getLocales(''));

Should do the same as locale - on the command line and print out a list of available locales.

localhost: de_DE
Webserver: /de_DE/C/C/C/C/C

Works for me and my locale output like that:

LC_CTYPE=en_US.utf-8;LC_NUMERIC=tr_TR.utf-8;LC_TIME=tr_TR.utf-8;LC_COLLATE=tr_TR.utf-8;LC_MONETARY=tr_TR.utf-8;LC_MESSAGES=tr_TR.utf-8;LC_PAPER=tr_TR.utf-8;LC_NAME=tr_TR.utf-8;LC_ADDRESS=tr_TR.utf-8;LC_TELEPHONE=tr_TR.utf-8;LC_MEASUREMENT=tr_TR.utf-8;LC_IDENTIFICATION=tr_TR.utf-8

Have you tried my last suggestion, @felixhuth?

Upload following codes to your server root like: setlocale.php and run.
If it doesn’t work, contact your hosting provider.

<?php
setlocale(LC_TIME, "de_DE.utf8");
echo strftime("In German %A.\n");
?>

I’ve tried it - it worked :confused:

I will try it at my test environment - it is hostet at 1und1 IONOS, so i will tell you about the results in a few days :slight_smile:

The website is now online at a dev environment at 1und1 IONOS - same problem…

@texnixe in which template (i.e. file) and where i have to insert this code?

You can insert that code anywhere, e.g. in the home.php template.

Class ‘ResourceBundle’ not found …

Hm, ok, that class doesn’t seem to be included in your PHP then, what a shame.

Stop, I just realised you are using languages, right? So the locale should be defined in the language files…

What do you have there?