zauberware / react-i18n

I18n helper for React and React Native projects.
3 stars 0 forks source link

Parser not using default-namespace when multiple-namespaces are provided #5

Open hschmied opened 4 years ago

hschmied commented 4 years ago

The following scenario the parsing-process correctly creates 3 keys in the localization namespace file ...

  const {t, i18n} = useTranslation('localization', {useSuspense: true});
  ...
  <Text>{t('localization:test_dragonfruit')}</Text>
  <Text>{t('localization:test_elderberries')}</Text>
  <Text>{t('test_fig')}</Text>

In this scenario, though, the last key is not written into the localization namespace, but a separate one (translation.json) ...

  const {t, i18n} = useTranslation(['localization', 'app', 'common'], {useSuspense: true});
  ...
  <Text>{t('localization:test_dragonfruit')}</Text>
  <Text>{t('localization:test_elderberries')}</Text>
  <Text>{t('test_fig')}</Text>

Expected behavior: when multiple namespaces are provided, ideally the parser identifies the first namespace as default and writes the key into the corresponding file.

kirrg001 commented 4 years ago

I'd suggest to look if a bug issue at i18n-parser exist and if not, create one. Till this get's fixed, we could add a requirement that this notation is not allowed?

hschmied commented 4 years ago

Update -- there's some code regarding this use-case, but I think it's check isn't working in the namespace-array use case. I've written the original poster of the fix to get his/her feedback.

https://github.com/i18next/i18next-parser/pull/195