mirror of https://github.com/keeweb/keeweb.git
improved locale
This commit is contained in:
parent
a035796503
commit
27b8633bc2
File diff suppressed because it is too large
Load Diff
|
@ -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",
|
||||
|
|
|
@ -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;
|
|
@ -1,3 +0,0 @@
|
|||
import { Crypto } from '@peculiar/webcrypto';
|
||||
|
||||
global.crypto = new Crypto();
|
|
@ -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');
|
||||
|
|
Loading…
Reference in New Issue