react-translation.js
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

react-translation.js

A translation library to help react applications managing, loading and applying translations.

Usage

Simple example of translation

Add context on top of page

import TranslationJSContext from "react-translation.js"
ReactDOM.render(<React.StrictMode><TranslationJSContext><App/></TranslationJSContext></React.StrictMode>, document.getElementById("root"))

Add translation

import  { LoadTrans, useTranslation } from 'react-translation.js'
const translation = useTranslation();
LoadTrans("pt", { global: { missing: { text: "Texto em Falta" } } }, translation, true)

Use translation

import  { T } from 'react-translation.js'
T("global.missing.text")

T will return Texto em Falta

You can also directly load a JSON.parse() into the LoadTrans function

Development

To build the library all you have to do is run the following commands

  yarn
  yarn build

Package Sidebar

Install

npm i react-translation.js

Weekly Downloads

1

Version

1.0.2

License

GPL-3.0

Unpacked Size

40 kB

Total Files

5

Last publish

Collaborators

  • pedro_s