i18n fix
This commit is contained in:
parent
e3c9d6d531
commit
d70cb0468f
@ -25,6 +25,7 @@ export class LanguageService {
|
|||||||
} else {
|
} else {
|
||||||
defaultLang = 'en';
|
defaultLang = 'en';
|
||||||
}
|
}
|
||||||
|
console.log(defaultLang);
|
||||||
document.documentElement.lang = defaultLang;
|
document.documentElement.lang = defaultLang;
|
||||||
this._translateService.setDefaultLang(defaultLang);
|
this._translateService.setDefaultLang(defaultLang);
|
||||||
this._translateService.use(defaultLang).toPromise().then();
|
this._translateService.use(defaultLang).toPromise().then();
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"ADMIN_CONTACT_NAME": null,
|
"ADMIN_CONTACT_NAME": null,
|
||||||
"ADMIN_CONTACT_URL": null,
|
"ADMIN_CONTACT_URL": null,
|
||||||
"API_URL": "https://qa3.iqser.cloud/redaction-gateway-v1",
|
"API_URL": "https://dev-06.iqser.cloud/redaction-gateway-v1",
|
||||||
"APP_NAME": "RedactManager",
|
"APP_NAME": "RedactManager",
|
||||||
"AUTO_READ_TIME": 1.5,
|
"AUTO_READ_TIME": 1.5,
|
||||||
"BACKEND_APP_VERSION": "4.4.40",
|
"BACKEND_APP_VERSION": "4.4.40",
|
||||||
@ -17,7 +17,7 @@
|
|||||||
"MAX_RETRIES_ON_SERVER_ERROR": 3,
|
"MAX_RETRIES_ON_SERVER_ERROR": 3,
|
||||||
"OAUTH_CLIENT_ID": "redaction",
|
"OAUTH_CLIENT_ID": "redaction",
|
||||||
"OAUTH_IDP_HINT": null,
|
"OAUTH_IDP_HINT": null,
|
||||||
"OAUTH_URL": "https://qa3.iqser.cloud/auth/realms/redaction",
|
"OAUTH_URL": "https://dev-06.iqser.cloud/auth/realms/redaction",
|
||||||
"RECENT_PERIOD_IN_HOURS": 24,
|
"RECENT_PERIOD_IN_HOURS": 24,
|
||||||
"SELECTION_MODE": "structural"
|
"SELECTION_MODE": "structural"
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -82,6 +82,7 @@
|
|||||||
"@types/node": "16.9.1",
|
"@types/node": "16.9.1",
|
||||||
"@typescript-eslint/eslint-plugin": "4.33.0",
|
"@typescript-eslint/eslint-plugin": "4.33.0",
|
||||||
"@typescript-eslint/parser": "4.33.0",
|
"@typescript-eslint/parser": "4.33.0",
|
||||||
|
"axios": "^0.24.0",
|
||||||
"cypress": "^6.9.1",
|
"cypress": "^6.9.1",
|
||||||
"cypress-file-upload": "^5.0.8",
|
"cypress-file-upload": "^5.0.8",
|
||||||
"cypress-keycloak": "^1.7.0",
|
"cypress-keycloak": "^1.7.0",
|
||||||
|
|||||||
1089
tools/auto-i18n/de-flat.json
Normal file
1089
tools/auto-i18n/de-flat.json
Normal file
File diff suppressed because it is too large
Load Diff
75
tools/auto-i18n/unflatten.js
Normal file
75
tools/auto-i18n/unflatten.js
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
const fs = require('fs');
|
||||||
|
const axios = require('axios');
|
||||||
|
|
||||||
|
function flatten(data) {
|
||||||
|
const result = {};
|
||||||
|
|
||||||
|
function recurse(cur, prop) {
|
||||||
|
if (Object(cur) !== cur) {
|
||||||
|
result[prop] = cur;
|
||||||
|
} else if (Array.isArray(cur)) {
|
||||||
|
for (let i = 0, l = cur.length; i < l; i++) recurse(cur[i], prop + '[' + i + ']');
|
||||||
|
if (l === 0) result[prop] = [];
|
||||||
|
} else {
|
||||||
|
let isEmpty = true;
|
||||||
|
for (const p in cur) {
|
||||||
|
isEmpty = false;
|
||||||
|
recurse(cur[p], prop ? prop + '.' + p : p);
|
||||||
|
}
|
||||||
|
if (isEmpty && prop) result[prop] = {};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
recurse(data, '');
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
function unflatten(data) {
|
||||||
|
if (Object(data) !== data || Array.isArray(data)) return data;
|
||||||
|
const regex = /\.?([^.\[\]]+)|\[(\d+)\]/g,
|
||||||
|
resultholder = {};
|
||||||
|
for (const p in data) {
|
||||||
|
let cur = resultholder,
|
||||||
|
prop = '',
|
||||||
|
m;
|
||||||
|
while ((m = regex.exec(p))) {
|
||||||
|
cur = cur[prop] || (cur[prop] = m[2] ? [] : {});
|
||||||
|
prop = m[2] || m[1];
|
||||||
|
}
|
||||||
|
cur[prop] = data[p];
|
||||||
|
}
|
||||||
|
return resultholder[''] || resultholder;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function execute() {
|
||||||
|
const flatGerman = JSON.parse(fs.readFileSync('de-flat.json', 'utf-8'));
|
||||||
|
|
||||||
|
const english = JSON.parse(fs.readFileSync('./../../apps/red-ui/src/assets/i18n/en.json', 'utf-8'));
|
||||||
|
|
||||||
|
const flatEnglish = flatten(english);
|
||||||
|
|
||||||
|
const apiKey = 'AIzaSyBiqNTundSKFjAJnSb4wSVLDU6w0Kv651M';
|
||||||
|
|
||||||
|
for (const key of Object.keys(flatEnglish)) {
|
||||||
|
if (!flatGerman[key]) {
|
||||||
|
const value = flatEnglish[key];
|
||||||
|
const apiUrl = `https://www.googleapis.com/language/translate/v2?key=${apiKey}&q=${value}&source=en&target=de`;
|
||||||
|
|
||||||
|
const response = await axios.get(apiUrl);
|
||||||
|
let translated = flatEnglish[key];
|
||||||
|
try {
|
||||||
|
translated = response.data.data.translations[0].translatedText;
|
||||||
|
} catch (e) {}
|
||||||
|
console.log('missing: ' + key + ' -> ' + flatEnglish[key] + ' -> ' + translated);
|
||||||
|
flatGerman[key] = translated;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const german = { ...flatEnglish, ...flatGerman };
|
||||||
|
|
||||||
|
const finalGerman = unflatten(german);
|
||||||
|
|
||||||
|
fs.writeFileSync('./../../apps/red-ui/src/assets/i18n/de.json', JSON.stringify(finalGerman));
|
||||||
|
}
|
||||||
|
|
||||||
|
execute().then();
|
||||||
12
yarn.lock
12
yarn.lock
@ -3982,6 +3982,13 @@ axios@^0.18.0:
|
|||||||
follow-redirects "1.5.10"
|
follow-redirects "1.5.10"
|
||||||
is-buffer "^2.0.2"
|
is-buffer "^2.0.2"
|
||||||
|
|
||||||
|
axios@^0.24.0:
|
||||||
|
version "0.24.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/axios/-/axios-0.24.0.tgz#804e6fa1e4b9c5288501dd9dff56a7a0940d20d6"
|
||||||
|
integrity sha512-Q6cWsys88HoPgAaFAVUb0WpPk0O8iTeisR9IMqy9G8AbO4NlpVknrnQS03zzF9PGAWgO3cgletO3VjV/P7VztA==
|
||||||
|
dependencies:
|
||||||
|
follow-redirects "^1.14.4"
|
||||||
|
|
||||||
axobject-query@^2.2.0:
|
axobject-query@^2.2.0:
|
||||||
version "2.2.0"
|
version "2.2.0"
|
||||||
resolved "https://registry.yarnpkg.com/axobject-query/-/axobject-query-2.2.0.tgz#943d47e10c0b704aa42275e20edf3722648989be"
|
resolved "https://registry.yarnpkg.com/axobject-query/-/axobject-query-2.2.0.tgz#943d47e10c0b704aa42275e20edf3722648989be"
|
||||||
@ -7323,6 +7330,11 @@ follow-redirects@^1.0.0:
|
|||||||
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.13.0.tgz#b42e8d93a2a7eea5ed88633676d6597bc8e384db"
|
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.13.0.tgz#b42e8d93a2a7eea5ed88633676d6597bc8e384db"
|
||||||
integrity sha512-aq6gF1BEKje4a9i9+5jimNFIpq4Q1WiwBToeRK5NvZBd/TRsmW8BsJfOEGkr76TbOyPVD3OVDN910EcUNtRYEA==
|
integrity sha512-aq6gF1BEKje4a9i9+5jimNFIpq4Q1WiwBToeRK5NvZBd/TRsmW8BsJfOEGkr76TbOyPVD3OVDN910EcUNtRYEA==
|
||||||
|
|
||||||
|
follow-redirects@^1.14.4:
|
||||||
|
version "1.14.5"
|
||||||
|
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.5.tgz#f09a5848981d3c772b5392309778523f8d85c381"
|
||||||
|
integrity sha512-wtphSXy7d4/OR+MvIFbCVBDzZ5520qV8XfPklSN5QtxuMUJZ+b0Wnst1e1lCDocfzuCkHqj8k0FpZqO+UIaKNA==
|
||||||
|
|
||||||
for-in@^1.0.2:
|
for-in@^1.0.2:
|
||||||
version "1.0.2"
|
version "1.0.2"
|
||||||
resolved "https://registry.yarnpkg.com/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80"
|
resolved "https://registry.yarnpkg.com/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user