Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESM support + Easier way to specify translationKeyMatcher #31

Merged
merged 3 commits into from
Nov 28, 2022

Conversation

bleuscyther
Copy link
Contributor

@bleuscyther bleuscyther commented Nov 26, 2022

New command --translation-key-matcher

This makes it easier to modify the matcher for more libraries like i18n-node, who use __ :
display

image

ESM module configuration file

When creating the configuration file from inside an ES-Modules (esm) the parser is not able to read the Common-js module without the .cjs extension.

To fix that we could use a .json configuration file without the support for callbacks or a .cjs file.

i18n-unused.config.json :

{
  "localesPath": "src/locales",
  "srcPath": "src",
  "translationKeyMatcher": "/(?:[$ .](_|t|tc|i18nKey|__))\\(.*?\\)/gi"
}

i18n-unused.config.cjs :

module.exports = {
  localesPath: 'src/locales',
  srcPath: 'src',
  translationKeyMatcher: /(?:[$ .](_|t|tc|i18nKey|__))\(.*?\)/gi
};

closes #30

From the Shell you can now pass this option `--translation-key-matcher`. It will parse the escaped string into a REgex
ESM modules wont pars Common-js modules if they don't have the `.cjs` extension
@mxmvshnvsk mxmvshnvsk merged commit 5a8da39 into mxmvshnvsk:main Nov 28, 2022
@mxmvshnvsk
Copy link
Owner

Hi, thank you for wonder pr)

@bleuscyther
Copy link
Contributor Author

You are welcome

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Nodes i18n The translation matcher could include __
2 participants