mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-11 12:57:29 -08:00
🔥 Remove unused translations output
This commit is contained in:
parent
d3519e44d0
commit
d006234790
|
@ -13,13 +13,12 @@ function copyIcons() {
|
||||||
return src('credentials/**/*.{png,svg}').pipe(dest('dist/credentials'));
|
return src('credentials/**/*.{png,svg}').pipe(dest('dist/credentials'));
|
||||||
}
|
}
|
||||||
|
|
||||||
task('build:translations', writeHeadersAndTranslations);
|
task('build:translations', writeHeaders);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write all node translation headers at `/dist/nodes/headers.js` and write
|
* Write all node translation headers at `/dist/nodes/headers.js`.
|
||||||
* each node translation at `/dist/nodes/<node>/translations/<language>.js`
|
|
||||||
*/
|
*/
|
||||||
function writeHeadersAndTranslations(done) {
|
function writeHeaders(done) {
|
||||||
const { N8N_DEFAULT_LOCALE: locale } = process.env;
|
const { N8N_DEFAULT_LOCALE: locale } = process.env;
|
||||||
|
|
||||||
log(`Default locale set to: ${colorize(PURPLE_ANSI_COLOR_CODE, locale || 'en')}`);
|
log(`Default locale set to: ${colorize(PURPLE_ANSI_COLOR_CODE, locale || 'en')}`);
|
||||||
|
@ -30,7 +29,7 @@ function writeHeadersAndTranslations(done) {
|
||||||
};
|
};
|
||||||
|
|
||||||
const paths = getTranslationPaths();
|
const paths = getTranslationPaths();
|
||||||
const { headers, translations } = getHeadersAndTranslations(paths);
|
const headers = getHeaders(paths);
|
||||||
|
|
||||||
const headersDestinationPath = path.join(__dirname, 'dist', 'nodes', 'headers.js');
|
const headersDestinationPath = path.join(__dirname, 'dist', 'nodes', 'headers.js');
|
||||||
|
|
||||||
|
@ -39,13 +38,6 @@ function writeHeadersAndTranslations(done) {
|
||||||
log('Headers translation file written to:');
|
log('Headers translation file written to:');
|
||||||
log(headersDestinationPath, { bulletpoint: true });
|
log(headersDestinationPath, { bulletpoint: true });
|
||||||
|
|
||||||
translations.forEach(t => {
|
|
||||||
writeDestinationFile(t.destinationPath, t.content);
|
|
||||||
});
|
|
||||||
|
|
||||||
log('Main translation files written to:');
|
|
||||||
translations.forEach(t => log(t.destinationPath, { bulletpoint: true }))
|
|
||||||
|
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,7 +74,7 @@ function getTranslationPaths() {
|
||||||
}, []);
|
}, []);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getHeadersAndTranslations(paths) {
|
function getHeaders(paths) {
|
||||||
return paths.reduce((acc, cur) => {
|
return paths.reduce((acc, cur) => {
|
||||||
const translation = require(cur.source);
|
const translation = require(cur.source);
|
||||||
const nodeTypes = Object.keys(translation);
|
const nodeTypes = Object.keys(translation);
|
||||||
|
@ -91,17 +83,12 @@ function getHeadersAndTranslations(paths) {
|
||||||
const { header } = translation[nodeType];
|
const { header } = translation[nodeType];
|
||||||
|
|
||||||
if (isValidHeader(header, ALLOWED_HEADER_KEYS)) {
|
if (isValidHeader(header, ALLOWED_HEADER_KEYS)) {
|
||||||
acc.headers[nodeType] = header;
|
acc[nodeType] = header;
|
||||||
}
|
}
|
||||||
|
|
||||||
acc.translations.push({
|
|
||||||
destinationPath: cur.destination,
|
|
||||||
content: translation,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return acc;
|
return acc;
|
||||||
}, { headers: {}, translations: [] });
|
}, {});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue