You can use a configuration file (e.g., i18next-parser.config.js) to control how the parser treats your files. This allows you to define input/output paths, locales, separators, and lexer settings.
Key configuration options include:
input: An array of globs describing source files relative to the config file.output: Path template for locale files (supports $LOCALE and $NAMESPACE injection, e.g., 'locales/$LOCALE/$NAMESPACE.json').locales: An array of locales used in your application (e.g., ['en', 'fr']).keySeparator and namespaceSeparator: Define the characters used to split keys (e.g., . and :). Set both to false if using plain English keys to avoid conflicts.defaultValue: The default value for keys with no value. Can be a string or a function.keepRemoved: Determines if keys no longer present in code should be kept in the catalog. Can be a boolean or an array of patterns.failOnUpdate: If true, the process exits with code 1 when translations are updated (useful for CI).
// i18next-parser.config.js
export default {
contextSeparator: '_',
createOldCatalogs: true,
defaultNamespace: 'translation',
defaultValue: '',
indentation: 2,
keepRemoved: false,
keySeparator: '.',
lexers: {
hbs: ['HandlebarsLexer'],
handlebars: ['HandlebarsLexer'],
htm: ['HTMLLexer'],
html: ['HTMLLexer'],
mjs: ['JavascriptLexer'],
js: ['JavascriptLexer'],
ts: ['JavascriptLexer'],
jsx: ['JsxLexer'],
tsx: ['JsxLexer'],
default: ['JavascriptLexer'],
},
lineEnding: 'auto',
locales: ['en', 'fr'],
namespaceSeparator: ':',
output: 'locales/$LOCALE/$NAMESPACE.json',
pluralSeparator: '_',
input: undefined,
sort: false,
verbose: false,
failOnWarnings: false,
failOnUpdate: false,
customValueTemplate: null,
resetDefaultValueLocale: null,
i18nextOptions: null,
yamlOptions: null,
}