11import * as fs from "fs" ;
22import { promisify } from "util" ;
33import * as path from "path" ;
4- import { I18n } from "emoji-picker-element/shared" ;
5- import de from "emoji-picker-element/i18n/de" ;
6- import en from "emoji-picker-element/i18n/en" ;
7- import es from "emoji-picker-element/i18n/es" ;
8- import fr from "emoji-picker-element/i18n/fr" ;
9- import it from "emoji-picker-element/i18n/it" ;
10- import nl from "emoji-picker-element/i18n/nl" ;
11- import pl from "emoji-picker-element/i18n/pl" ;
12- import pt_PT from "emoji-picker-element/i18n/pt_PT" ;
13- import ru_RU from "emoji-picker-element/i18n/ru_RU" ;
144
155const copyFile = promisify ( fs . copyFile ) ;
166const writeFile = promisify ( fs . writeFile ) ;
@@ -33,25 +23,25 @@ if (!fs.existsSync(localisation)) {
3323 throw new Error ( `The path '${ localisation } ' does not exist.` ) ;
3424}
3525
36- const languages : LanguageItem [ ] = [
37- { local : "da" } ,
38- { local : "nl" , i18n : nl } ,
39- { local : "en" , i18n : en } ,
40- { local : "en-gb" } ,
41- { local : "et" } ,
42- { local : "fi" } ,
43- { local : "fr" , i18n : fr } ,
44- { local : "de" , i18n : de } ,
45- { local : "hu" } ,
46- { local : "it" , i18n : it } ,
47- { local : "lt" } ,
48- { local : "nb" } ,
49- { local : "pl" , i18n : pl } ,
50- { local : "pt" , i18n : pt_PT } ,
51- { local : "ru" , i18n : ru_RU } ,
52- { local : "es" , i18n : es } ,
53- { local : "sv" } ,
54- { local : "uk" } ,
26+ const languages : string [ ] = [
27+ "da" ,
28+ "en" ,
29+ "nl" ,
30+ "en-gb" ,
31+ "et" ,
32+ "fi" ,
33+ "fr" ,
34+ "de" ,
35+ "hu" ,
36+ "it" ,
37+ "lt" ,
38+ "nb" ,
39+ "pl" ,
40+ "pt" ,
41+ "ru" ,
42+ "es" ,
43+ "sv" ,
44+ "uk" ,
5545] ;
5646
5747( async ( ) => {
@@ -64,38 +54,13 @@ const languages: LanguageItem[] = [
6454 * @woltlabExcludeBundle all
6555 */
6656
67- import { I18n } from "emoji-picker-element/shared";
68-
6957// prettier-ignore
7058const locales = [
71- ${ languages . map ( ( item ) => {
72- return `"${ item . local } "` ;
59+ ${ languages . map ( ( language ) => {
60+ return `"${ language } "` ;
7361 } ) }
7462];
7563
76- export function getLocalizationData(localization: string): I18n {
77- if (localization.includes("-")) {
78- localization = localization.split("-")[0];
79- }
80-
81- switch (localization) {
82- ${ languages
83- . filter ( ( item ) => {
84- return item . local !== "en" ;
85- } )
86- . filter ( ( language ) => language . i18n )
87- . map ( ( item ) => {
88- return `case "${ item . local } ":
89- // prettier-ignore
90- return ${ JSON . stringify ( item . i18n ) } ;` ;
91- } )
92- . join ( "\n " ) }
93- default:
94- // prettier-ignore
95- return ${ JSON . stringify ( en ) } ;
96- }
97- }
98-
9964export function getDataSource(locale: string): string {
10065 if (!locales.includes(locale)) {
10166 return \`\${window.WCF_PATH}emoji/en.json\`;
@@ -115,15 +80,10 @@ export function getDataSource(locale: string): string {
11580
11681 for ( const language of languages ) {
11782 await copyFile (
118- path . join ( __dirname , `node_modules/emoji-picker-element-data/${ language . local } /cldr-native/data.json` ) ,
119- path . join ( repository , `${ language . local } .json` ) ,
83+ path . join ( __dirname , `node_modules/emoji-picker-element-data/${ language } /cldr-native/data.json` ) ,
84+ path . join ( repository , `${ language } .json` ) ,
12085 ) ;
12186 }
12287
12388 await writeFile ( localisation , localisationContent ) ;
12489} ) ( ) ;
125-
126- interface LanguageItem {
127- local : string ;
128- i18n ?: I18n ;
129- }
0 commit comments