i18next-parser
i18next-parser copied to clipboard
CLI Exceeding call stack
🐛 Bug Report
After freshly installing i18next-parser with npm i -g i18next-parser and setting up a configuration file, running the CLI gives
i18next "src/**/*.{js, jsx, ts, tsx}"
i18next Parser
--------------
Input: src/**/*.{js, jsx, ts, tsx}
Output: public/locales/$LOCALE/$NAMESPACE.json
/home/justin/.nvm/versions/node/v20.12.0/lib/node_modules/i18next-parser/node_modules/anymatch/index.js:94
return (testString, ri = false) => {
^
RangeError: Maximum call stack size exceeded
at /home/justin/.nvm/versions/node/v20.12.0/lib/node_modules/i18next-parser/node_modules/anymatch/index.js:94:12
at EventEmitter.onPath (/home/justin/.nvm/versions/node/v20.12.0/lib/node_modules/i18next-parser/node_modules/glob-stream/index.js:270:20)
at EventEmitter.emit (node:events:518:28)
at processDirents (/home/justin/.nvm/versions/node/v20.12.0/lib/node_modules/i18next-parser/node_modules/glob-stream/index.js:88:10)
at next (/home/justin/.nvm/versions/node/v20.12.0/lib/node_modules/i18next-parser/node_modules/now-and-later/lib/mapSeries.js:43:5)
at handler (/home/justin/.nvm/versions/node/v20.12.0/lib/node_modules/i18next-parser/node_modules/now-and-later/lib/mapSeries.js:57:9)
at f (/home/justin/.nvm/versions/node/v20.12.0/lib/node_modules/i18next-parser/node_modules/once/once.js:25:25)
at processDirents (/home/justin/.nvm/versions/node/v20.12.0/lib/node_modules/i18next-parser/node_modules/glob-stream/index.js:113:7)
at next (/home/justin/.nvm/versions/node/v20.12.0/lib/node_modules/i18next-parser/node_modules/now-and-later/lib/mapSeries.js:43:5)
at handler (/home/justin/.nvm/versions/node/v20.12.0/lib/node_modules/i18next-parser/node_modules/now-and-later/lib/mapSeries.js:57:9)
Node.js v20.12.0
To Reproduce
A minimal reproducible example.
A codesandbox example or similar
or at least steps to reproduce the behavior:
i18next-parser.config.js
module.exports = {
contextSeparator: '_',
// Key separator used in your translation keys
createOldCatalogs: true,
// Save the \_old files
defaultNamespace: 'translation',
// Default namespace used in your i18next config
defaultValue: (loc, ns, key) => (loc === 'en' ? key : '__NOT_TRANSLATED__'),
// Default value to give to keys with no value
// You may also specify a function accepting the locale, namespace, key, and value as arguments
indentation: 2,
// Indentation of the catalog files
keepRemoved: true,
// Keep keys from the catalog that are no longer in code
// You may either specify a boolean to keep or discard all removed keys.
// You may also specify an array of patterns: the keys from the catalog that are no long in the code but match one of the patterns will be kept.
// The patterns are applied to the full key including the namespace, the parent keys and the separators.
keySeparator: false,
// Key separator used in your translation keys
// If you want to use plain english keys, separators such as `.` and `:` will conflict. You might want to set `keySeparator: false` and `namespaceSeparator: false`. That way, `t('Status: Loading...')` will not think that there are a namespace and three separator dots for instance.
// see below for more details
lexers: {
js: ['JavascriptLexer'], // if you're writing jsx inside .js files, change this to JsxLexer
ts: ['JavascriptLexer'],
jsx: ['JsxLexer'],
tsx: ['JsxLexer'],
default: ['JavascriptLexer'],
},
lineEnding: 'auto',
// Control the line ending. See options at https://github.com/ryanve/eol
locales: ['en'],
// An array of the locales in your applications
namespaceSeparator: false,
// Namespace separator used in your translation keys
// If you want to use plain english keys, separators such as `.` and `:` will conflict. You might want to set `keySeparator: false` and `namespaceSeparator: false`. That way, `t('Status: Loading...')` will not think that there are a namespace and three separator dots for instance.
output: 'public/locales/$LOCALE/$NAMESPACE.json',
// Supports $LOCALE and $NAMESPACE injection
// Supports JSON (.json) and YAML (.yml) file formats
// Where to write the locale files relative to process.cwd()
pluralSeparator: '_',
// Plural separator used in your translation keys
// If you want to use plain english keys, separators such as `_` might conflict. You might want to set `pluralSeparator` to a different string that does not occur in your keys.
// If you don't want to generate keys for plurals (for example, in case you are using ICU format), set `pluralSeparator: false`.
input: ['src/**/*.{js, jsx, ts, tsx}'],
// An array of globs that describe where to look for source files
// relative to the location of the configuration file
sort: false,
// Whether or not to sort the catalog. Can also be a [compareFunction](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#parameters)
verbose: true,
// Display info about the parsing including some stats
failOnWarnings: false,
// Exit with an exit code of 1 on warnings
failOnUpdate: false,
// Exit with an exit code of 1 when translations are updated (for CI purpose)
i18nextOptions: { compatibilityJSON: 'v3' },
// If you wish to customize options in internally used i18next instance, you can define an object with any
// configuration property supported by i18next (https://www.i18next.com/overview/configuration-options).
// { compatibilityJSON: 'v3' } can be used to generate v3 compatible plurals.
};
npm i -g i18next-parser
i18next "src/**/*.{js, jsx, ts, tsx}"
Expected behavior
i18next-parser runs
Your Environment
- runtime version: node v20, v18, v16
- i18next version: ^23.5.1
- os: Linux
- Folders go no further than 4 levels deep, so not sure what would be causing
Have same issue :(
npm i -D 'glob-stream@<8.0.1’ fix this problem for me
Having the same issue, but yeah it appears a security fix update to the glob-stream package broke this.
I spend over hour debugging, and ended up installing i18next-parser in version 7.9.0
Same issue here. Downgrade resolved it.
FYI - glob-stream 8.0.2 fixes this. If you're using yarn, you can update it with yarn up glob-stream --recursive. I'm not sure how to update transitive dependencies with other package managers...