babel-plugin-i18next-extract icon indicating copy to clipboard operation
babel-plugin-i18next-extract copied to clipboard

Be able to extract translations from strings and not only from t(string)

Open alanszp opened this issue 3 years ago • 2 comments

Is your feature request related to a problem? Please describe.

When using yup or other libraries, I want to give the library the translation path, but not the computed value, and then in the code use that path with the TFunction.

Ilustrative example:

yup.object({
    body: yup.string().required('errors.bodyIsRequired'),
})

Later on the code

t(errors.body)

In this case, i18next-extract won't know that errors.bodyIsRequired is a translation.

Describe the solution you'd like

Was thinking (but open to discussion) that if we can add a comment hint like // i18next-extract-string-is-translation or // i18next-extract-string-is-translation-next-line would help in this cases.

Describe alternatives you've considered

Was thinking how to configure customTransComponents for this case, but the problem is that there are many types and they are stored in node_modules. Woludn't be so sure how to make that work.

Additional context

alanszp avatar May 25 '21 19:05 alanszp

This one seems covered by this documentation: https://i18next-extract.netlify.app/#/configuration?id=tfunctionnames You can add relevant yup calls as function names, like "string().required" in your example.

eric-burel avatar Aug 12 '21 07:08 eric-burel

Thanks for the comment! I think that it might be used, but can lead to potential errors if miss configured. And also if the implementation of the yup call handles multiple firms, it may also lead to problems.

I think that this hint is still usefull.

alanszp avatar Sep 17 '21 21:09 alanszp