# traduire

> simple i18n translator using explicit typescript models

Latest version **1.1.0** (published 2021-05-09) · LICENSE license · 0 weekly downloads

## Install

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

## 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.1.0 |
| Published | 2021-05-09 |
| First published | 2021-02-21 |
| Weekly downloads | 0 |
| License | LICENSE |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 4.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Haci Murat Yaman |
| Maintainers | muratyaman |
| Keywords | i18n, translate |

## Links

- npm: https://www.npmjs.com/package/traduire
- Repository: https://github.com/muratyaman/traduire
- Homepage: https://github.com/muratyaman/traduire#readme
- Issues: https://github.com/muratyaman/traduire/issues
- npm.io page: https://npm.io/package/traduire

## Alternatives

- [messageformat](https://npm.io/package/messageformat.md) — 329.7K weekly downloads
- [@mintlify/scraping](https://npm.io/package/@mintlify/scraping.md) — 294.8K weekly downloads
- [@mintlify/previewing](https://npm.io/package/@mintlify/previewing.md) — 209.5K weekly downloads
- [@mintlify/prebuild](https://npm.io/package/@mintlify/prebuild.md) — 209.5K weekly downloads
- [@mintlify/link-rot](https://npm.io/package/@mintlify/link-rot.md) — 206.3K weekly downloads

## Recent versions

- 1.1.0 (latest) — 2021-05-09
- 1.0.2 — 2021-02-22
- 1.0.1 — 2021-02-22
- 1.0.0 — 2021-02-21

## README

# traduire
simple i18n translator using explicit typescript models

```typescript
import en from './en.json';
import fr from './fr.json';
import { Traduire, TransDataToInject } from 'traduire';

// this is expected structure in JSON files: Record<string, string>
const sample = {
  welcome: '',
  title: '',
  label: '',
};

// infer type from sample data
type TranslationSet = typeof sample;

interface TranslationSets {
  [code: string]: TranslationSet;
}

// this line would tell you if JSON files are incorrect
const translations: TranslationSets = {
  en,
  fr,
};

const t = new Traduire<TranslationSet>('fr', fr);

// this is a flat object Record<string, string> or null;
const params: TransDataToInject = {
  username: 'Haci',
};

// this line would tell you if key 'welcome' is incorrect
const text: string = t._('welcome', params);
```

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