简体   繁体   中英

i18next change language of the entire app

I hope you are doing great on another quarantine day!

I'm trying to change the language of my React Application using i18n but I'm having a problem.

Here is the snippet code I'm using (this code is located in the component TopBar.jsx)

 function onSelectFlag(countryCode) { switch (countryCode) { case "US": { i18n.changeLanguage("en"); break; } case "BR": { i18n.changeLanguage("po"); break; } default: { i18n.changeLanguage("es"); break; } } }

The problem is that, this code, is ONLY changing the component language but NOT the entire application language. I've done some research but didn't find anything...

Does someone know how to solve this?

Thanks!

Alright, tipically... You've researched the answer for 1 hour and just 2 minute after ask a question in Stackoverflow, you find the answer!

The problem was that I wasn't using the hook to translate in the other components... So, using useTranslations hook everywhere, solved my problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM