# @oneforx/react-translator

> This library is intent to be used as a translator of predefined json file that can be created with [react-translator-gui](https://oneforx.net/react-translator/) website

Latest version **1.0.3** (published 2023-09-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install @oneforx/react-translator
pnpm add @oneforx/react-translator
yarn add @oneforx/react-translator
bun add @oneforx/react-translator
```

## Health

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

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2023-09-12 |
| First published | 2021-11-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >= v12.18.4 |
| Dependencies | 1 |
| Unpacked size | 69 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | oneforx |
| Maintainers | bawdeveloppement |

## Links

- npm: https://www.npmjs.com/package/@oneforx/react-translator
- Repository: https://github.com/oneforx/react-translator
- Homepage: https://oneforx.github.io/react-translator
- Issues: https://github.com/oneforx/react-translator/issues
- npm.io page: https://npm.io/package/@oneforx/react-translator

## Dependencies (1)

- [@oneforx/poseidon](https://npm.io/package/@oneforx/poseidon.md) ^0.1.2

## Recent versions

- 1.0.3 (latest) — 2023-09-12
- 1.0.2 — 2023-08-30
- 1.0.1 — 2023-08-30
- 1.0.0 — 2023-08-30
- 0.0.10 — 2023-05-13
- 0.0.9 — 2022-04-03
- 0.0.8 — 2022-02-20
- 0.0.7 — 2022-01-04
- 0.0.6 — 2021-11-24
- 0.0.5 — 2021-11-23
- 0.0.3 — 2021-11-20
- 0.0.2 — 2021-11-20
- 0.0.1 — 2021-11-20

## README

# @oneforx/react-translator
This library is intent to be used as a translator of predefined json file that can be created with [react-translator-gui](https://oneforx.net/react-translator/) website


## locales.json
```json 
{"translate_key":{"fr":"Je suis une traduction","au":"I'm a translation"}}
```

## Example of initialisation
import locales from './locales.json'

```jsx
  const ExampleComponent = () => {
    const translateKey = useTranslator("translate_key");

    return (
      <div>{translateKey}<div>
    )
  }
```

```jsx
  const ExampleComponent2 = () => {
    const translated = useTranslator();

    return (
      <div>{translated["translate_key"]}<div>
    )
  }
```

```jsx
  const App = () => {
    return (
      <ReactTranslatorContextProvider locales={locales}>
        {/**Your components*/}
      </ReactTranslatorContextProvider>
    );
  }
```

## Optimisation
Support for translation in webworker to minimize work done by main web worker, cool for large file. Not fun for old browser that don't support webworker :p

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