checking "KeeWeb" spelling
This commit is contained in:
parent
c390a3ac75
commit
77308c4a30
|
@ -16,10 +16,7 @@ const PHRASE_COUNT_THRESHOLD_PERCENT = 75;
|
||||||
const ts = Math.floor(new Date() / 1000);
|
const ts = Math.floor(new Date() / 1000);
|
||||||
|
|
||||||
const hashStr = ts + keys.secret;
|
const hashStr = ts + keys.secret;
|
||||||
const hash = crypto
|
const hash = crypto.createHash('md5').update(hashStr).digest('hex');
|
||||||
.createHash('md5')
|
|
||||||
.update(hashStr)
|
|
||||||
.digest('hex');
|
|
||||||
const urlParams = {
|
const urlParams = {
|
||||||
'api_key': keys.public,
|
'api_key': keys.public,
|
||||||
'timestamp': ts,
|
'timestamp': ts,
|
||||||
|
@ -36,10 +33,10 @@ const publicKey = fs
|
||||||
.replace(/\n/g, '');
|
.replace(/\n/g, '');
|
||||||
const defaultCountries = { 'SE': 'sv' };
|
const defaultCountries = { 'SE': 'sv' };
|
||||||
|
|
||||||
module.exports = function() {
|
module.exports = function () {
|
||||||
return new Promise(resolve => {
|
return new Promise((resolve) => {
|
||||||
loadLanguages(languages =>
|
loadLanguages((languages) =>
|
||||||
loadTranslations(translations => resolve(processData(languages, translations)))
|
loadTranslations((translations) => resolve(processData(languages, translations)))
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -52,16 +49,16 @@ module.exports = function() {
|
||||||
API_URL_LANGUAGES.replace(':project_id', PROJECT_ID) +
|
API_URL_LANGUAGES.replace(':project_id', PROJECT_ID) +
|
||||||
'?' +
|
'?' +
|
||||||
Object.keys(urlParams)
|
Object.keys(urlParams)
|
||||||
.map(param => param + '=' + urlParams[param])
|
.map((param) => param + '=' + urlParams[param])
|
||||||
.join('&');
|
.join('&');
|
||||||
https.get(url, res => {
|
https.get(url, (res) => {
|
||||||
if (res.statusCode !== 200) {
|
if (res.statusCode !== 200) {
|
||||||
console.error(`API error ${res.statusCode}`);
|
console.error(`API error ${res.statusCode}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
console.log('Response received, reading...');
|
console.log('Response received, reading...');
|
||||||
const data = [];
|
const data = [];
|
||||||
res.on('data', chunk => data.push(chunk));
|
res.on('data', (chunk) => data.push(chunk));
|
||||||
res.on('end', () => {
|
res.on('end', () => {
|
||||||
console.log('Data received, parsing...');
|
console.log('Data received, parsing...');
|
||||||
const json = Buffer.concat(data).toString('utf8');
|
const json = Buffer.concat(data).toString('utf8');
|
||||||
|
@ -81,16 +78,16 @@ module.exports = function() {
|
||||||
API_URL.replace(':project_id', PROJECT_ID) +
|
API_URL.replace(':project_id', PROJECT_ID) +
|
||||||
'?' +
|
'?' +
|
||||||
Object.keys(urlParams)
|
Object.keys(urlParams)
|
||||||
.map(param => param + '=' + urlParams[param])
|
.map((param) => param + '=' + urlParams[param])
|
||||||
.join('&');
|
.join('&');
|
||||||
https.get(url, res => {
|
https.get(url, (res) => {
|
||||||
if (res.statusCode !== 200) {
|
if (res.statusCode !== 200) {
|
||||||
console.error(`API error ${res.statusCode}`);
|
console.error(`API error ${res.statusCode}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
console.log('Response received, reading...');
|
console.log('Response received, reading...');
|
||||||
const data = [];
|
const data = [];
|
||||||
res.on('data', chunk => data.push(chunk));
|
res.on('data', (chunk) => data.push(chunk));
|
||||||
res.on('end', () => {
|
res.on('end', () => {
|
||||||
console.log('Data received, parsing...');
|
console.log('Data received, parsing...');
|
||||||
const json = Buffer.concat(data).toString('utf8');
|
const json = Buffer.concat(data).toString('utf8');
|
||||||
|
@ -133,7 +130,7 @@ module.exports = function() {
|
||||||
`[${lang}] ${langPhraseCount} / ${totalPhraseCount} (${percentage}%) -> ${action}`
|
`[${lang}] ${langPhraseCount} / ${totalPhraseCount} (${percentage}%) -> ${action}`
|
||||||
);
|
);
|
||||||
|
|
||||||
const langInfo = languages.data.filter(x => x.code === lang)[0];
|
const langInfo = languages.data.filter((x) => x.code === lang)[0];
|
||||||
const region = (defaultCountries[langInfo.region] || langInfo.region).toLowerCase();
|
const region = (defaultCountries[langInfo.region] || langInfo.region).toLowerCase();
|
||||||
const langName =
|
const langName =
|
||||||
langInfo.locale === region
|
langInfo.locale === region
|
||||||
|
@ -202,12 +199,23 @@ module.exports = function() {
|
||||||
);
|
);
|
||||||
errors++;
|
errors++;
|
||||||
}
|
}
|
||||||
|
const misspelledKeeWebRe = /(ke[^e]?web|k[^e]eweb)/gi;
|
||||||
|
if (misspelledKeeWebRe.test(text)) {
|
||||||
|
const textHl = text.replace(misspelledKeeWebRe, '\x1b[31m$1\x1b[0m');
|
||||||
|
console.error(`[${lang}] \x1b[31mERROR:{}\x1b[0m ${name}: ${textHl}`);
|
||||||
|
errors++;
|
||||||
|
}
|
||||||
|
if (text.match(/keeweb/gi)?.some((m) => m !== 'KeeWeb')) {
|
||||||
|
const textHl = text.replace(/(keeweb)/gi, '\x1b[31m$1\x1b[0m');
|
||||||
|
console.error(`[${lang}] \x1b[31mERROR:{}\x1b[0m ${name}: ${textHl}`);
|
||||||
|
errors++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
languageJson = JSON.stringify(languageTranslations, null, 2);
|
languageJson = JSON.stringify(languageTranslations, null, 2);
|
||||||
|
|
||||||
const data = Buffer.from(languageJson);
|
const data = Buffer.from(languageJson);
|
||||||
const signature = await sign(data).catch(e => {
|
const signature = await sign(data).catch((e) => {
|
||||||
console.log('Sign error', e);
|
console.log('Sign error', e);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue