Ghost---Shadow/i18nize-react

No rerender after language change

ESalfinger opened this issue · 4 comments

Hey, great project! I have a problem that my components content only switches language after I refresh the page.

I change my language by setting it in the local storage, correct?

const changeLanguage = lng => {
    localStorage.setItem("lng", lng);
  };

Yeah.

This tool is for automating out the boring parts of moving all the hardcoded text into a look up table. As an addition I added some "batteries included" features like Chinese and the language changer, but if you want to do it another way, you can!

And how do i get the components to render in the new language after i set it in the localStorage?

In my application I just did a window.reload() in the callback of the language change button. You can do it in some other way.

e.g. Ubisoft picks the language from the URL

Works like a charm, thanks!