How to use the i18next.language function in i18next

To help you get started, we’ve selected a few i18next 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 berty / berty / client / react-native / common / i18n / dateFns.js View on Github external
const getLocale = () => {
  let languageCode = 'en'
  try {
    languageCode = i18n.language.split('-')[0]
  } catch (e) {
    // noop
  }

  if (loadedLocales[languageCode] !== undefined) {
    return loadedLocales[languageCode]
  }

  return loadedLocales['en']
}
github DestinyItemManager / DIM / src / app / settings / settings.ts View on Github external
SyncService.get().then((data) => {
    data = data || {};

    const savedSettings = data['settings-v1.0'] || {};

    const languageChanged = savedSettings.language !== i18next.language;
    store.dispatch(loaded(savedSettings));
    const settings = store.getState().settings;
    localStorage.setItem('dimLanguage', settings.language);
    if (languageChanged) {
      i18next.changeLanguage(settings.language);
    }

    readyResolve();
    // Start saving settings changes
    unsubscribe = saveSettingsOnUpdate();
  });
}
github mapseed / platform / src / base / static / components / app.tsx View on Github external
//     the current language is English. We expect the hard-coded default
        //     language of all non-configurable UI to be English.
        if (
          (i18next.language === config.flavor.defaultLanguage.code ||
            isFetchingTranslation[key] ||
            key === fallbackValue) &&
          isValidNonConfigurableI18nKey(key, i18next.language)
        ) {
          return;
        }

        isFetchingTranslation[key] = true;

        const response = await translationServiceClient.translate({
          text: fallbackValue,
          target: i18next.language,
        });

        // eslint-disable-next-line require-atomic-updates
        isFetchingTranslation[key] = false;

        if (response) {
          i18next.addResource(i18next.language, ns, key, response.body);
        } else {
          i18next.addResource(i18next.language, ns, key, fallbackValue);
        }
      },
    });
github babelouest / glewlwyd / webapp-src / src / Admin / App.js View on Github external
messageDispatcher.subscribe('App', (message) => {
      if (message.type === 'nav') {
        this.setState({curNav: message.message});
      } else if (message.type === 'profile') {
        this.fetchApi();
      } else if (message.type === 'loggedIn') {
        this.setState({loggedIn: message.message}, () => {
          console.log("loggedIn", this.state.loggedIn);
          if (!this.state.loggedIn) {
            this.fetchApi();
          }
        });
      } else if (message.type === 'lang') {
        this.setState({lang: i18next.language});
      } else if (message.type === 'delete') {
        if (message.role === 'user') {
          var confirmModal = {
            title: i18next.t("admin.confirm-delete-user-title", {user: message.user.name}),
            message: i18next.t("admin.confirm-delete-user", {username: message.user.username, name: message.user.name}),
            callback: this.confirmDeleteUser
          }
          this.setState({confirmModal: confirmModal, curUser: message.user}, () => {
            $("#confirmModal").modal({keyboard: false, show: true});
          });
        } else if (message.role === 'client') {
          var confirmModal = {
            title: i18next.t("admin.confirm-delete-client-title", {client: message.client.name}),
            message: i18next.t("admin.confirm-delete-client", {clientId: message.client.client_id, name: message.client.name}),
            callback: this.confirmDeleteClient
          }
github kiegroup / optaweb-employee-rostering / employee-rostering-frontend / src / i18n.ts View on Github external
},() => {
    moment.locale(languageToMomentLocale(i18n.language));
    setDefaultLocale(i18n.language);
  });
github Talend / ui / packages / components / src / translate.js View on Github external
export function getCurrentLanguage() {
	if (i18next.language) {
		return i18next.language;
	}
	return 'en';
}
github CKGrafico / Frontend-Boilerplates / src / app / app.i18n.ts View on Github external
export function getCurrentLanguage(): string {
  return i18n.language;
}
github sudhanshu16 / openwrt-firmware-selector / src / components / header.js View on Github external
const openChangeLanguagePopper = event => {
    setValue(i18next.language.substring(0, 2));
    setAnchorEl(anchorEl ? null : event.currentTarget);
  };
github babelouest / glewlwyd / webapp-src / src / Profile / Navbar.js View on Github external
this.state.config.lang.forEach((lang, i) => {
      if (lang === i18next.language) {
        langList.push(<a href="#">{lang}</a>);
      } else {
        langList.push(<a href="#"> this.changeLang(e, lang)} key={i}&gt;{lang}</a>);
      }
    });
    this.state.schemeList.forEach((scheme, index) =&gt; {