improved locale

This commit is contained in:
antelle 2021-05-14 18:50:45 +02:00
parent a035796503
commit 27b8633bc2
No known key found for this signature in database
GPG Key ID: 63C9777AAB7C563C
5 changed files with 800 additions and 817 deletions

File diff suppressed because it is too large Load Diff

View File

@ -123,7 +123,7 @@
},
"scripts": {
"start": "grunt",
"test": "mocha --require ts-node/register --require tsconfig-paths/register --recursive --reporter spec test/**/*.ts",
"test": "mocha --require ts-node/register --require tsconfig-paths/register --require test/init.ts --recursive --reporter spec 'test/**/*.spec.ts'",
"eslint": "grunt eslint",
"build-beta": "grunt --beta && cp dist/index.html ../keeweb-beta/index.html && cd ../keeweb-beta && git add index.html && git commit -a -m 'beta' && git push origin master",
"electron": "cross-env KEEWEB_IS_PORTABLE=0 ELECTRON_DISABLE_SECURITY_WARNINGS=1 KEEWEB_EMULATE_HARDWARE_ENCRYPTION=persistent KEEWEB_HTML_PATH=http://localhost:8085 electron desktop --no-sandbox",

View File

@ -3,6 +3,9 @@
const Module = require('module');
import * as path from 'path';
import * as fs from 'fs';
import { Crypto } from '@peculiar/webcrypto';
global.crypto = new Crypto();
const appBasePath = path.resolve(__dirname, '..', 'app');
@ -30,8 +33,8 @@ function requireTextFile(filePath: string): () => { default: string } {
}
const knownModules: { [name: string]: any } = {
'public-key.pem': requireTextFile('keys/public-key.pem'),
'public-key-new.pem': requireTextFile('keys/public-key-new.pem')
'public-key.pem': requireTextFile('app/resources/public-key.pem'),
'public-key-new.pem': requireTextFile('app/resources/public-key-new.pem')
};
const originalRequire = Module.prototype.require;

View File

@ -1,3 +0,0 @@
import { Crypto } from '@peculiar/webcrypto';
global.crypto = new Crypto();

View File

@ -15,21 +15,25 @@ const generatedLines = [];
for (const [name, value] of Object.entries(localeData)) {
if (value.includes('{}')) {
generatedLines.push(`${name}: strWithReplace('${name}')`);
generatedLines.push(`${name}: withReplace('${name}')`);
} else {
generatedLines.push(`${name}: str('${name}')`);
generatedLines.push(`get ${name}(): string { return get('${name}'); }`);
}
}
const generatedCode = `// this code is generated using npm run generate-locale
${generatedLines.map((line) => ` ${line}`).join(',\n')}\n`;
${generatedLines.map((line) => ` ${line}`).join(',\n')}
// end of generated code`;
let found = false;
const replacedSourceCode = sourceCode.replace(/\/\/ this code is generated [^}]+/gm, () => {
found = true;
return generatedCode;
});
const replacedSourceCode = sourceCode.replace(
/\/\/ this code is generated [\s\S]*?^\s*\/\/ end of generated code/gm,
() => {
found = true;
return generatedCode;
}
);
if (!found) {
throw new Error('Not found');