Use `getLocalizationData()`
authorCyperghost <olaf_schmitz_1@t-online.de>
Thu, 17 Oct 2024 12:32:26 +0000 (14:32 +0200)
committerCyperghost <olaf_schmitz_1@t-online.de>
Thu, 17 Oct 2024 12:32:26 +0000 (14:32 +0200)
ts/WoltLabSuite/Core/Component/EmojiPicker/woltlab-core-emoji-picker.ts
wcfsetup/install/files/js/WoltLabSuite/Core/Component/EmojiPicker/woltlab-core-emoji-picker.js

index c47fe9d6631c21e3463b1698c1f524e8f9173e2f..1457fc2ff1e0a0b431a4bb4e6b8833dabfd07e2b 100644 (file)
@@ -1,29 +1,7 @@
-import de from "emoji-picker-element/i18n/de";
-import en from "emoji-picker-element/i18n/en";
-import es from "emoji-picker-element/i18n/es";
-import fr from "emoji-picker-element/i18n/fr";
-import it from "emoji-picker-element/i18n/it";
-import nl from "emoji-picker-element/i18n/nl";
-import pl from "emoji-picker-element/i18n/pl";
-import pt_BR from "emoji-picker-element/i18n/pt_BR";
-import pt_PT from "emoji-picker-element/i18n/pt_PT";
-import ru_RU from "emoji-picker-element/i18n/ru_RU";
 import "emoji-picker-element";
-import { PickerConstructorOptions, I18n } from "emoji-picker-element/shared";
+import { PickerConstructorOptions } from "emoji-picker-element/shared";
 import { Picker } from "emoji-picker-element";
-
-const EmojiPickerLocales: { [key: string]: I18n } = {
-  de,
-  en,
-  es,
-  fr,
-  it,
-  nl,
-  pl,
-  "pt-br": pt_BR,
-  "pt-pt": pt_PT,
-  "ru-ru": ru_RU,
-};
+import { getLocalizationData } from "WoltLabSuite/Core/Component/EmojiPicker/Localization";
 
 function getDataSource(locale: string): string {
   return `${window.WSC_API_URL}emoji/${locale}.json`;
@@ -37,7 +15,7 @@ export class WoltlabCoreEmojiPicker extends Picker {
       locale: locale,
       ...(props || {}),
       dataSource: getDataSource(locale),
-      ...(Object.hasOwn(EmojiPickerLocales, locale) ? { i18n: EmojiPickerLocales[locale] } : {}),
+      i18n: getLocalizationData(locale),
     });
   }
 
index c4b30de1077100c384a2903766e7a39d3fc65a5d..a4d177aa8a759f69ec396a5db1cbf8f21e677bb0 100644 (file)
@@ -1,29 +1,7 @@
-define(["require", "exports", "tslib", "emoji-picker-element/i18n/de", "emoji-picker-element/i18n/en", "emoji-picker-element/i18n/es", "emoji-picker-element/i18n/fr", "emoji-picker-element/i18n/it", "emoji-picker-element/i18n/nl", "emoji-picker-element/i18n/pl", "emoji-picker-element/i18n/pt_BR", "emoji-picker-element/i18n/pt_PT", "emoji-picker-element/i18n/ru_RU", "emoji-picker-element", "emoji-picker-element"], function (require, exports, tslib_1, de_1, en_1, es_1, fr_1, it_1, nl_1, pl_1, pt_BR_1, pt_PT_1, ru_RU_1, emoji_picker_element_1) {
+define(["require", "exports", "emoji-picker-element", "WoltLabSuite/Core/Component/EmojiPicker/Localization", "emoji-picker-element"], function (require, exports, emoji_picker_element_1, Localization_1) {
     "use strict";
     Object.defineProperty(exports, "__esModule", { value: true });
     exports.WoltlabCoreEmojiPicker = void 0;
-    de_1 = tslib_1.__importDefault(de_1);
-    en_1 = tslib_1.__importDefault(en_1);
-    es_1 = tslib_1.__importDefault(es_1);
-    fr_1 = tslib_1.__importDefault(fr_1);
-    it_1 = tslib_1.__importDefault(it_1);
-    nl_1 = tslib_1.__importDefault(nl_1);
-    pl_1 = tslib_1.__importDefault(pl_1);
-    pt_BR_1 = tslib_1.__importDefault(pt_BR_1);
-    pt_PT_1 = tslib_1.__importDefault(pt_PT_1);
-    ru_RU_1 = tslib_1.__importDefault(ru_RU_1);
-    const EmojiPickerLocales = {
-        de: de_1.default,
-        en: en_1.default,
-        es: es_1.default,
-        fr: fr_1.default,
-        it: it_1.default,
-        nl: nl_1.default,
-        pl: pl_1.default,
-        "pt-br": pt_BR_1.default,
-        "pt-pt": pt_PT_1.default,
-        "ru-ru": ru_RU_1.default,
-    };
     function getDataSource(locale) {
         return `${window.WSC_API_URL}emoji/${locale}.json`;
     }
@@ -34,7 +12,7 @@ define(["require", "exports", "tslib", "emoji-picker-element/i18n/de", "emoji-pi
                 locale: locale,
                 ...(props || {}),
                 dataSource: getDataSource(locale),
-                ...(Object.hasOwn(EmojiPickerLocales, locale) ? { i18n: EmojiPickerLocales[locale] } : {}),
+                i18n: (0, Localization_1.getLocalizationData)(locale),
             });
         }
         static get observedAttributes() {