Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function i18nScanner(params) { // eslint-disable-line
const parser = new Parser({
keySeparator: '>',
nsSeparator: '|',
});
const sourceJSON = fs.readFileSync(params.outputFilePath, 'utf8');
let translationsSource;
try {
translationsSource = JSON.parse(sourceJSON);
} catch (e) {
process.stderr.write(`i18nScanner: ${e}\n`);
return;
}
const customHandler = function (key, options) {
const value = translationsSource[key] || key;
if (options.context) {
gulp.task('i18next:web', () => {
return gulp.src(webConfig.src)
.pipe(sort()) // Sort files in stream by path
.pipe(i18nextScanner(webConfig.options, customTransform))
.pipe(gulp.dest(webConfig.dest));
});
};
function parse(config, oldTranslations) {
const parser = new Parser({
keySeparator: '>',
nsSeparator: '|',
});
config.files
.map(filePattern => glob.sync(filePattern, {}))
.reduce((accumulator, files) => [...accumulator, ...files], [])
.forEach(file => {
const content = fs.readFileSync(file, 'utf-8');
parser.parseFuncFromString(
content,
{ list: config.translationFunctionNames },
(key, options) => customHandler(parser, oldTranslations, key, options)
);
});
gulp.task('i18next:app', () => {
return gulp.src(appConfig.src)
.pipe(i18nextScanner(appConfig.options, customTransform))
.pipe(gulp.dest(appConfig.dest));
});
gulp.task('i18next:web', () => {