TS func refactoring
This commit is contained in:
parent
8f9db655ec
commit
8ff637a57e
4 changed files with 28 additions and 37 deletions
11
ui/src/env.ts
vendored
11
ui/src/env.ts
vendored
|
@ -1,6 +1,5 @@
|
||||||
let host = `${window.location.hostname}`;
|
const host = `${window.location.hostname}`;
|
||||||
let port = `${window.location.port == '4444' ? '8536' : window.location.port}`;
|
const port = `${window.location.port == '4444' ? '8536' : window.location.port}`;
|
||||||
let endpoint = `${host}:${port}`;
|
const endpoint = `${host}:${port}`;
|
||||||
export let wsUri = `${
|
|
||||||
window.location.protocol == 'https:' ? 'wss://' : 'ws://'
|
export const wsUri = `${window.location.protocol == 'https:' ? 'wss://' : 'ws://'}${endpoint}/api/v1/ws`;
|
||||||
}${endpoint}/api/v1/ws`;
|
|
||||||
|
|
9
ui/src/i18next.ts
vendored
9
ui/src/i18next.ts
vendored
|
@ -27,10 +27,7 @@ const resources = {
|
||||||
fi,
|
fi,
|
||||||
};
|
};
|
||||||
|
|
||||||
function format(value: any, format: any, lng: any) {
|
const format = (value, format, lng) => format === 'uppercase' ? value.toUpperCase() : value;
|
||||||
if (format === 'uppercase') return value.toUpperCase();
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
i18next.init({
|
i18next.init({
|
||||||
debug: false,
|
debug: false,
|
||||||
|
@ -40,9 +37,7 @@ i18next.init({
|
||||||
lng: getLanguage(),
|
lng: getLanguage(),
|
||||||
fallbackLng: 'en',
|
fallbackLng: 'en',
|
||||||
resources,
|
resources,
|
||||||
interpolation: {
|
interpolation: { format },
|
||||||
format: format,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export { i18next as i18n, resources };
|
export { i18next as i18n, resources };
|
||||||
|
|
2
ui/src/version.ts
vendored
2
ui/src/version.ts
vendored
|
@ -1 +1 @@
|
||||||
export let version: string = 'v0.6.5';
|
export const version: string = 'v0.6.5';
|
||||||
|
|
43
ui/translation_report.ts
vendored
43
ui/translation_report.ts
vendored
|
@ -11,24 +11,26 @@ import { it } from './src/translations/it';
|
||||||
import { fi } from './src/translations/fi';
|
import { fi } from './src/translations/fi';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
|
|
||||||
let readmePath = '../README.md';
|
const readmePath = '../README.md';
|
||||||
|
|
||||||
let open = '<!-- translations -->';
|
const open = '<!-- translations -->';
|
||||||
let close = '<!-- translationsstop -->';
|
const close = '<!-- translationsstop -->';
|
||||||
|
|
||||||
let readmeTxt = fs.readFileSync(readmePath, { encoding: 'utf8' });
|
const readmeTxt = fs.readFileSync(readmePath, { encoding: 'utf8' });
|
||||||
|
|
||||||
let before = readmeTxt.split(open)[0];
|
const before = readmeTxt.split(open)[0];
|
||||||
let after = readmeTxt.split(close)[1];
|
const after = readmeTxt.split(close)[1];
|
||||||
|
|
||||||
let report = buildReport();
|
const report = buildReport();
|
||||||
|
|
||||||
let alteredReadmeTxt = `${before}${open}\n\n${report}\n${close}${after}`;
|
const alteredReadmeTxt = `${before}${open}\n\n${report}\n${close}${after}`;
|
||||||
|
|
||||||
fs.writeFileSync(readmePath, alteredReadmeTxt);
|
fs.writeFileSync(readmePath, alteredReadmeTxt);
|
||||||
|
|
||||||
|
const difference = (a: Array<string>, b: Array<string>): Array<string> => a.filter(x => !b.includes(x));
|
||||||
|
|
||||||
function buildReport(): string {
|
function buildReport(): string {
|
||||||
let files = [
|
const files = [
|
||||||
{ t: de, n: 'de' },
|
{ t: de, n: 'de' },
|
||||||
{ t: eo, n: 'eo' },
|
{ t: eo, n: 'eo' },
|
||||||
{ t: es, n: 'es' },
|
{ t: es, n: 'es' },
|
||||||
|
@ -40,21 +42,16 @@ function buildReport(): string {
|
||||||
{ t: sv, n: 'sv' },
|
{ t: sv, n: 'sv' },
|
||||||
{ t: zh, n: 'zh' },
|
{ t: zh, n: 'zh' },
|
||||||
];
|
];
|
||||||
let masterKeys = Object.keys(en.translation);
|
const masterKeys = Object.keys(en.translation);
|
||||||
|
|
||||||
let report = 'lang | done | missing\n';
|
const report = 'lang | done | missing\n' +
|
||||||
report += '--- | --- | ---\n';
|
'--- | --- | ---\n' +
|
||||||
|
files.map(file => {
|
||||||
for (let file of files) {
|
const keys = Object.keys(file.t.translation);
|
||||||
let keys = Object.keys(file.t.translation);
|
const pct: number = (keys.length / masterKeys.length) * 100;
|
||||||
let pct: number = (keys.length / masterKeys.length) * 100;
|
const missing = difference(masterKeys, keys);
|
||||||
let missing = difference(masterKeys, keys);
|
return `${file.n} | ${pct.toFixed(0)}% | ${missing}`;
|
||||||
report += `${file.n} | ${pct.toFixed(0)}% | ${missing} \n`;
|
}).join("\n");
|
||||||
}
|
|
||||||
|
|
||||||
return report;
|
return report;
|
||||||
}
|
}
|
||||||
|
|
||||||
function difference(a: Array<string>, b: Array<string>): Array<string> {
|
|
||||||
return a.filter(x => !b.includes(x));
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue