Open guiedugt opened 2 months ago
Using custom t names combined with custom translation hooks is not working as expected. For example, the translation keys will not be extracted:
t
function MyComponent() { const { myTranslationFunction } = useMyTranslationHook('namespace'); return <p>{myTranslationFunction('myTranslationKey')}</p>; }
After some investigation, I found this is due to a hardcoded "t" key inside the useTranslationHook extractor:
"t"
useTranslationHook
https://github.com/gilbsgilbs/babel-plugin-i18next-extract/blob/7cc5b807de142bedabcacb234ecc167e9db343a1/src/extractors/useTranslationHook.ts#L59
This PR adds some simple logic to try out different function names in the order they are defined in the tFunctionNames configuration parameter
tFunctionNames
Using custom
t
names combined with custom translation hooks is not working as expected. For example, the translation keys will not be extracted:After some investigation, I found this is due to a hardcoded
"t"
key inside theuseTranslationHook
extractor:https://github.com/gilbsgilbs/babel-plugin-i18next-extract/blob/7cc5b807de142bedabcacb234ecc167e9db343a1/src/extractors/useTranslationHook.ts#L59
This PR adds some simple logic to try out different function names in the order they are defined in the
tFunctionNames
configuration parameter