How to use the react-native-localize.getLocales 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 keremcubuk / react-native-boilerplate / app / localization / index.js View on Github external
import * as RNLocalize from 'react-native-localize';
import I18n from 'i18next';

import en from './en';
import fr from './fr';

const locales = RNLocalize.getLocales();

I18n.init({
  debug: true,
  useLocalStorage: true,
  lng: locales[0].languageCode,
  fallbackLng: 'en',
  resources: { fr: { translation: fr }, en: { translation: en }, 'fr-FR': { translation: fr } },
});

export default I18n;
github dooboolab / dooboo-native-ts / STRINGS.ts View on Github external
import * as Localization from 'react-native-localize';

import en from './assets/langs/en.json';
import i18n from 'i18n-js';
import ko from './assets/langs/ko.json';

const locales = Localization.getLocales();

if (Array.isArray(locales)) {
  i18n.locale = locales[0].languageTag;
}

i18n.fallbacks = true;
i18n.translations = { en, ko };

export const getString = (param: string, mapObj?: object): string => {
  if (mapObj) {
    i18n.t(param, mapObj);
  }
  return i18n.t(param);
};
github react-native-community / react-native-localize / example / src / AsyncExample.js View on Github external
render() {
    if (!this.state.isTranslationLoaded) {
      return ;
    }

    return (
github saucelabs / sample-app-mobile / src / js / config / I18n.js View on Github external
import I18n from 'i18n-js';
import * as RNLocalize from 'react-native-localize';
import en from './translations/en';

const locales = RNLocalize.getLocales();

if (Array.isArray(locales)) {
	I18n.locale = locales[ 0 ].languageTag;
}

I18n.fallbacks = true;
I18n.translations = {
	en,
};

export default I18n;
github infinitered / ChainReactApp2019 / app / i18n / i18n.ts View on Github external
import I18n from "i18n-js"
import * as RNLocalize from "react-native-localize"

const en = require("./locales/en.json")
const ja = require("./locales/ja.json")

const locales = RNLocalize.getLocales()

if (Array.isArray(locales)) {
  I18n.locale = locales[0].languageTag
}

I18n.fallbacks = true
I18n.translations = {
  en,
  ja,
}

export default I18n
github tomzaku / react-native-cba-starter-kit / exampleTs / src / i18n / index.ts View on Github external
import * as RNLocalize from "react-native-localize";
import i18n from 'i18n-js';

import en from './locales.__generate__/en.json'
import vi from './locales.__generate__/vi.json'

i18n.defaultLocale = 'en';
i18n.locale = RNLocalize.getLocales()[0].languageTag;
i18n.fallbacks = true;
i18n.translations = { en, vi };

export default i18n;
github OriginProtocol / origin / mobile / src / screens / onboarding / phone.js View on Github external
constructor(props) {
    super(props)

    let countryValue = ''

    const locales = RNLocalize.getLocales()
    if (locales) {
      const countryMatch = countryOptions.find(c => {
        if (c.value) {
          return (
            c.value.code.toLowerCase() === locales[0].countryCode.toLowerCase()
          )
        }
      })
      if (countryMatch) {
        countryValue = countryMatch.value
      }
    }

    this.state = {
      countryValue: countryValue,
      phoneValue: '',