tolgee-js icon indicating copy to clipboard operation
tolgee-js copied to clipboard

early updateOptions makes it missbehave (react and i18next backend)

Open Megamannen opened this issue 7 months ago • 3 comments

First wrote #3281 But I don't know, I think this is the same, but keeping the old one for history in case I'm wrong

Attached project to reproduce it tolgee-updateOptions.zip

Import language_export into a Tolgee project (has one namespace: 'keys')

populate .env.local with your project setting

VITE_TOLGEE_KEY=tgpak_
VITE_TOLGEE_API=https://
VITE_TOLGEE_PROJECT=1

run

pnpm install
pnpm run dev

observe how AltLeft isn't translated, but you can Alt + Click it and it has the correct values

it all comes down to a very early updateOptions. This example code doesn't make so much sense. But it's a condensed version of something that makes more sense :P

language-provider.tsx

useEffect(() => {
      tolgee.updateOptions({
        apiKey: import.meta.env.VITE_TOLGEE_KEY,
      });      
  }, []);

Megamannen avatar Nov 22 '23 07:11 Megamannen