JSPM

@openshift-assisted/locales

2.47.3
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 277
  • Score
    100M100P100Q123630F
  • License Apache-2.0

Locales for the Assisted Installer UI library

Package Exports

  • @openshift-assisted/locales/en/translation.json
  • @openshift-assisted/locales/es/translation.json
  • @openshift-assisted/locales/fr/translation.json
  • @openshift-assisted/locales/ja/translation.json
  • @openshift-assisted/locales/ko/translation.json
  • @openshift-assisted/locales/package.json
  • @openshift-assisted/locales/zh/translation.json

Readme

Assisted Installer locales library

NPM

Installation

yarn add @openshift-assisted/locales

Usage

Internationalization is implemented with i18next and react-i18next. The i18n namespace must be declared at build-time in an environment variable called: TRANSLATION_NAMESPACE in order to avoid naming conflicts.

  • Environment variables:

      TRANSLATION_NAMESPACE: required, name of translation namespace (by default is 'translation')
  • We create the wrapper src/common/hooks/use-translation-wrapper.ts that use the useTranslation hook with our namespace.

  • Use in our components :

    import { useTranslation } from 'common/hooks/use-translation-wrapper';
    const { t } = useTranslation();
    
    <Button key="submit" onClick={submitForm}>
      {t('ai:Generate Discovery ISO')}
    </Button>;

    Add 'ai:' prefix to all strings.

  • Running yarn i18n updates the JSON files in the locales folder when adding or changing messages.