Ghost---Shadow / i18nize-react

Internationalize react apps within a lunch break
MIT License
405 stars 21 forks source link

No rerender after language change #12

Closed ESalfinger closed 4 years ago

ESalfinger commented 4 years ago

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);
  };
Ghost---Shadow commented 4 years ago

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!

ESalfinger commented 4 years ago

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

Ghost---Shadow commented 4 years ago

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

ESalfinger commented 4 years ago

Works like a charm, thanks!