1.0.2 • Published 7 months ago

i18n-config-mfi v1.0.2

Weekly downloads
-
License
MIT
Repository
-
Last release
7 months ago

i18n-config-mfi

The library which contains the i18next configuration and common translation files.

Features

  • Contains the default configuration of the i18next library.
  • Contains the common translation files for all the MFI projects.

Installation

  1. Install the package via npm:
npm i i18n-config-mfi
  1. Wrap the App component with the I18nWrapper component from the i18n-config-mfi library. Pass the required properties: defaultLang, availableLangs and projectResources:
<I18nWrapper defaultLang="en" availableLangs={['en', 'fr', 'pt', 'es']} projectResources={projectResources}>
  <App />
</I18nWrapper>

The availableLangs property must also contain the default language and be the first one in the array.

  1. Create locales folder and add translation JSON files there.

  2. Install translation-checker-mfi package via npm:

npm i translation-checker-mfi
  1. Create translationRunner.ts file in the root folder.

  2. Add following code in this file:

const { updateTranslations } = require('translation-checker-mfi');

const defaultLang = 'en';
const availableLanguages = ['en', 'fr', 'pt', 'es']; // Add more languages as needed
const fileLocation = './src/locales/'; // Add the base location of translation files

updateTranslations(defaultLang, fileLocation, availableLanguages);
  1. In package.json add this script:
 "check-i18n": "ts-node ./src/translationRunner.ts"

Usage

  1. Import useTranslation hook from i18n-config-mfi library:
import { useTranslation } from 'i18n-config-mfi';
  1. To access the common translation use common: prefix before key:
<p>{t('common:hello')}</p>
  1. To access the translation of the project use only the key name specified in the JSON file:
<p>{t('error')}</p>
1.0.2

7 months ago

1.0.1

7 months ago

1.0.0

7 months ago

0.9.1

7 months ago

0.9.0

7 months ago

0.8.0

7 months ago

0.7.0

7 months ago

0.6.0

7 months ago

0.5.0

7 months ago

0.4.0

7 months ago

0.3.0

7 months ago

0.2.0

7 months ago

0.1.0

7 months ago