You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi I'm trying to implement i18next-scanner. So far I have npm installed i18next-scanner, created a config and npm script in my package.json. I have tested the config, it runs and creates a i18n folder in my project root with my project locales, but the json files are empty.
In my public folder -> locales -> {{lng}} -> {{ns}} are around 100 dummy translations, that have been translated with locize - their save missing feature could find all my non translated words. Sooo I don't really know what is wrong.
Can anyone help me out? If you need more information, just ask!
Hi I'm trying to implement i18next-scanner. So far I have npm installed i18next-scanner, created a config and npm script in my package.json. I have tested the config, it runs and creates a i18n folder in my project root with my project locales, but the json files are empty.
In my public folder -> locales -> {{lng}} -> {{ns}} are around 100 dummy translations, that have been translated with locize - their save missing feature could find all my non translated words. Sooo I don't really know what is wrong.
Can anyone help me out? If you need more information, just ask!
Execute command: i18next-scanner --config i18next-scanner.config.js
Thanks and regards from Chris
i18next-scanner.config.js
`
const fs = require('fs')
const chalk = require('chalk')
module.exports = {
input: [
'./src//*.{js,jsx}',
'./pages//.{js,jsx}',
// Use ! to filter out files or directories
'!./**/.spec.{js,jsx}',
'!./i18n/',
'!/node_modules/**'
],
output: './',
options: {
debug: true,
func: {
list: ['i18next.t', 'i18n.t'],
extensions: ['.js', '.jsx']
},
trans: {
component: 'Trans',
i18nKey: 'i18nKey',
defaultsKey: 'defaults',
extensions: ['.js', '.jsx'],
fallbackKey: function (ns, value) {
return value
},
// https://react.i18next.com/latest/trans-component#usage-with-simple-html-elements-like-less-than-br-greater-than-and-others-v10.4.0
supportBasicHtmlNodes: true, // Enables keeping the name of simple nodes (e.g.
) in translations instead of indexed keys.
keepBasicHtmlNodesFor: ['br', 'strong', 'i', 'p'], // Which nodes are allowed to be kept in translations during defaultValue generation of .
// https://github.com/acornjs/acorn/tree/master/acorn#interface
acorn: {
ecmaVersion: 2020,
sourceType: 'module' // defaults to 'module'
}
},
lngs: ['en', 'fr', 'nl', 'de'],
ns: ['locale', 'resource'],
defaultLng: 'en',
defaultNs: 'resource',
defaultValue: 'STRING_NOT_TRANSLATED',
resource: {
loadPath: './public/locales/{{lng}}/{{ns}}.json',
savePath: 'i18n/{{lng}}/{{ns}}.json',
jsonIndent: 2,
lineEnding: '\n'
},
nsSeparator: ':',
keySeparator: '.',
pluralSeparator: '',
contextSeparator: '',
contextDefaultValues: [],
interpolation: {
prefix: '{{',
suffix: '}}'
},
metadata: {},
allowDynamicKeys: false
},
transform: function customTransform(file, enc, done) {
'use strict'
const parser = this.parser
const content = fs.readFileSync(file.path, enc)
let count = 0
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))}')
}
done()
}
}
`
The text was updated successfully, but these errors were encountered: