build: package browser extension locale catalogs
This commit is contained in:
@@ -38,6 +38,13 @@ function copyIcons(destRoot) {
|
||||
}
|
||||
}
|
||||
|
||||
function copyLocalization(destRoot) {
|
||||
copy(path.join(shared, 'i18n.js'), path.join(destRoot, 'i18n.js'));
|
||||
for (const locale of ['en', 'ru']) {
|
||||
copy(path.join(shared, 'locales', `${locale}.json`), path.join(destRoot, 'locales', `${locale}.json`));
|
||||
}
|
||||
}
|
||||
|
||||
rm(dist);
|
||||
|
||||
const chromiumDist = path.join(dist, 'chromium');
|
||||
@@ -47,18 +54,21 @@ concat([
|
||||
path.join(shared, 'protocol.js'),
|
||||
path.join(shared, 'api.js'),
|
||||
path.join(shared, 'queue.js'),
|
||||
path.join(shared, 'i18n.js'),
|
||||
path.join(shared, 'background.js'),
|
||||
], path.join(chromiumDist, 'background.js'));
|
||||
copyPopup(chromiumDist);
|
||||
copyIcons(chromiumDist);
|
||||
copyLocalization(chromiumDist);
|
||||
|
||||
const firefoxDist = path.join(dist, 'firefox');
|
||||
mkdir(firefoxDist);
|
||||
copy(path.join(root, 'firefox', 'manifest.json'), path.join(firefoxDist, 'manifest.json'));
|
||||
for (const name of ['protocol.js', 'api.js', 'queue.js', 'background.js']) {
|
||||
for (const name of ['protocol.js', 'api.js', 'queue.js', 'i18n.js', 'background.js']) {
|
||||
copy(path.join(shared, name), path.join(firefoxDist, name));
|
||||
}
|
||||
copyPopup(firefoxDist);
|
||||
copyIcons(firefoxDist);
|
||||
copyLocalization(firefoxDist);
|
||||
|
||||
console.log('built dist/chromium and dist/firefox');
|
||||
|
||||
@@ -34,9 +34,9 @@ const browser = {
|
||||
},
|
||||
},
|
||||
contextMenus: {
|
||||
removeAll(callback) {
|
||||
removeAll() {
|
||||
menuTitles = [];
|
||||
if (callback) callback();
|
||||
return Promise.resolve();
|
||||
},
|
||||
create(item) {
|
||||
menuTitles.push(item.title);
|
||||
|
||||
@@ -33,6 +33,18 @@ assert.strictEqual(tEn('error.value', { error: 'offline' }), 'Error: offline');
|
||||
assert.strictEqual(tRu('missing', null, 'Fallback'), 'Fallback');
|
||||
assert.strictEqual(tRu('missing.key'), 'missing.key');
|
||||
|
||||
const dist = path.join(root, 'dist');
|
||||
if (fs.existsSync(dist)) {
|
||||
for (const target of ['chromium', 'firefox']) {
|
||||
for (const relativePath of ['i18n.js', 'locales/en.json', 'locales/ru.json']) {
|
||||
assert.ok(
|
||||
fs.existsSync(path.join(dist, target, relativePath)),
|
||||
`${target} build is missing ${relativePath}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
i18n.loadCatalogs((locale) => Promise.resolve(locale === 'ru' ? ru : en))
|
||||
.then((catalogs) => {
|
||||
assert.strictEqual(catalogs.en, en);
|
||||
|
||||
Reference in New Issue
Block a user