1.0.6 • Published 6 years ago

i18n-react-json v1.0.6

Weekly downloads
9
License
MIT
Repository
github
Last release
6 years ago

Build Status

i18n-react-json

i18n-react-json

A simple translator for Reactjs load languages from json file.

Install

In your react project, run one of these commands:

$ yarn add i18n-react-json

or

$ npm i i18n-react-json

Configuration

Lets create your files respository, for example: "locales"

|--project
  |--public
  |--src
    |--locales
      |-- en.json
      |-- pt.json

In the json file, for example:

// pt.json
{
    "Hello" : "Olá",
    "I am Gaspar": "Eu sou Gaspar"
}

Using it

In your App.js lets import and set the language.

//project/src/App.js
import Translate from "i18n-react-json";
import locales from "./locales";

// call tranlation
const i18n = new Translate(locales);

//set default language
i18n.setLocale("pt");

class App extends Component {
render() {
    return (
      <div className="App">
        <p>{i18n.__("Hello")}, {i18n.__("I am Gaspar")}!</p>
      </div>
    );
}
export default App;

I also provided an example take a look or download it and run in your environment.

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago