tl8-react
TypeScript icon, indicating that this package has built-in type declarations

0.0.1-beta.4 • Public • Published

tl8-react

Check out tl8.io to learn about TL8 and the open-source repository on Github https://github.com/kevinmerckx/tl8.

This library is the React counter-part of the TL8 solution.

Install

npm install tl8-react

Use

Prepare translation files

Prepare translation files such as en.json:

{
  "some": {
    "textToTranslate": "Here we go",
    "other": "Yes!"
  }
}

Prepare your application

import { TL8Provider } from 'tl8-react';
import en from './en.json';
import fr from './fr.json';

const tl8Config = {
  currentLang: 'en',
  translations: {
    en,
    fr,
  },
};

function App() {
  return <TL8Provider config={tl8Config}>
    <Tl8 of="some.textToTranslate" />
    <Tl8 of="some.other" />
  </TL8Provider>;
}

Get current language and change language

const { setCurrentLanguage, currentLanguage } = useTL8();

Readme

Keywords

none

Package Sidebar

Install

npm i tl8-react

Weekly Downloads

3

Version

0.0.1-beta.4

License

MIT

Unpacked Size

10.6 kB

Total Files

14

Last publish

Collaborators

  • kmpeach