mxmvshnvsk/i18n-unused

Nodes i18n The translation matcher could include __

bleuscyther opened this issue · 2 comments

While using the popular i18n library, I discovered that I needed to specify __ in the regex.

/(?:[$ .](__))\(.*?\)/gi

Or more generally

const defaultValues = {
// ...
 translationKeyMatcher: : /(?:[$ .](_|t|tc|i18nKey|__))\(.*?\)/gi,

// ...
};

I am leaving this here for others in the future or if people are having issues with other translation libraries.


i18n-unused
is a must-have if you are doing internationalization with JS. Imprecive work mxmvshnvsk

translation-key-matcher is not in the supported list of options for the Shell commands.
Overriding the config would look like this:

i18n-unused display-unused --locales-path src/locales --src-path src/ --translation-key-matcher '/(?:[$ .](_|t|tc|i18nKey|__))\(.*?\)/gi'

Another suggestion, I am using ESM so the i18n-unused.config.js is not found, the module parser is expecting i18n-unused.config.cjs.
I think the config package should be allowed to be:

  • json
  • js
  • cjs (ESM modules parsing CommonJS )