mirror of
https://framagit.org/framasoft/framadate/framadate
synced 2026-01-22 18:04:15 +00:00
Make sure the given locale is available for php-intl/ICU
Or fallback to default language Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
70830c514d
commit
e96c2256ef
1 changed files with 4 additions and 0 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue