@coxy/i18n
TypeScript icon, indicating that this package has built-in type declarations

1.0.14 • Public • Published

@coxy/i18n

Component localization for react. Allows you to translate components individually, without storing huge localization files. Try. It's comfortable.

You can upload all translations with one command into one or several files. Then create a new translation file and import back into all files.

Install

yarn add @coxy/i18n

Setup

  1. Wrap main component I18nProvider
<I18nProvider fallback="en" language="es">  
    <AppComponent />
</I18nProvider>
  1. In AppComponent

Create index.i18n.json file in a component folder and include.

import locales from './index.i18n.json'

const { t } = useI18n(locales)

return <div>{t('title', {test: 123})}</div>

in index.i18n.json write

{
  "en": {
    "title": "Title string {{test}}"
  },
  "es": {
    "title": "Cadena de título {{test}}"
  }
}

Dump all translations

yarn i18n-dump --path ./ --output localizations --mode split

Restore all translations

yarn i18n-restore --path ./ --baseDir localizations --mode split

Readme

Keywords

none

Package Sidebar

Install

npm i @coxy/i18n

Weekly Downloads

2

Version

1.0.14

License

MIT

Unpacked Size

27.6 kB

Total Files

21

Last publish

Collaborators

  • dsshard