# labels-manager

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

Latest version **0.3.7** (published 2020-10-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install labels-manager
pnpm add labels-manager
yarn add labels-manager
bun add labels-manager
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 0.3.7 |
| Published | 2020-10-20 |
| First published | 2020-07-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 4.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | alessandro gambaro |
| Maintainers | alessandro.gambaro |

## Links

- npm: https://www.npmjs.com/package/labels-manager
- Repository: https://github.com/AlessandroGambaro/labelsmanager
- Homepage: https://github.com/AlessandroGambaro/labelsmanager#readme
- Issues: https://github.com/AlessandroGambaro/labelsmanager/issues
- npm.io page: https://npm.io/package/labels-manager

## Recent versions

- 0.3.7 (latest) — 2020-10-20
- 0.3.6 — 2020-10-14
- 0.3.5 — 2020-10-14
- 0.3.4 — 2020-07-22
- 0.3.3 — 2020-07-22
- 0.3.2 — 2020-07-21
- 0.3.1 — 2020-07-21
- 0.3.0 — 2020-07-20
- 0.2.5 — 2020-07-20
- 0.2.4 — 2020-07-20
- 0.2.3 — 2020-07-20
- 0.2.2 — 2020-07-20
- 0.2.1 — 2020-07-20
- 0.2.0 — 2020-07-20
- 0.1.0 — 2020-07-20

## README

This is a very simple library you can use to manage your multilanguage in your app.

## Usage
1. Installation
 ```bash
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

 ```json
 {
    "demo": {
        "label_01": "Demo Label 01",
        "label_02": "Demo Label 02"
    },
    "anotherContext": {}
}
 ```

3. Import
 ```javascript
 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)
 ```javascript
  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
  ```javascript
  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.<br />
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.

The page will reload if you make edits.<br />
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.<br />
It correctly bundles the React component.

### `npm publish`

Publish the dist on npmjs.

## License
[MIT](https://choosealicense.com/licenses/mit/)

---
_Source: https://npm.io/package/labels-manager · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
