Query language toDate and strftime

I’m using 'date.handler' => 'strftime', and noticed that using query language on the panel to format date won’t translate to the current language in the panel. Is it possible?

On the panel i’m using info: "{{ page.date.toDate('%d %b %Y') }}"

Looks like this depends on the user language you choose in the Panel.

My user language is es_419 but date still shows up on english
image

I just noticed it’s not translated on the template neither :thinking: maybe something on my config for the language?

<?php

return [
  'code' => 'es_419',
  'default' => true,
  'direction' => 'ltr',
  'name' => 'Español',
  'url' => '/es',
  'locale'  => [
    LC_ALL      => 'es_MX.utf8',
    LC_COLLATE  => 'es_MX.utf8',
    LC_MONETARY => 'es_MX.utf8',
    LC_NUMERIC  => 'es_MX.utf8',
    LC_TIME     => 'es_MX.utf8',
    LC_MESSAGES => 'es_MX.utf8',
    LC_CTYPE    => 'es_MX.utf8'
  ],

Have you checked the locale is installed on your server.

I used <?php dump(ResourceBundle::getLocales('')); ?> and es_MX is there
image

What if you set locales to es_MX then, without the utf8 bit?

No. Same result. I’m using laravel valet, maybe it’s related?

I’m using laravel valet myself und tested Spanish now:

With config setting (because that’s the variant that is installed on my server)

 'locale' => [
    LC_TIME     => 'es_ES.UTF-8'
  ],

And user language of current user in Panel set to Spanish (America Latina or Spain), strftime works for me. Haven’t tested es_MX because it’s not installed.

Looks pretty Spanish to me (ok, I know it doesn’t help if it works on my machine).

Doesn’t work for me. I even made a new install from plainkit to isolate the problem and nothing changes. I tried uploading it to a shared hosting and it’s even works becase every page sends me to the error page of kirby (not the degug info).
Ijust wanted to translate the month and now It’s all worse :sob:

:hugs:

If every page sends you to the error page, then that is probably some other issue on the remote server. Have you checked that the shared hosting meets Kirby’s requirements?

I also tested this on a remote server (Uberspace) and there it works as well.

I only tested a single language install though, let me test if multi-language makes a difference.

Now I also did a test with multi-languages (EN, ES). In fact, it doesn’t even matter what I set in my language files, the language changes to whatever language I set as my user language (Polish, Russian etc.)

ok, I’m trying again. I’m using kirby plainkit with multilanguage

config.php

<?php

return [
  'languages' => true,
  'date.handler'  => 'strftime',

];

languages/es-419.php

<?php

return [
    'code' => 'es-419',
    'default' => true,
    'direction' => 'ltr',
    'locale' => [
        'es_419'
    ],
    'name' => 'Español',
    'translations' => [

    ],
    'url' => 'es'
];

languages/en.php

<?php

return [
    'code' => 'en',
    'default' => false,
    'direction' => 'ltr',
    'locale' => [
        'en'
    ],
    'name' => 'English',
    'translations' => [

    ],
    'url' => NULL
];

default.yml blueprint, just added date

title: Default Page
preset: page
fields:
  date:
    type: date
  text:
    label: Text
    type: textarea
    size: large

same for default.php template and a Language switcher from the guide

<nav class="languages">
  <ul>
    <?php foreach($kirby->languages() as $language): ?>
    <li<?php e($kirby->language() == $language, ' class="active"') ?>>
      <a href="<?= $page->url($language->code()) ?>" hreflang="<?php echo $language->code() ?>">
        <?= html($language->name()) ?>
      </a>
    </li>
    <?php endforeach ?>
  </ul>
</nav>
<h1><?= $page->title() ?></h1>
<?= $page->date()->toDate('%a %B %Y') ?>

Title changes correctly but not the date. The date is shown on english in both.
language

Thank you for your patience :bowing_woman:t4:

Whoa! it works with this now. Gonna check it out more.

Feel free to send me a download link for your testkit!

I created this repo: https://github.com/Turqueso/kirby-multilanguage-translate-dates

It works on my local Laravel Valet environment but on my remote server it sends me to the error page. So I guess it’s my server, but don0t know what wrong with it.

That repo works for me as well, apart from the missing Kirby folder :wink:

I don’t know either. so you actually see the Kirby error page or a server error page on the server?

I use kirby as a submodule! and I get Kirby error page.

Even on the home page?

Is there any information in the error logs? What is the PHP version on the remote server? Could you send me a link to the remote site?

Yes, on the home page. Tried and another server with same results.

Php is 7.3.14 on one, 7.2.26. No error logs. I’m sending you the link with a message.

In case someone finds this: I’ve not been able to fix it. It works locally but the date won’t be translated on the server. So i’m pretty sure it’s the server config or something like that but servers are out of my league.

For now I’ll stick to dates with number, maybe I’ll give it another shot later.