|
|
|
@ -1,54 +1,51 @@
|
|
|
|
|
const fs = require('fs');
|
|
|
|
|
const chalk = require('chalk');
|
|
|
|
|
const fs = require("fs");
|
|
|
|
|
const chalk = require("chalk");
|
|
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
|
input: [
|
|
|
|
|
'app/**/*.{js,jsx}',
|
|
|
|
|
"app/**/*.{js,jsx}",
|
|
|
|
|
// Use ! to filter out files or directories
|
|
|
|
|
'!app/**/*.spec.{js,jsx}',
|
|
|
|
|
'!app/i18n/**',
|
|
|
|
|
'!**/node_modules/**',
|
|
|
|
|
"!app/**/*.spec.{js,jsx}",
|
|
|
|
|
"!app/i18n/**",
|
|
|
|
|
"!**/node_modules/**"
|
|
|
|
|
],
|
|
|
|
|
output: '.',
|
|
|
|
|
output: ".",
|
|
|
|
|
options: {
|
|
|
|
|
debug: true,
|
|
|
|
|
func: {
|
|
|
|
|
list: ['i18next.t', 'i18n.t', 't'],
|
|
|
|
|
extensions: ['.js', '.jsx']
|
|
|
|
|
list: ["i18next.t", "i18n.t", "t"],
|
|
|
|
|
extensions: [".js", ".jsx"]
|
|
|
|
|
},
|
|
|
|
|
trans: {
|
|
|
|
|
component: 'Trans',
|
|
|
|
|
i18nKey: 'i18nKey',
|
|
|
|
|
defaultsKey: 'defaults',
|
|
|
|
|
extensions: ['.js', '.jsx'],
|
|
|
|
|
component: "Trans",
|
|
|
|
|
i18nKey: "i18nKey",
|
|
|
|
|
defaultsKey: "defaults",
|
|
|
|
|
extensions: [".js", ".jsx"],
|
|
|
|
|
fallbackKey: function(ns, value) {
|
|
|
|
|
return value;
|
|
|
|
|
},
|
|
|
|
|
acorn: {
|
|
|
|
|
ecmaVersion: 10, // defaults to 10
|
|
|
|
|
sourceType: 'module', // defaults to 'module'
|
|
|
|
|
sourceType: "module" // defaults to 'module'
|
|
|
|
|
// Check out https://github.com/acornjs/acorn/tree/master/acorn#interface for additional options
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
lngs: ['en','fr','es'],
|
|
|
|
|
ns: [
|
|
|
|
|
'resource',
|
|
|
|
|
'common'
|
|
|
|
|
],
|
|
|
|
|
defaultLng: 'en',
|
|
|
|
|
defaultNs: 'resource',
|
|
|
|
|
defaultValue: '__STRING_NOT_TRANSLATED__',
|
|
|
|
|
lngs: ["en", "fr", "es"],
|
|
|
|
|
ns: ["resource", "common"],
|
|
|
|
|
defaultLng: "en",
|
|
|
|
|
defaultNs: "resource",
|
|
|
|
|
defaultValue: "__STRING_NOT_TRANSLATED__",
|
|
|
|
|
resource: {
|
|
|
|
|
loadPath: './public/locale/i18n/{{lng}}/{{ns}}.json',
|
|
|
|
|
savePath: './public/locale/i18n/{{lng}}/{{ns}}.json',
|
|
|
|
|
loadPath: "./public/locale/i18n/{{lng}}/{{ns}}.json",
|
|
|
|
|
savePath: "./public/locale/i18n/{{lng}}/{{ns}}.json",
|
|
|
|
|
jsonIndent: 2,
|
|
|
|
|
lineEnding: '\n'
|
|
|
|
|
lineEnding: "\n"
|
|
|
|
|
},
|
|
|
|
|
nsSeparator: false, // namespace separator
|
|
|
|
|
keySeparator: false, // key separator
|
|
|
|
|
interpolation: {
|
|
|
|
|
prefix: '{{',
|
|
|
|
|
suffix: '}}'
|
|
|
|
|
prefix: "{{",
|
|
|
|
|
suffix: "}}"
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
transform: function customTransform(file, enc, done) {
|
|
|
|
@ -57,16 +54,27 @@ module.exports = {
|
|
|
|
|
const content = fs.readFileSync(file.path, enc);
|
|
|
|
|
let count = 0;
|
|
|
|
|
|
|
|
|
|
parser.parseFuncFromString(content, { list: ['i18next._', 'i18next.__'] }, (key, options) => {
|
|
|
|
|
parser.set(key, Object.assign({}, options, {
|
|
|
|
|
parser.parseFuncFromString(
|
|
|
|
|
content,
|
|
|
|
|
{ list: ["i18next._", "i18next.__"] },
|
|
|
|
|
(key, options) => {
|
|
|
|
|
parser.set(
|
|
|
|
|
key,
|
|
|
|
|
Object.assign({}, options, {
|
|
|
|
|
nsSeparator: false,
|
|
|
|
|
keySeparator: false
|
|
|
|
|
}));
|
|
|
|
|
})
|
|
|
|
|
);
|
|
|
|
|
++count;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (count > 0) {
|
|
|
|
|
console.log(`i18next-scanner: count=${chalk.cyan(count)}, file=${chalk.yellow(JSON.stringify(file.relative))}`);
|
|
|
|
|
console.log(
|
|
|
|
|
`i18next-scanner: count=${chalk.cyan(count)}, file=${chalk.yellow(
|
|
|
|
|
JSON.stringify(file.relative)
|
|
|
|
|
)}`
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
done();
|
|
|
|
|