48 lines
981 B
JavaScript
48 lines
981 B
JavaScript
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
|
|
module.exports = {
|
|
input: [
|
|
'src/**/*.{js,ejs}'
|
|
],
|
|
output: './',
|
|
options: {
|
|
debug: false,
|
|
func: {
|
|
list: ['i18next.t', 'i18n.t', 'this.i18n.tr'],
|
|
extensions: ['.js', '.ejs']
|
|
},
|
|
lngs: ['en', 'it', 'de'],
|
|
ns: [
|
|
'translation'
|
|
],
|
|
defaultLng: 'en',
|
|
defaultNs: 'translation',
|
|
resource: {
|
|
loadPath: 'i18n/{{lng}}.json',
|
|
savePath: 'i18n/{{lng}}.json',
|
|
jsonIndent: 4,
|
|
lineEnding: '\n'
|
|
},
|
|
nsSeparator: false, // namespace separator
|
|
keySeparator: false, // key separator
|
|
interpolation: {
|
|
prefix: '{{',
|
|
suffix: '}}'
|
|
},
|
|
removeUnusedKeys: true
|
|
},
|
|
transform: function customTransform(file, enc, done) {
|
|
const {ext} = path.parse(file.path);
|
|
const content = fs.readFileSync(file.path, enc);
|
|
if (ext === '.js' || ext === '.ejs') {
|
|
let p = this.parser;
|
|
p.parseFuncFromString(content, function(key) {
|
|
p.set(key, '⚠ ' + key + ' ⚠');
|
|
});
|
|
}
|
|
done();
|
|
}
|
|
};
|