i18next / i18next-parser

Parse your code to extract translation keys/values and manage your catalog files
MIT License
488 stars 199 forks source link

@i18next-parser-warning-ignore tag #657

Open soullivaneuh opened 2 years ago

soullivaneuh commented 2 years ago

🚀 Feature Proposal

Provide a @i18next-parser-warning-ignore (or equivalent if you don't like that name ha ha!) comment tag that will silent a warning on a specific code line.

Motivation

For specific reasons, we may have sometime to use dynamic key and then say good bye to the automatic generation.

However, the only way to keep the parser working is to completely ignore any warning by setting failOnWarnings to false.

Deactivate this is not ideal because we are not able anymore to spot some not authorized variable key usage during merge requests review processing.

Using this tag will allow us to be more flexible without losing this security.

Example

const key = 'foo';
const { t } = useTranslation();
// @i18next-parser-warning-ignore
t(key);
soullivaneuh commented 2 years ago

As an another alternative, we may also provide a ignoreNamespaces option. Indeed, we dedicated our dynamic key usage on a specific catalog named validation (see here for the usage).

Ignoring the complete namespace may also fit our needs.

sparrowek commented 3 weeks ago

Any progress on this?