From baf07a4a2c428cb406a1532afa7c8c008a743182 Mon Sep 17 00:00:00 2001 From: ralf Date: Fri, 29 Apr 2022 17:40:43 +0200 Subject: [PATCH] only load localization, if we have one --- api/js/etemplate/Et2Date/Et2Date.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/api/js/etemplate/Et2Date/Et2Date.ts b/api/js/etemplate/Et2Date/Et2Date.ts index 6560650b22..f79f7f341c 100644 --- a/api/js/etemplate/Et2Date/Et2Date.ts +++ b/api/js/etemplate/Et2Date/Et2Date.ts @@ -17,12 +17,21 @@ import {dateStyles} from "./DateStyles"; import {LitFlatpickr} from "lit-flatpickr"; import "flatpickr/dist/plugins/scrollPlugin.js"; -if(egw.preference('lang') && egw.preference('lang') !== "en") +// list of existing localizations from node_modules/flatpicker/dist/l10n directory: +const l10n = [ + 'ar', 'at', 'az', 'be', 'bg', 'bn', 'bs', 'cat', 'cs', 'cy', 'da', 'de', 'eo', 'es', 'et', 'fa', 'fi', 'fo', + 'fr', 'ga', 'gr', 'he', 'hi', 'hr', 'hu', 'id', 'index', 'is', 'it', 'ja', 'ka', 'km', 'ko', 'kz', 'lt', 'lv', 'mk', + 'mn', 'ms', 'my', 'nl', 'no', 'pa', 'pl', 'pt', 'ro', 'ru', 'si', 'sk', 'sl', 'sq', 'sr-cyr', 'sr', 'sv', 'th', 'tr', + 'uk', 'uz', 'uz_latn', 'vn', 'zh-tw', 'zh', +]; +const lang = egw.preference('lang'); +// only load localization, if we have one +if (l10n.indexOf(lang) >= 0) { - import(egw.webserverUrl + "/node_modules/flatpickr/dist/l10n/" + (egw.preference('lang') + ".js")).then(() => + import(egw.webserverUrl + "/node_modules/flatpickr/dist/l10n/" + lang + ".js").then(() => { // @ts-ignore - flatpickr.localize(flatpickr.l10ns[egw.preference('lang')]); + flatpickr.localize(flatpickr.l10ns[lang]); }); }