How to use @ohif/i18n - 10 common examples

To help you get started, we’ve selected a few @ohif/i18n 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 OHIF / react-viewerbase / src / components / userPreferencesModal / UserPreferencesModal.js View on Github external
constructor(props) {
    super(props);

    this.state = {
      windowLevelData: cloneDeep(props.windowLevelData),
      hotKeysData: cloneDeep(props.hotKeysData),
      generalData: {
        currentLanguage: i18n.language.substring(0, 2),
        // TODO: list of available languages should come from i18n.options.resources
        languages: [
          {
            value: 'en',
            label: 'English',
          },
          {
            value: 'es',
            label: 'Spanish',
          },
        ],
        onChange: language => {
          this.changeLanguage(language);
        },
      },
    };
github OHIF / Viewers / extensions / vtk / src / loadLocales.js View on Github external
async function loadLocales() {
  // Note: We should wait for the i18n initializing
  // promise to complete before adding any new
  // resources to i18next. If the resources are added
  // to i18next before initialization is complete, the
  // backend values (e.g. those from Locize) will not
  // be loaded properly.
  try {
    await i18n.initializing;
  } catch(error) {
    throw new Error(error);
  }

  i18n.addLocales(locales);
}
github OHIF / Viewers / platform / viewer / src / connectedComponents / ConnectedUserPreferencesForm.js View on Github external
onSave: ({ windowLevelData, hotkeyDefinitions, generalPreferences }) => {
      // TODO improve this strategy on windowLevel implementation
      hotkeysManager.setHotkeys(hotkeyDefinitions);

      const { language } = generalPreferences;

      // set new language
      i18n.changeLanguage(language);

      ownProps.hide();
      dispatch(
        setUserPreferences({
          windowLevelData,
          hotkeyDefinitions,
          generalPreferences,
        })
      );
    },
  };
github OHIF / Viewers / extensions / vtk / src / loadLocales.js View on Github external
async function loadLocales() {
  // Note: We should wait for the i18n initializing
  // promise to complete before adding any new
  // resources to i18next. If the resources are added
  // to i18next before initialization is complete, the
  // backend values (e.g. those from Locize) will not
  // be loaded properly.
  try {
    await i18n.initializing;
  } catch(error) {
    throw new Error(error);
  }

  i18n.addLocales(locales);
}
github OHIF / react-viewerbase / src / components / languageSwitcher / LanguageSwitcher.js View on Github external
  const getCurrentLanguage = (language = i18n.language) =>
    language.split('-')[0];
github OHIF / Viewers / platform / ui / src / components / languageSwitcher / LanguageSwitcher.js View on Github external
  const getCurrentLanguage = (language = i18n.language) =>
    language.split('-')[0];
github OHIF / react-viewerbase / src / components / userPreferencesModal / UserPreferencesModal.js View on Github external
changeLanguage(language) {
    this.setState({
      generalData: {
        ...this.state.generalData,
        currentLanguage: language,
      },
    });

    i18n.init({
      fallbackLng: language.split('-')[0],
      lng: language,
    });
  }
github OHIF / react-viewerbase / src / components / languageSwitcher / LanguageSwitcher.js View on Github external
const onChange = () => {
    const { value } = event.target;
    const language = getCurrentLanguage(value);
    setCurrentLanguage(language);

    i18n.init({
      fallbackLng: language,
      lng: language,
    });
  };
github OHIF / Viewers / platform / ui / src / components / languageSwitcher / LanguageSwitcher.js View on Github external
const onChange = () => {
    const { value } = event.target;
    const language = getCurrentLanguage(value);
    setCurrentLanguage(language);

    i18n.init({
      fallbackLng: language,
      lng: language,
    });
  };
github OHIF / Viewers / platform / ui / src / components / languageSwitcher / LanguageSwitcher.js View on Github external
useEffect(() => {
    let mounted = true;

    i18n.on('languageChanged', () => {
      if (mounted) {
        setCurrentLanguage(getCurrentLanguage());
      }
    });

    return () => {
      mounted = false;
    };
  }, []);

@ohif/i18n

Internationalization library for The OHIF Viewer

MIT
Latest version published 6 months ago

Package Health Score

86 / 100
Full package analysis

Similar packages