Skip to content

Commit

Permalink
Use 1251 locale only for ukr/rus lang.
Browse files Browse the repository at this point in the history
  • Loading branch information
Neloreck committed Sep 1, 2023
1 parent dc4ba3f commit 500a3eb
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 4 deletions.
8 changes: 4 additions & 4 deletions cli/build/steps/translations_dynamic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,14 @@ import {
const log: NodeLogger = new NodeLogger("BUILD_TRANSLATIONS_DYNAMIC");

const EXPECTED_CONFIG_EXTENSIONS: Array<EAssetExtension> = [EAssetExtension.JSON];
const WINDOWS_1251_LOCALES: Array<string> = ["ukr", "rus"];
const LOCALES_TO_PROCESS: Array<string> = config.available_locales;
const TARGET_ENCODING: EEncoding = EEncoding.WINDOWS_1251;

/**
* Build different languages translations based on JSON files.
*/
export async function buildDynamicTranslations(): Promise<void> {
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");
Expand Down Expand Up @@ -92,7 +91,6 @@ function createJsonTranslationFiles(descriptor: TFolderReplicationDescriptor): v
const [source] = descriptor;

const comment: string = `<!-- Generated by xrf util at: ${new Date().toString()} --> \n\n`;
const heading: string = `<?xml version=${quoted("1.0")} encoding="${TARGET_ENCODING}" ?>\n\n`;
const filename: string = path.parse(source).name;

// eslint-disable-next-line @typescript-eslint/no-var-requires
Expand All @@ -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 = `<?xml version=${quoted("1.0")} encoding="${encoding}" ?>\n\n`;
const targetFile: string = path.resolve(TARGET_GAME_DATA_TRANSLATIONS_DIR, locale, filename + EAssetExtension.XML);
const targetData = JSXXML(
"string_table",
Expand All @@ -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));
});
}
2 changes: 2 additions & 0 deletions src/engine/translations/example.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<?xml version="1.0" encoding="windows-1250" ?>

<string_table>
<string id="st_example">
<text>example</text>
Expand Down
2 changes: 2 additions & 0 deletions src/engine/translations/multilang.eng.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<?xml version="1.0" encoding="windows-1250" ?>

<string_table>
<string id="st_multilang_example">
<text>eng</text>
Expand Down
2 changes: 2 additions & 0 deletions src/engine/translations/multilang.pol.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<?xml version="1.0" encoding="windows-1250" ?>

<string_table>
<string id="st_multilang_example">
<text>pol</text>
Expand Down
2 changes: 2 additions & 0 deletions src/engine/translations/multilang.rus.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<?xml version="1.0" encoding="windows-1251" ?>

<string_table>
<string id="st_multilang_example">
<text>rus</text>
Expand Down
2 changes: 2 additions & 0 deletions src/engine/translations/multilang.ukr.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<?xml version="1.0" encoding="windows-1251" ?>

<string_table>
<string id="st_multilang_example">
<text>ukr</text>
Expand Down

0 comments on commit 500a3eb

Please sign in to comment.