From 1a8e79271002d244b3dd3cf408c67a95379f0465 Mon Sep 17 00:00:00 2001 From: Cyperghost Date: Fri, 18 Oct 2024 09:15:21 +0200 Subject: [PATCH] Add pt and ru to the Localization.ts --- extra/update-emoji-picker-element-data.ts | 86 ----------------- extra/update-emoji-picker-element.ts | 93 +++++++++++++++++++ .../Component/EmojiPicker/Localization.ts | 8 ++ .../Component/EmojiPicker/Localization.js | 7 ++ 4 files changed, 108 insertions(+), 86 deletions(-) delete mode 100644 extra/update-emoji-picker-element-data.ts create mode 100644 extra/update-emoji-picker-element.ts diff --git a/extra/update-emoji-picker-element-data.ts b/extra/update-emoji-picker-element-data.ts deleted file mode 100644 index 93267d1d39..0000000000 --- a/extra/update-emoji-picker-element-data.ts +++ /dev/null @@ -1,86 +0,0 @@ -import * as fs from "fs"; -import { promisify } from "util"; -import * as path from "path"; -import { I18n } from "emoji-picker-element/shared"; - -const copyFile = promisify(fs.copyFile); -const writeFile = promisify(fs.writeFile); - -if (process.argv.length !== 4) { - throw new Error( - "Expects the path to the directory in which the emoji data is saved as the #1 argument and the path to the Localisation.ts as the #2 argument.", - ); -} - -const repository = process.argv[2]; -if (!fs.existsSync(repository)) { - throw new Error(`The path '${repository}' does not exist.`); -} - -const localisation = process.argv[3]; -if (!fs.existsSync(localisation)) { - throw new Error(`The path '${localisation}' does not exist.`); -} - -const languages = [ - "da", - "nl", - "en", - "en-gb", - "et", - "fi", - "fr", - "de", - "hu", - "it", - "lt", - "nb", - "pl", - "pt", - "ru", - "es", - "sv", - "uk", -]; - -(async () => { - const en = await import("emoji-picker-element/i18n/en"); - let importedLanguages = new Map< - string, - { - default: I18n; - } - >(); - for (const language of languages.filter((language) => language !== "en")) { - try { - importedLanguages.set(language, await import(`emoji-picker-element/i18n/${language}`)); - } catch { - // localizations not found, will be fallback to en - } - } - - let localisationContent = `import { I18n } from "emoji-picker-element/shared"; - -export function getLocalizationData(localization: string): I18n { - switch (localization) { - ${Array.from(importedLanguages.entries()) - .map(([languageCode, language]) => { - return `case "${languageCode}": - return ${JSON.stringify(language.default)};`; - }) - .join("\n ")} - default: - return ${JSON.stringify(en.default)}; - } -} -`; - - for (const language of languages) { - await copyFile( - path.join(__dirname, `node_modules/emoji-picker-element-data/${language}/cldr-native/data.json`), - path.join(repository, `${language}.json`), - ); - } - - await writeFile(localisation, localisationContent); -})(); diff --git a/extra/update-emoji-picker-element.ts b/extra/update-emoji-picker-element.ts new file mode 100644 index 0000000000..1503249fa7 --- /dev/null +++ b/extra/update-emoji-picker-element.ts @@ -0,0 +1,93 @@ +import * as fs from "fs"; +import { promisify } from "util"; +import * as path from "path"; +import { I18n } from "emoji-picker-element/shared"; +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_PT from "emoji-picker-element/i18n/pt_PT"; +import ru_RU from "emoji-picker-element/i18n/ru_RU"; + +const copyFile = promisify(fs.copyFile); +const writeFile = promisify(fs.writeFile); + +if (process.argv.length !== 4) { + throw new Error( + "Expects the path to the directory in which the emoji data is saved as the #1 argument and the path to the Localisation.ts as the #2 argument.", + ); +} + +const repository = process.argv[2]; +if (!fs.existsSync(repository)) { + throw new Error(`The path '${repository}' does not exist.`); +} + +const localisation = process.argv[3]; +if (!fs.existsSync(localisation)) { + throw new Error(`The path '${localisation}' does not exist.`); +} + +const languages: LanguageItem[] = [ + { local: "da" }, + { local: "nl", i18n: nl }, + { local: "en", i18n: en }, + { local: "en-gb" }, + { local: "et" }, + { local: "fi" }, + { local: "fr", i18n: fr }, + { local: "de", i18n: de }, + { local: "hu" }, + { local: "it", i18n: it }, + { local: "lt" }, + { local: "nb" }, + { local: "pl", i18n: pl }, + { local: "pt", i18n: pt_PT }, + { local: "ru", i18n: ru_RU }, + { local: "es", i18n: es }, + { local: "sv" }, + { local: "uk" }, +]; + +(async () => { + let localisationContent = `import { I18n } from "emoji-picker-element/shared"; + +export function getLocalizationData(localization: string): I18n { + if (localization.includes("-")) { + localization = localization.split("-")[0]; + } + + switch (localization) { + ${languages + .filter((item) => { + return item.local !== "en"; + }) + .filter((language) => language.i18n) + .map((item) => { + return `case "${item.local}": + return ${JSON.stringify(item.i18n)};`; + }) + .join("\n ")} + default: + return ${JSON.stringify(en)}; + } +} +`; + + for (const language of languages) { + await copyFile( + path.join(__dirname, `node_modules/emoji-picker-element-data/${language.local}/cldr-native/data.json`), + path.join(repository, `${language.local}.json`), + ); + } + + await writeFile(localisation, localisationContent); +})(); + +interface LanguageItem { + local: string; + i18n?: I18n; +} diff --git a/ts/WoltLabSuite/Core/Component/EmojiPicker/Localization.ts b/ts/WoltLabSuite/Core/Component/EmojiPicker/Localization.ts index 652dae1a05..4923ec1b43 100644 --- a/ts/WoltLabSuite/Core/Component/EmojiPicker/Localization.ts +++ b/ts/WoltLabSuite/Core/Component/EmojiPicker/Localization.ts @@ -1,6 +1,10 @@ import { I18n } from "emoji-picker-element/shared"; export function getLocalizationData(localization: string): I18n { + if (localization.includes("-")) { + localization = localization.split("-")[0]; + } + switch (localization) { case "nl": return {"categoriesLabel":"Categorieën","emojiUnsupportedMessage":"Uw browser ondersteunt geen kleurenemoji.","favoritesLabel":"Favorieten","loadingMessage":"Bezig met laden…","networkErrorMessage":"Kan emoji niet laden.","regionLabel":"Emoji-kiezer","searchDescription":"Als er zoekresultaten beschikbaar zijn, drukt u op omhoog of omlaag om te selecteren en op enter om te kiezen.","searchLabel":"Zoeken","searchResultsLabel":"Zoekresultaten","skinToneDescription":"Wanneer uitgevouwen, druk omhoog of omlaag om te selecteren en enter om te kiezen.","skinToneLabel":"Kies een huidskleur (momenteel {skinTone})","skinTonesLabel":"Huidskleuren","skinTones":["Standaard","Licht","Medium-Licht","Medium","Middeldonker","Donker"],"categories":{"custom":"Aangepast","smileys-emotion":"Smileys en emoticons","people-body":"Mensen en lichaam","animals-nature":"Dieren en natuur","food-drink":"Eten en drinken","travel-places":"Reizen en plaatsen","activities":"Activiteiten","objects":"Voorwerpen","symbols":"Symbolen","flags":"Vlaggen"}}; @@ -12,6 +16,10 @@ export function getLocalizationData(localization: string): I18n { return {"categoriesLabel":"Categorie","emojiUnsupportedMessage":"Il tuo browser non supporta le emoji colorate.","favoritesLabel":"Preferiti","loadingMessage":"Caricamento...","networkErrorMessage":"Impossibile caricare le emoji.","regionLabel":"Selezione emoji","searchDescription":"Quando i risultati della ricerca sono disponibili, premi su o giù per selezionare e invio per scegliere.","searchLabel":"Cerca","searchResultsLabel":"Risultati di ricerca","skinToneDescription":"Quando espanso, premi su o giù per selezionare e invio per scegliere.","skinToneLabel":"Scegli una tonalità della pelle (corrente {skinTone})","skinTonesLabel":"Tonalità della pelle","skinTones":["Predefinita","Chiara","Medio-Chiara","Media","Medio-Scura","Scura"],"categories":{"custom":"Personalizzata","smileys-emotion":"Faccine ed emozioni","people-body":"Persone e corpi","animals-nature":"Animali e natura","food-drink":"Cibi e bevande","travel-places":"Viaggi e luoghi","activities":"Attività","objects":"Oggetti","symbols":"Simboli","flags":"Bandiere"}}; case "pl": return {"categoriesLabel":"Kategorie","emojiUnsupportedMessage":"Twoja przeglądarka nie wspiera kolorowych emotikon.","favoritesLabel":"Ulubione","loadingMessage":"Ładuję…","networkErrorMessage":"Nie można załadować emoji.","regionLabel":"Selektor emoji","searchDescription":"Kiedy wyniki wyszukiwania będą dostępne, wciśnij góra lub dół aby wybrać oraz enter aby zatwierdzić wybór.","searchLabel":"Wyszukaj","searchResultsLabel":"Wyniki wyszukiwania","skinToneDescription":"Po rozwinięciu wciśnij góra lub dół aby wybrać oraz enter aby zatwierdzić wybór.","skinToneLabel":"Wybierz odcień skóry (aktualnie {skinTone})","skinTonesLabel":"Odcienie skóry","skinTones":["Domyślna","Jasna","Średnio-jasna","Średnia","Średnio-ciemna","Ciemna"],"categories":{"custom":"Własne","smileys-emotion":"Uśmiechy","people-body":"Ludzie","animals-nature":"Zwierzęta i natura","food-drink":"Żywność i napoje","travel-places":"Podróże i miejsca","activities":"Aktywności","objects":"Obiekty","symbols":"Symbole","flags":"Flagi"}}; + case "pt": + return {"categoriesLabel":"Categorias","emojiUnsupportedMessage":"O seu browser não suporta emojis.","favoritesLabel":"Favoritos","loadingMessage":"A Carregar…","networkErrorMessage":"Não foi possível carregar o emoji.","regionLabel":"Emoji picker","searchDescription":"Quando os resultados da pesquisa estiverem disponíveis, pressione para cima ou para baixo para selecionar e digite para escolher.","searchLabel":"Procurar","searchResultsLabel":"Resultados da procura","skinToneDescription":"Quando expandido, pressione para cima ou para baixo para selecionar e digite para escolher.","skinToneLabel":"Escolha um tom de pele (atual {skinTone})","skinTonesLabel":"Tons de pele","skinTones":["Pré-definido","Claro","Médio-Claro","Médio","Médio-Escuro","Escuro"],"categories":{"custom":"Personalizados","smileys-emotion":"Smileys e emoticons","people-body":"Pessoas e corpo","animals-nature":"Animais e natureza","food-drink":"Comida e bebida","travel-places":"Viagens e locais","activities":"Atividades","objects":"Objetos","symbols":"Símbolos","flags":"Bandeiras"}}; + case "ru": + return {"categoriesLabel":"Категории","emojiUnsupportedMessage":"Ваш браузер не поддерживает цветные эмодзи.","favoritesLabel":"Избранное","loadingMessage":"Загрузка…","networkErrorMessage":"Не удалось загрузить эмодзи. Попробуйте перезагрузить страницу.","regionLabel":"Выберите эмодзи","searchDescription":"Когда результаты поиска станут доступны, выберите их с помощью стрелок вверх и вниз, затем нажмите для подтверждения.","searchLabel":"Искать","searchResultsLabel":"Результаты поиска","skinToneDescription":"При отображении используйте клавиши со стрелками вверх и вниз для выбора, нажмите для подтверждения.","skinToneLabel":"Выберите оттенок кожи (текущий {skinTone})","skinTonesLabel":"Оттенки кожи","skinTones":["Стандартный","Светлый","Средне-светлый","Средний","Средне-темный","Темный"],"categories":{"custom":"Пользовательский","smileys-emotion":"Смайлики и Эмотиконы","people-body":"Люди и Тела","animals-nature":"Животные и Природа","food-drink":"Еда и Напитки","travel-places":"Путешествия и Места","activities":"Виды деятельности","objects":"Объекты","symbols":"Символы","flags":"Флаги"}}; case "es": return {"categoriesLabel":"Categorías","emojiUnsupportedMessage":"El navegador no admite emojis de color.","favoritesLabel":"Favoritos","loadingMessage":"Cargando…","networkErrorMessage":"No se pudo cargar el emoji.","regionLabel":"Selector de emojis","searchDescription":"Cuando estén disponibles los resultados, pulsa la tecla hacia arriba o hacia abajo para seleccionar y la tecla intro para elegir.","searchLabel":"Buscar","searchResultsLabel":"Resultados de búsqueda","skinToneDescription":"Cuando se abran las opciones, pulsa la tecla hacia arriba o hacia abajo para seleccionar y la tecla intro para elegir.","skinToneLabel":"Elige un tono de piel ({skinTone} es el actual)","skinTonesLabel":"Tonos de piel","skinTones":["Predeterminado","Claro","Claro medio","Medio","Oscuro medio","Oscuro"],"categories":{"custom":"Personalizado","smileys-emotion":"Emojis y emoticones","people-body":"Personas y partes del cuerpo","animals-nature":"Animales y naturaleza","food-drink":"Comida y bebida","travel-places":"Viajes y lugares","activities":"Actividades","objects":"Objetos","symbols":"Símbolos","flags":"Banderas"}}; default: diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Component/EmojiPicker/Localization.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Component/EmojiPicker/Localization.js index 529bc4e7ba..687a0f3735 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Component/EmojiPicker/Localization.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Component/EmojiPicker/Localization.js @@ -3,6 +3,9 @@ define(["require", "exports"], function (require, exports) { Object.defineProperty(exports, "__esModule", { value: true }); exports.getLocalizationData = getLocalizationData; function getLocalizationData(localization) { + if (localization.includes("-")) { + localization = localization.split("-")[0]; + } switch (localization) { case "nl": return { "categoriesLabel": "Categorieën", "emojiUnsupportedMessage": "Uw browser ondersteunt geen kleurenemoji.", "favoritesLabel": "Favorieten", "loadingMessage": "Bezig met laden…", "networkErrorMessage": "Kan emoji niet laden.", "regionLabel": "Emoji-kiezer", "searchDescription": "Als er zoekresultaten beschikbaar zijn, drukt u op omhoog of omlaag om te selecteren en op enter om te kiezen.", "searchLabel": "Zoeken", "searchResultsLabel": "Zoekresultaten", "skinToneDescription": "Wanneer uitgevouwen, druk omhoog of omlaag om te selecteren en enter om te kiezen.", "skinToneLabel": "Kies een huidskleur (momenteel {skinTone})", "skinTonesLabel": "Huidskleuren", "skinTones": ["Standaard", "Licht", "Medium-Licht", "Medium", "Middeldonker", "Donker"], "categories": { "custom": "Aangepast", "smileys-emotion": "Smileys en emoticons", "people-body": "Mensen en lichaam", "animals-nature": "Dieren en natuur", "food-drink": "Eten en drinken", "travel-places": "Reizen en plaatsen", "activities": "Activiteiten", "objects": "Voorwerpen", "symbols": "Symbolen", "flags": "Vlaggen" } }; @@ -14,6 +17,10 @@ define(["require", "exports"], function (require, exports) { return { "categoriesLabel": "Categorie", "emojiUnsupportedMessage": "Il tuo browser non supporta le emoji colorate.", "favoritesLabel": "Preferiti", "loadingMessage": "Caricamento...", "networkErrorMessage": "Impossibile caricare le emoji.", "regionLabel": "Selezione emoji", "searchDescription": "Quando i risultati della ricerca sono disponibili, premi su o giù per selezionare e invio per scegliere.", "searchLabel": "Cerca", "searchResultsLabel": "Risultati di ricerca", "skinToneDescription": "Quando espanso, premi su o giù per selezionare e invio per scegliere.", "skinToneLabel": "Scegli una tonalità della pelle (corrente {skinTone})", "skinTonesLabel": "Tonalità della pelle", "skinTones": ["Predefinita", "Chiara", "Medio-Chiara", "Media", "Medio-Scura", "Scura"], "categories": { "custom": "Personalizzata", "smileys-emotion": "Faccine ed emozioni", "people-body": "Persone e corpi", "animals-nature": "Animali e natura", "food-drink": "Cibi e bevande", "travel-places": "Viaggi e luoghi", "activities": "Attività", "objects": "Oggetti", "symbols": "Simboli", "flags": "Bandiere" } }; case "pl": return { "categoriesLabel": "Kategorie", "emojiUnsupportedMessage": "Twoja przeglądarka nie wspiera kolorowych emotikon.", "favoritesLabel": "Ulubione", "loadingMessage": "Ładuję…", "networkErrorMessage": "Nie można załadować emoji.", "regionLabel": "Selektor emoji", "searchDescription": "Kiedy wyniki wyszukiwania będą dostępne, wciśnij góra lub dół aby wybrać oraz enter aby zatwierdzić wybór.", "searchLabel": "Wyszukaj", "searchResultsLabel": "Wyniki wyszukiwania", "skinToneDescription": "Po rozwinięciu wciśnij góra lub dół aby wybrać oraz enter aby zatwierdzić wybór.", "skinToneLabel": "Wybierz odcień skóry (aktualnie {skinTone})", "skinTonesLabel": "Odcienie skóry", "skinTones": ["Domyślna", "Jasna", "Średnio-jasna", "Średnia", "Średnio-ciemna", "Ciemna"], "categories": { "custom": "Własne", "smileys-emotion": "Uśmiechy", "people-body": "Ludzie", "animals-nature": "Zwierzęta i natura", "food-drink": "Żywność i napoje", "travel-places": "Podróże i miejsca", "activities": "Aktywności", "objects": "Obiekty", "symbols": "Symbole", "flags": "Flagi" } }; + case "pt": + return { "categoriesLabel": "Categorias", "emojiUnsupportedMessage": "O seu browser não suporta emojis.", "favoritesLabel": "Favoritos", "loadingMessage": "A Carregar…", "networkErrorMessage": "Não foi possível carregar o emoji.", "regionLabel": "Emoji picker", "searchDescription": "Quando os resultados da pesquisa estiverem disponíveis, pressione para cima ou para baixo para selecionar e digite para escolher.", "searchLabel": "Procurar", "searchResultsLabel": "Resultados da procura", "skinToneDescription": "Quando expandido, pressione para cima ou para baixo para selecionar e digite para escolher.", "skinToneLabel": "Escolha um tom de pele (atual {skinTone})", "skinTonesLabel": "Tons de pele", "skinTones": ["Pré-definido", "Claro", "Médio-Claro", "Médio", "Médio-Escuro", "Escuro"], "categories": { "custom": "Personalizados", "smileys-emotion": "Smileys e emoticons", "people-body": "Pessoas e corpo", "animals-nature": "Animais e natureza", "food-drink": "Comida e bebida", "travel-places": "Viagens e locais", "activities": "Atividades", "objects": "Objetos", "symbols": "Símbolos", "flags": "Bandeiras" } }; + case "ru": + return { "categoriesLabel": "Категории", "emojiUnsupportedMessage": "Ваш браузер не поддерживает цветные эмодзи.", "favoritesLabel": "Избранное", "loadingMessage": "Загрузка…", "networkErrorMessage": "Не удалось загрузить эмодзи. Попробуйте перезагрузить страницу.", "regionLabel": "Выберите эмодзи", "searchDescription": "Когда результаты поиска станут доступны, выберите их с помощью стрелок вверх и вниз, затем нажмите для подтверждения.", "searchLabel": "Искать", "searchResultsLabel": "Результаты поиска", "skinToneDescription": "При отображении используйте клавиши со стрелками вверх и вниз для выбора, нажмите для подтверждения.", "skinToneLabel": "Выберите оттенок кожи (текущий {skinTone})", "skinTonesLabel": "Оттенки кожи", "skinTones": ["Стандартный", "Светлый", "Средне-светлый", "Средний", "Средне-темный", "Темный"], "categories": { "custom": "Пользовательский", "smileys-emotion": "Смайлики и Эмотиконы", "people-body": "Люди и Тела", "animals-nature": "Животные и Природа", "food-drink": "Еда и Напитки", "travel-places": "Путешествия и Места", "activities": "Виды деятельности", "objects": "Объекты", "symbols": "Символы", "flags": "Флаги" } }; case "es": return { "categoriesLabel": "Categorías", "emojiUnsupportedMessage": "El navegador no admite emojis de color.", "favoritesLabel": "Favoritos", "loadingMessage": "Cargando…", "networkErrorMessage": "No se pudo cargar el emoji.", "regionLabel": "Selector de emojis", "searchDescription": "Cuando estén disponibles los resultados, pulsa la tecla hacia arriba o hacia abajo para seleccionar y la tecla intro para elegir.", "searchLabel": "Buscar", "searchResultsLabel": "Resultados de búsqueda", "skinToneDescription": "Cuando se abran las opciones, pulsa la tecla hacia arriba o hacia abajo para seleccionar y la tecla intro para elegir.", "skinToneLabel": "Elige un tono de piel ({skinTone} es el actual)", "skinTonesLabel": "Tonos de piel", "skinTones": ["Predeterminado", "Claro", "Claro medio", "Medio", "Oscuro medio", "Oscuro"], "categories": { "custom": "Personalizado", "smileys-emotion": "Emojis y emoticones", "people-body": "Personas y partes del cuerpo", "animals-nature": "Animales y naturaleza", "food-drink": "Comida y bebida", "travel-places": "Viajes y lugares", "activities": "Actividades", "objects": "Objetos", "symbols": "Símbolos", "flags": "Banderas" } }; default: -- 2.20.1