Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Date range locale #3

Open
j11k00 opened this issue Jan 9, 2024 · 4 comments
Open

Date range locale #3

j11k00 opened this issue Jan 9, 2024 · 4 comments

Comments

@j11k00
Copy link

j11k00 commented Jan 9, 2024

Thanks for developing this useful Kirby plugin. It looks like toDateRange() and dateRange() are not picking up the locale set in the config and return the string in German in any case. All the other methods helpers seem to work fine. Running on Kirby 4.

@nilshoerrmann
Copy link
Member

Interesting – this never occured to us so far. Two questions:

  1. Which PHP version are you using?
  2. Could you please provide an usage example with expected and actual result?

Thanks!

@j11k00
Copy link
Author

j11k00 commented Jan 9, 2024

Thanks for looking into this.

Running locally on MAMP Tried PHP 8.2 and 8.3

I have a page with two date fields, like so:

$start = $page->start();
$end = $page->end();
$range  = dateRange($start, $end);

echo $range;
// returns 16. – 23. März 2024 though locale is set to en_GB

Hope I'm not missing something obvious.

@nilshoerrmann
Copy link
Member

nilshoerrmann commented Jan 9, 2024

Oh, I think I understand the problem now. And yes, you are right, the dateRange helper (and thus the related method) is not consistent with the other methods. I'll have to think about how to fix this in a backwards-compatible way.

For now, adding the following to your config.php should fix the issue for now:

return [
    // … other setting here …
    'hananils.date-methods' => [
        'code' => 'en'
    ]
];

@j11k00
Copy link
Author

j11k00 commented Jan 9, 2024

Thanks again.

For anyone trying the solution above, had to add the full list of available options to do the trick.

return [
  'hananils.date-methods' => [
    'code' => 'en',
    'rangeseparator' => '',
    'datetimeseparator' => ', ',
    'datetype' => IntlDateFormatter::LONG,
    'timetype' => IntlDateFormatter::SHORT
  ]
];

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants