How to use the react-native-localize.addEventListener function in react-native-localize

To help you get started, we’ve selected a few react-native-localize examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github burst-apps-team / phoenix / mobile / App.tsx View on Github external
// (required) Called when a remote or local notification is opened or received
      onNotification,

      // ANDROID ONLY: GCM or FCM Sender ID (product_number)
      senderID: '1025777552500',

      // IOS ONLY (optional): default: all - Permissions to register.
      permissions: {
        alert: true,
        badge: true,
        sound: true
      }
    });

    addEventListener('change', this.handleLanguagesChange);

    if (Platform.OS === 'android') {
      Linking.getInitialURL().then((url) => {
        if (url) {
          this.navigate(url);
        }
      });
    } else {
      Linking.addEventListener('url', this.handleOpenURL);
    }
  }
github celo-org / celo-monorepo / packages / mobile / src / i18n.ts View on Github external
fallbackLng: {
      default: ['en-US'],
      'es-US': ['es-LA'],
    },
    resources: availableResources,
    ns: ['common', ...Object.keys(Namespaces)],
    defaultNS: 'common',
    debug: true,
    interpolation: {
      escapeValue: false,
    },
    missingInterpolationHandler: currencyInterpolator,
  })
  .catch((reason: any) => Logger.error(TAG, 'Failed init i18n', reason))

RNLocalize.addEventListener('change', () => {
  i18n
    .changeLanguage(getLanguage())
    .catch((reason: any) => Logger.error(TAG, 'Failed to change i18n language', reason))
})

// Create HOC wrapper that hoists statics
// https://react.i18next.com/latest/withtranslation-hoc#hoist-non-react-statics
export const withTranslation = (namespace: Namespaces) => (component: React.ComponentType) =>
  hoistStatics(withTranslationI18Next(namespace)(component), component)

export default i18n
github rastapasta / foodsharing / src / common / translation.tsx View on Github external
const { languageTag, isRTL } =
    RNLocalize.findBestAvailableLanguage(Object.keys(translationGetters)) ||
    fallback

  translate.cache.clear();
  I18nManager.forceRTL(isRTL)

  i18n.translations = { [languageTag]: translationGetters[languageTag]() }
  i18n.locale = languageTag

  moment.locale(languageTag)
}

setI18nConfig()
RNLocalize.addEventListener("change", () => setI18nConfig())
github react-native-community / react-native-localize / example / src / SyncExample.js View on Github external
componentDidMount() {
    RNLocalize.addEventListener("change", this.handleLocalizationChange);
  }
github react-native-community / react-native-localize / example / src / AsyncExample.js View on Github external
.then(() => {
        this.setState({ isTranslationLoaded: true });
        RNLocalize.addEventListener("change", this.handleLocalizationChange);
      })
      .catch(error => {