зеркало из https://github.com/mozilla/send.git
Generate production locales using 'compare-locales'
This commit is contained in:
Родитель
c9c7c3182c
Коммит
5effeb16d1
22
package.json
22
package.json
|
@ -46,13 +46,15 @@
|
|||
"license": "MPL-2.0",
|
||||
"repository": "mozilla/send",
|
||||
"availableLanguages": [
|
||||
"en-US",
|
||||
"zh-TW",
|
||||
"zh-CN",
|
||||
"cs",
|
||||
"cy",
|
||||
"de",
|
||||
"dsb",
|
||||
"en-US",
|
||||
"es-MX",
|
||||
"fr",
|
||||
"fy-NL",
|
||||
"de",
|
||||
"hsb",
|
||||
"hu",
|
||||
"it",
|
||||
"ja",
|
||||
|
@ -60,19 +62,14 @@
|
|||
"ms",
|
||||
"nb-NO",
|
||||
"nn-NO",
|
||||
"pt-PT",
|
||||
"pt-BR",
|
||||
"pt-PT",
|
||||
"ru",
|
||||
"sk",
|
||||
"sl",
|
||||
"dsb",
|
||||
"hsb",
|
||||
"es-CL",
|
||||
"es-ES",
|
||||
"es-MX",
|
||||
"sv-SE",
|
||||
"tr",
|
||||
"cy"
|
||||
"zh-CN",
|
||||
"zh-TW"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "npm-run-all build:*",
|
||||
|
@ -80,6 +77,7 @@
|
|||
"build:download": "browserify frontend/src/download.js -g uglifyify -o public/download.js",
|
||||
"build:version": "node scripts/version",
|
||||
"build:l10n": "cp node_modules/l20n/dist/web/l20n.min.js public",
|
||||
"get-prod-locales": "node scripts/get-prod-locales",
|
||||
"dev": "npm run build && npm start",
|
||||
"format": "prettier '{frontend/src/,scripts/,server/,test/**/!(bundle)}*.js' 'public/*.css' --single-quote --write",
|
||||
"lint": "npm-run-all lint:*",
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
const { exec } = require('child_process');
|
||||
const fs = require('fs');
|
||||
|
||||
const pkg = require('../package.json');
|
||||
const availableLanguages = pkg.availableLanguages.sort();
|
||||
|
||||
const compareLocales =
|
||||
'compare-locales l10n.toml . `ls public/locales` --data=json';
|
||||
|
||||
exec(compareLocales, (err, stdout, stderr) => {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
process.exit(1);
|
||||
}
|
||||
const missingLocales = (current, package) =>
|
||||
current.filter(locale => !package.includes(locale));
|
||||
const { summary } = JSON.parse(stdout);
|
||||
const locales = Object.keys(summary)
|
||||
.filter(locale => {
|
||||
const loc = summary[locale];
|
||||
const hasMissing = loc.hasOwnProperty('missing');
|
||||
const hasErrors = loc.hasOwnProperty('errors');
|
||||
return !hasMissing && !hasErrors;
|
||||
})
|
||||
.sort();
|
||||
|
||||
if (locales.join(',') !== availableLanguages.join(',')) {
|
||||
const missingLocales = missingLocales(locales, availableLanguages);
|
||||
console.log('current 100%:', JSON.stringify(locales));
|
||||
console.log('package.json:', JSON.stringify(availableLanguages));
|
||||
console.log('missing prod:', JSON.stringify(missingLocales));
|
||||
|
||||
if (process.argv.includes('--write')) {
|
||||
const pkgPath = require.resolve('../package.json');
|
||||
pkg.availableLanguages = locales;
|
||||
const str = JSON.stringify(pkg, null, 2) + '\n';
|
||||
console.log('Updating /package.json availableLanguages');
|
||||
fs.writeFileSync(pkgPath, str, 'utf-8');
|
||||
}
|
||||
} else {
|
||||
console.log('Production locales are up to date!');
|
||||
}
|
||||
});
|
Загрузка…
Ссылка в новой задаче