How to use the i18n-js.locale function in i18n-js

To help you get started, we’ve selected a few i18n-js 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 status-im / ens-usernames / app / index.js View on Github external
import lang from 'i18n-js';
import React from 'react';
import { render } from 'react-dom';
import { Provider } from 'react-redux';
import store from './store/configureStore';
import App from './dapp';
import init from './store/init';
import translations from './languages';
import './dapp.css';

// Init i18n translation
lang.defaultLocale = 'en';
lang.locale = navigator.language;
lang.fallbacks = true;
lang.translations = translations;

// Init Redux store
init();

render(
  
    
  ,
  document.getElementById('app')
);
github react-native-community / react-native-localize / example / src / AsyncExample.js View on Github external
const { languageTag, isRTL } =
    RNLocalize.findBestAvailableLanguage(Object.keys(translationPaths)) ||
    fallback;

  const fileContent = await (Platform.OS === "android"
    ? RNFS.readFileAssets(translationPaths[languageTag], "utf8")
    : RNFS.readFile(translationPaths[languageTag], "utf8"));

  // clear translation cache
  translate.cache.clear();
  // update layout direction
  I18nManager.forceRTL(isRTL);

  // set i18n-js config
  i18n.translations = { [languageTag]: JSON.parse(fileContent) };
  i18n.locale = languageTag;
};
github Sage / carbon / src / components / date / __spec__.js View on Github external
it('sets the weekDays and format', () => {
      const datepickerProps = datepicker.props
      expect(datepickerProps.fixedWeeks).toBeTruthy();
      expect(datepickerProps.enableOutsideDays).toBeTruthy();
      expect(datepickerProps.inline).toBeTruthy();
      expect(datepickerProps.locale).toEqual(I18n.locale);
      expect(datepickerProps.localeUtils).toEqual(LocaleUtils);
    });
  });
github jolocom / smartwallet-app / src / locales / i18n.ts View on Github external
export const getI18nImage = (filename: string): string => {
  const locale = locales.includes(I18n.locale)
    ? I18n.locale
    : I18n.defaultLocale

  return localeSpecificImages[locale][filename]
}
github dooboolab / hackatalk-mobile / STRINGS.ts View on Github external
PASSWORD_CHANGE: '비밀번호 변경하기',
  PASSWORD_CURRENT: '기존 비밀번호',
  PASSWORD_NEW: '새로운 비밀번호',
  PASSWORD_NEW_REPEAT: '새로운 비밀번호 확인',
  NEXT: '다음',
  OK: '확인',
  CONFIRM: '확인',
  LOGIN_INFORMATION: '계정 정보',
  SIGNED_IN_WITH_GOOGLE: '구글 계정으로 로그인 됨',
  SIGNED_IN_WITH_FACEBOOK: '페이스북 계정으로 로그인 됨',
  SIGNED_IN_WITH_EMAIL: '이메일로 로그인 됨',
};

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

export const getString = (param: string, mapObj?: object): string => {
  if (mapObj) {
    i18n.t(param, mapObj);
  }
  return i18n.t(param);
};
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 expo / expo / apps / native-component-list / src / screens / LocalizationScreen.tsx View on Github external
changeLocale = (locale: string) => {
    i18n.locale = locale;
    this.setState({ locale });
  }
github mikebarkmin / react-to-everything / src / locales / I18n.js View on Github external
import I18n from 'i18n-js';
import de from './locales/de';
import en from './locales/en';

I18n.fallbacks = true;

I18n.translations = {
  en,
  de,
};

I18n.locale = navigator.language || navigator.userLanguage;

export default I18n;