# i18next2ts

> # Purpose * Are you tired of cpy-paste of translation keys? * Are you in love with TS? * You do hate a typos when providing a translation key? * Want to avoid providing a key that does not exist?

Latest version **1.0.0** (published 2018-07-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install i18next2ts
pnpm add i18next2ts
yarn add i18next2ts
bun add i18next2ts
```

Provides the command `i18next2ts`.

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2018-07-26 |
| First published | 2018-07-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 31.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | kgajowy |
| Maintainers | kgajowy |
| Keywords | ts, tson, typed, json, interface |

## Links

- npm: https://www.npmjs.com/package/i18next2ts
- Homepage: https://github.com/kgajowy/i18next2ts
- npm.io page: https://npm.io/package/i18next2ts

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.0.0 (latest) — 2018-07-26

## README

# Installation

# Purpose
* Are you tired of cpy-paste of translation keys?
* Are you in love with TS?
* You do hate a typos when providing a translation key?
* Want to avoid providing a key that does not exist?

Perfect! I answered `yes` to all the above and made a simple tool for us:

instead of      `i18n.t('auth.password')`

lets write      `i18n.t(typedJson.auth.password)` !

Are you fancy testing it out?

# Quickstart

1) grab this json and save it to some file:
```json
{
  "screenA": {
    "title": "Screen Title",
    "description": "Description",
    "value": "value does not matter, can be empty!"
  },
  "auth": {
    "password": "Password is required!",
    "strangeKey": "does not matter"
  },
  "deepKeys": {
    "lostInSpace": {
      "andTime": {
        "farAwayInAnother": "galaxy"
      }
    }
  }
}
```

2) run `npm i i18next2ts --save-dev` in your project

3) run `i18next2ts translation.json LanguageKeys.ts`

4) create any .ts file to test it
```nodejs
import LocalizationKeys from 'LocalizationKeys'
const json = require('./translation.json');
const typedJson = json as LocalizationKeys;
```

5) now try to type `typedJson.` - tadam! hints are working like a charm.

6) you can now change your `i18n.t('auth.passowrd`)` into `i18n.t(typedJson.auth.password)` instead

# Dependencies:
* no dependencies for module itself!
* CLI uses 'fs' native module

# restrictions
* keys should be .notation acceptable (no - for example)
* types other than `string` or `{}` are not supported - they are not present in the common translation files for i18next

//TODO GIF
//TODO tests
//TODO travis
//TODO coveralls

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