Is there any way to change whole app languate in single click. instead of writting a alternate word for each word. I dont know, but just a thought. like by using google translate or any other api ?
One way is you can send this file with your selected language to your server and the server will give you the response of the translated file. For dynamic data it works well. And another way you can use any third party API to translate your text.
When I close the app and reopen it, will it show the default language (en), right? How can we display the last selected language when reopening the application using AsyncStorage?
Yeah, I got it, Screen One const changeLangFunc = async (lng) => { await AsyncStorage.setItem('selectedLanguage', lng); // Store the selected language i18next.changeLanguage(lng) setLangModal(false) } set the selected lang in an asyncStorage screen two, In the screen where we call the functions to execute the changes added the below code, const setInitialLanguage = async () => { try { const selectedLanguage = await AsyncStorage.getItem('selectedLanguage'); if (selectedLanguage) { i18next.changeLanguage(selectedLanguage); } } catch (error) { console.error('Error retrieving selected language:', error); } }; setInitialLanguage(); // Set the initial language on application startup @@sameersingh-gb1gy
Please check, have you installed/configured library correctly? And to change language you can use import { useTranslation } from 'react-i18next' const { t, i18n } = useTranslation(); i18n.changeLanguage('fr')
How to do RTL?
Yes, you can achieve it using I18nManager.
import {I18nManager} from 'react-native'
...
I18nManager.forceRTL(true) // forceRLT: boolean
you saved my hours thanks a lot buddy
Cheers 🥂
This was so easy, thanks a bunch !
Cheers 🥂
daammnnn this is what i need. thank you.
Helpful content... great thanks
thanks
Welcome 😊
Very Helpful
Is there any way to change whole app languate in single click. instead of writting a alternate word for each word. I dont know, but just a thought. like by using google translate or any other api ?
One way is you can send this file with your selected language to your server and the server will give you the response of the translated file.
For dynamic data it works well.
And another way you can use any third party API to translate your text.
Perfect!
When I close the app and reopen it, will it show the default language (en), right? How can we display the last selected language when reopening the application using AsyncStorage?
i am also trying the same from last 3 days please reply here if you get any solution
Yeah, I got it,
Screen One
const changeLangFunc = async (lng) => {
await AsyncStorage.setItem('selectedLanguage', lng); // Store the selected language
i18next.changeLanguage(lng)
setLangModal(false)
}
set the selected lang in an asyncStorage
screen two,
In the screen where we call the functions to execute the changes added the below code,
const setInitialLanguage = async () => {
try {
const selectedLanguage = await AsyncStorage.getItem('selectedLanguage');
if (selectedLanguage) {
i18next.changeLanguage(selectedLanguage);
}
} catch (error) {
console.error('Error retrieving selected language:', error);
}
};
setInitialLanguage(); // Set the initial language on application startup
@@sameersingh-gb1gy
@@MaheshRajan-ly7vm ty man
Danke Schön bruddah!
Also try to mix react-native-localise with this video as part 2
Thank u!!
Welcome 😊
What extension do you have that sugest you evreything when you are writting code ??
I have installed many extensions but you can try these...
Auto import
"React Native Tools"
Auto complete Tag
is their any automation available?
Does it mean you'd have to input the translations manually?
Yes, for static texts!
For dynamic or api based data/text it requires translation from api or need to add some extra efforts.
ERROR TypeError: Cannot read property 'language' of undefined, js engine: hermes
when I am trying to change language
Please check, have you installed/configured library correctly?
And to change language you can use
import { useTranslation } from 'react-i18next'
const { t, i18n } = useTranslation();
i18n.changeLanguage('fr')
How can I show last selected language when reopening the app ?
For that you need to persist your selected language in any local storage like AsyncStorge or you can find any other solution to persist user prefs.
How to do RTL ?
Layout is not shifting without refreshing app
Have you tried with, Pinned comment's answer?
@@vishalpwr, yes ! Language changes but layout is not shifted.
Can you show it in another tutorial please.
does it work with expo
Yes, i18next and react-i18next absolutely works with Expo.
The music is freaking stressing me out , had to stop in the middle of tutorial :(
Ohhh :(, Sorry next time I will try better.
Bro again forgot yt password
😔