From e96c2256ef4a95d5dd8b0205631492907df1361e Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Tue, 22 Mar 2022 14:49:59 +0100 Subject: [PATCH] Make sure the given locale is available for php-intl/ICU Or fallback to default language Signed-off-by: Thomas Citharel --- app/inc/i18n.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/inc/i18n.php b/app/inc/i18n.php index 0f7f1fe..d481551 100644 --- a/app/inc/i18n.php +++ b/app/inc/i18n.php @@ -50,6 +50,10 @@ $date_format['txt_datetime_short'] = 'dd-MM-y HH:mm'; function formatDate(string $format, $date) { global $locale; + $locales = ResourceBundle::getLocales(''); + if (!in_array($locale, $locales, true)) { + $locale = DEFAULT_LANGUAGE; + } $formatter = new IntlDateFormatter($locale, IntlDateFormatter::SHORT, IntlDateFormatter::NONE); if ($format !== '') { $formatter->setPattern($format);