0.1.4 • Published 3 years ago

react-native-change-ios-locale v0.1.4

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

Under development

currently working with IOS only

react-native-change-ios-locale

Force ios to sync the language change with the i18 localization or react native localization,

When should I use this package

Use this package when: you are using a native module or library that provides a separate way to detect the localization

Installation

npm install react-native-change-ios-locale

Usage

Follow the instruction from https://www.npmjs.com/package/react-native-localization

let strings = new LocalizedStrings({
 en:{
   ///...
 },
 ar:{
   // ....
 },
  // ...
});
import { switchLang } from "react-native-change-ios-locale";

// ...
useEffect(() => {
    async function changeLocalization() {
      //  Change the Language for the translation Package 
      await translations.setLanguage(selectedLocale);
    }
    if (selectedLocale) {
      changeLocalization().then(() => {
        // then trigger the switchLang to set the language for the IOS
        if (Platform.OS === 'ios') {
          switchLang(selectedLocale);
        }
        // reload app iff needed using react native restart
      });
    }
  }, [selectedLocale]);

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT