DenysVuika / preact-translate

Minimalistic translate (i18n) library for Preact

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TranslateProvider trying to fetch assets/en.json even if translations key is passed

toniopelo opened this issue · comments

The following code:

<TranslateProvider translations={{ fr: phrases, en: {} }} lang="fr">
  ...
</TranslationProvider>

Is still producing a xhr call to fetch assets/en.json, see this console output:

image

Ok, finally found out that the problem is that we fetch translations if their lang object is empty (even though the key exists).
In my case I don't want to support English now but I'm not able to change the fallbackLang. So I need to have an en key on the translation object.

I submitted two PRs:
#197 Which allow to update the fallbackLang (This is preferred way IMO)
#196 Optionally we could also avoid fetching translations if the key exists (whether or not they contain an empty object)

Thanks for the contribution!