Skip to content

Commit

Permalink
replace i18next-parser with i18next-scanner
Browse files Browse the repository at this point in the history
  • Loading branch information
glekner committed Apr 6, 2022
1 parent 14e0f08 commit ac982a2
Show file tree
Hide file tree
Showing 5 changed files with 524 additions and 506 deletions.
9 changes: 0 additions & 9 deletions i18next-parser.config.js

This file was deleted.

59 changes: 59 additions & 0 deletions i18next-scanner.config.js
@@ -0,0 +1,59 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const fs = require('fs');
const path = require('path');
const typescript = require('typescript');

module.exports = {
input: ['src/**/*.{js,jsx,ts,tsx}'],
output: './',
options: {
debug: true,
func: {
list: ['i18next.t', 'i18n.t', 't'],
extensions: ['.js', '.jsx', '.ts', '.tsx'],
},
trans: {
component: 'Trans',
extensions: [],
fallbackKey: function (ns, value) {
return value;
},
},
lngs: ['en'],
ns: ['plugin__kubevirt-plugin'],
defaultLng: 'en',
defaultNs: 'plugin__kubevirt-plugin',
resource: {
loadPath: 'locales/{{lng}}/{{ns}}.json',
savePath: 'locales/{{lng}}/{{ns}}.json',
jsonIndent: 2,
lineEnding: '\n',
},
nsSeparator: '~',
keySeparator: false,
interpolation: {
prefix: '{{',
suffix: '}}',
},
defaultValue: function (lng, ns, key) {
return key;
},
},
transform: function (file, enc, done) {
const { base, ext } = path.parse(file.path);
if (['.ts', '.tsx'].includes(ext) && !base.includes('.d.ts')) {
const content = fs.readFileSync(file.path, enc);

const { outputText } = typescript.transpileModule(content, {
compilerOptions: {
target: 'es2016',
},
fileName: path.basename(file.path),
});

this.parser.parseTransFromString(outputText);
}

done();
},
};

0 comments on commit ac982a2

Please sign in to comment.