added xliff for i18n tools
This commit is contained in:
parent
2072a8de1f
commit
0c286bd2ca
File diff suppressed because it is too large
Load Diff
@ -69,6 +69,7 @@
|
||||
"@angular/cli": "13.1.3",
|
||||
"@angular/compiler-cli": "13.1.2",
|
||||
"@angular/language-service": "13.1.2",
|
||||
"@bartholomej/ngx-translate-extract": "^8.0.2",
|
||||
"@nrwl/cli": "13.4.5",
|
||||
"@nrwl/cypress": "13.4.5",
|
||||
"@nrwl/eslint-plugin-nx": "13.4.5",
|
||||
@ -83,7 +84,6 @@
|
||||
"@typescript-eslint/eslint-plugin": "5.9.1",
|
||||
"@typescript-eslint/parser": "5.3.1",
|
||||
"axios": "^0.24.0",
|
||||
"@bartholomej/ngx-translate-extract": "^8.0.2",
|
||||
"cypress": "^6.9.1",
|
||||
"cypress-file-upload": "^5.0.8",
|
||||
"cypress-keycloak": "^1.7.0",
|
||||
@ -113,6 +113,7 @@
|
||||
"ts-jest": "27.1.3",
|
||||
"ts-node": "10.4.0",
|
||||
"typescript": "4.5.4",
|
||||
"webpack": "^4.18.1"
|
||||
"webpack": "^4.18.1",
|
||||
"xliff": "^6.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,9 @@
|
||||
import * as fs from 'fs';
|
||||
import axios from 'axios';
|
||||
import { TranslateMessageFormatCompiler } from 'ngx-translate-messageformat-compiler';
|
||||
// @ts-ignore
|
||||
import * as xliff from 'xliff';
|
||||
|
||||
// import { TranslateMessageFormatCompiler } from 'ngx-translate-messageformat-compiler';
|
||||
|
||||
function flatten(data: any) {
|
||||
const result: any = {};
|
||||
@ -55,7 +58,7 @@ async function execute() {
|
||||
|
||||
const apiKey = 'AIzaSyBiqNTundSKFjAJnSb4wSVLDU6w0Kv651M';
|
||||
|
||||
const tmfc = new TranslateMessageFormatCompiler();
|
||||
// const tmfc = new TranslateMessageFormatCompiler();
|
||||
|
||||
for (const key of Object.keys(flatEnglish)) {
|
||||
if (!flatGerman[key]) {
|
||||
@ -80,8 +83,8 @@ async function execute() {
|
||||
|
||||
for (let key of Object.keys(flatGerman)) {
|
||||
try {
|
||||
const result = tmfc.compile(flatGerman[key], 'de');
|
||||
//console.log(result);
|
||||
// const result = tmfc.compile(flatGerman[key], 'de');
|
||||
// console.log(result);
|
||||
} catch (e) {
|
||||
console.error('ERROR AT: ', flatGerman[key]);
|
||||
}
|
||||
@ -89,8 +92,8 @@ async function execute() {
|
||||
|
||||
for (let key of Object.keys(flatEnglish)) {
|
||||
try {
|
||||
const result = tmfc.compile(flatEnglish[key], 'de');
|
||||
console.log(result);
|
||||
// const result = tmfc.compile(flatEnglish[key], 'de');
|
||||
// console.log(result);
|
||||
} catch (e) {
|
||||
console.error('ERROR AT: ', flatEnglish[key]);
|
||||
}
|
||||
@ -101,6 +104,44 @@ async function execute() {
|
||||
const finalGerman = unflatten(mergedGerman);
|
||||
|
||||
fs.writeFileSync('./../../apps/red-ui/src/assets/i18n/de.json', JSON.stringify(finalGerman));
|
||||
|
||||
const js: any = {
|
||||
resources: {
|
||||
redaction: {},
|
||||
},
|
||||
sourceLanguage: 'en-US',
|
||||
targetLanguage: 'de-DE',
|
||||
};
|
||||
|
||||
for (const key of Object.keys(flatEnglish)) {
|
||||
js.resources.redaction[`${key}`] = {
|
||||
source: flatEnglish[`${key}`],
|
||||
target: flatGerman[`${key}`],
|
||||
};
|
||||
}
|
||||
|
||||
xliff.jsToXliff12(js, (err: any, res: any) => {
|
||||
fs.writeFileSync('./redaction-en-to-de.xliff', res);
|
||||
});
|
||||
|
||||
const xliffImport = fs.readFileSync('./import.xliff', 'utf-8');
|
||||
xliff.xliff12ToJs(xliffImport, (err: any, res: any) => {
|
||||
const ns = res.resources.redaction;
|
||||
|
||||
const importGerman: any = {};
|
||||
const importEnglish: any = {};
|
||||
|
||||
for (let key of Object.keys(ns)) {
|
||||
importGerman[key] = ns[key].target;
|
||||
importEnglish[key] = ns[key].source;
|
||||
}
|
||||
|
||||
const importReadyEnglish = unflatten(importEnglish);
|
||||
const importReadyGerman = unflatten(importGerman);
|
||||
|
||||
console.log(importReadyEnglish);
|
||||
console.log(importReadyGerman);
|
||||
});
|
||||
}
|
||||
|
||||
execute().then();
|
||||
|
||||
4127
tools/auto-i18n/import.xliff
Normal file
4127
tools/auto-i18n/import.xliff
Normal file
File diff suppressed because it is too large
Load Diff
4127
tools/auto-i18n/redaction-en-to-de.xliff
Normal file
4127
tools/auto-i18n/redaction-en-to-de.xliff
Normal file
File diff suppressed because it is too large
Load Diff
4295
tools/auto-i18n/test.xml
Normal file
4295
tools/auto-i18n/test.xml
Normal file
File diff suppressed because it is too large
Load Diff
14
yarn.lock
14
yarn.lock
@ -14130,6 +14130,20 @@ ws@^8.1.0:
|
||||
resolved "https://registry.yarnpkg.com/ws/-/ws-8.3.0.tgz#7185e252c8973a60d57170175ff55fdbd116070d"
|
||||
integrity sha512-Gs5EZtpqZzLvmIM59w4igITU57lrtYVFneaa434VROv4thzJyV6UjIL3D42lslWlI+D4KzLYnxSwtfuiO79sNw==
|
||||
|
||||
xliff@^6.0.0:
|
||||
version "6.0.0"
|
||||
resolved "https://registry.yarnpkg.com/xliff/-/xliff-6.0.0.tgz#4f32ec481e6272af0020cbe6b1d57030647bec8d"
|
||||
integrity sha512-N058dhmntriq/8BZw8HGWuseFoBjT+hRq0ETi4i+ioPraSay0LkpSr8lW7pB7NdbulqrYoA7Uu0X8t+Plu7GCQ==
|
||||
dependencies:
|
||||
xml-js "1.6.11"
|
||||
|
||||
xml-js@1.6.11:
|
||||
version "1.6.11"
|
||||
resolved "https://registry.yarnpkg.com/xml-js/-/xml-js-1.6.11.tgz#927d2f6947f7f1c19a316dd8eea3614e8b18f8e9"
|
||||
integrity sha512-7rVi2KMfwfWFl+GpPg6m80IVMWXLRjO+PxTq7V2CDhoGak0wzYzFgUY2m4XJ47OGdXd8eLE8EmwfAmdjw7lC1g==
|
||||
dependencies:
|
||||
sax "^1.2.4"
|
||||
|
||||
xml-name-validator@^3.0.0:
|
||||
version "3.0.0"
|
||||
resolved "https://registry.yarnpkg.com/xml-name-validator/-/xml-name-validator-3.0.0.tgz#6ae73e06de4d8c6e47f9fb181f78d648ad457c6a"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user