From 500a3eb9717c04703331aa50708721b8794d4d6b Mon Sep 17 00:00:00 2001 From: Neloreck Date: Fri, 1 Sep 2023 23:59:51 +0300 Subject: [PATCH] Use 1251 locale only for ukr/rus lang. --- cli/build/steps/translations_dynamic.ts | 8 ++++---- src/engine/translations/example.xml | 2 ++ src/engine/translations/multilang.eng.xml | 2 ++ src/engine/translations/multilang.pol.xml | 2 ++ src/engine/translations/multilang.rus.xml | 2 ++ src/engine/translations/multilang.ukr.xml | 2 ++ 6 files changed, 14 insertions(+), 4 deletions(-) diff --git a/cli/build/steps/translations_dynamic.ts b/cli/build/steps/translations_dynamic.ts index d897bf3e4..6afb2d1ea 100644 --- a/cli/build/steps/translations_dynamic.ts +++ b/cli/build/steps/translations_dynamic.ts @@ -21,15 +21,14 @@ import { const log: NodeLogger = new NodeLogger("BUILD_TRANSLATIONS_DYNAMIC"); const EXPECTED_CONFIG_EXTENSIONS: Array = [EAssetExtension.JSON]; +const WINDOWS_1251_LOCALES: Array = ["ukr", "rus"]; const LOCALES_TO_PROCESS: Array = config.available_locales; -const TARGET_ENCODING: EEncoding = EEncoding.WINDOWS_1251; /** * Build different languages translations based on JSON files. */ export async function buildDynamicTranslations(): Promise { log.info(blueBright("Build translations")); - log.info("Target encoding:", yellowBright(TARGET_ENCODING)); if (LOCALES_TO_PROCESS.length === 0) { return log.warn("No languages to translate found in config.json file, skip"); @@ -92,7 +91,6 @@ function createJsonTranslationFiles(descriptor: TFolderReplicationDescriptor): v const [source] = descriptor; const comment: string = ` \n\n`; - const heading: string = `\n\n`; const filename: string = path.parse(source).name; // eslint-disable-next-line @typescript-eslint/no-var-requires @@ -101,6 +99,8 @@ function createJsonTranslationFiles(descriptor: TFolderReplicationDescriptor): v log.debug("Processing:", source); LOCALES_TO_PROCESS.forEach((locale) => { + const encoding: string = WINDOWS_1251_LOCALES.includes(locale) ? EEncoding.WINDOWS_1251 : EEncoding.WINDOWS_1250; + const heading: string = `\n\n`; const targetFile: string = path.resolve(TARGET_GAME_DATA_TRANSLATIONS_DIR, locale, filename + EAssetExtension.XML); const targetData = JSXXML( "string_table", @@ -119,6 +119,6 @@ function createJsonTranslationFiles(descriptor: TFolderReplicationDescriptor): v log.debug("Creating resulting translation:", targetFile); - fs.writeFileSync(targetFile, encode(renderJsxToXmlText(targetData, heading + comment), TARGET_ENCODING)); + fs.writeFileSync(targetFile, encode(renderJsxToXmlText(targetData, heading + comment), encoding)); }); } diff --git a/src/engine/translations/example.xml b/src/engine/translations/example.xml index 44ace4f6d..ce3ef0a14 100644 --- a/src/engine/translations/example.xml +++ b/src/engine/translations/example.xml @@ -1,3 +1,5 @@ + + example diff --git a/src/engine/translations/multilang.eng.xml b/src/engine/translations/multilang.eng.xml index be7840bfc..99bad5175 100644 --- a/src/engine/translations/multilang.eng.xml +++ b/src/engine/translations/multilang.eng.xml @@ -1,3 +1,5 @@ + + eng diff --git a/src/engine/translations/multilang.pol.xml b/src/engine/translations/multilang.pol.xml index 50d0b863d..0c8bc317e 100644 --- a/src/engine/translations/multilang.pol.xml +++ b/src/engine/translations/multilang.pol.xml @@ -1,3 +1,5 @@ + + pol diff --git a/src/engine/translations/multilang.rus.xml b/src/engine/translations/multilang.rus.xml index 483e20598..38f8391d4 100644 --- a/src/engine/translations/multilang.rus.xml +++ b/src/engine/translations/multilang.rus.xml @@ -1,3 +1,5 @@ + + rus diff --git a/src/engine/translations/multilang.ukr.xml b/src/engine/translations/multilang.ukr.xml index a84d48eed..086cbe697 100644 --- a/src/engine/translations/multilang.ukr.xml +++ b/src/engine/translations/multilang.ukr.xml @@ -1,3 +1,5 @@ + + ukr