0.3.7 • Published 4 years ago

labels-manager v0.3.7

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

This is a very simple library you can use to manage your multilanguage in your app.

Usage

  1. Installation

    npm i labels-manager
  2. Create a file with a name like 'locale.json' with the following format and put it in the public/labels sample name it-IT.json

    {
       "demo": {
           "label_01": "Demo Label 01",
           "label_02": "Demo Label 02"
       },
       "anotherContext": {}
    }
  3. Import

    import { LanguageManager } from 'labels-manager';
  4. Load your language (this should be done once an saved in your app state, or update just if you want to reload the labels or change language)

     const [labels, setLabels] = useState({});
     LanguageManager.loadLabels('it-IT').then(response => {
         setLabels(response);
       })
       .catch(err => {
       console.log("Problem loading the Site Labels");
       });
  5. Show a label in code

    const [value, setValue] = useState(true);
    const label = value ? 'demo.label_01' : 'demo.label_02';
    ...
    {LanguageManager.getLabel(labels, label, 'default_ demoLabel')}

Available Scripts

In the project directory, you can run:

npm start

Runs the Demo app in the development mode. Open http://localhost:3000 to view it in the browser.

The page will reload if you make edits. You will also see any lint errors in the console.

npm run distribute

Builds (made for windows) the app for production to the dist folder. It correctly bundles the React component.

npm publish

Publish the dist on npmjs.

License

MIT

0.3.7

4 years ago

0.3.6

4 years ago

0.3.5

4 years ago

0.3.4

4 years ago

0.3.3

4 years ago

0.3.2

4 years ago

0.3.1

4 years ago

0.3.0

4 years ago

0.2.5

4 years ago

0.2.4

4 years ago

0.2.3

4 years ago

0.2.2

4 years ago

0.2.1

4 years ago

0.2.0

4 years ago

0.1.0

4 years ago