react-native-tts
react-native-tts copied to clipboard
How to speak multiple languages in an application?
My application needs to speak multiple languages. How to effectively implement it? Thank you
use a locale code
Tts.setDefaultLanguage([YOUR_LOCALE]);
like
Tts.setDefaultLanguage('en-IE');
You can store a locale array and when you want to change locale, you can set it to your state and put it as parameter to above function.
Example.
constructor(props){
super(props);
this.state = {
currentLocale: "en-IE"
}
}
... When you want to change locale, change currentLocale state to new locale like
this.setState({currentLocale:"YOUR_NEW_LOCALE_CODE"});
use this state object like;
Tts.setDefaultLanguage(this.state.currentLocale);