# i18next-sprintf-postprocessor

> backend layer for i18next using browsers xhr

Latest version **0.2.2** (published 2016-03-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install i18next-sprintf-postprocessor
pnpm add i18next-sprintf-postprocessor
yarn add i18next-sprintf-postprocessor
bun add i18next-sprintf-postprocessor
```

## Health

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

Positive: has types package; no vulnerabilities; high maintenance score.

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

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 0.2.2 |
| Published | 2016-03-10 |
| First published | 2015-10-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/i18next-sprintf-postprocessor) |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 27 |
| Author | Jan Mühlemann |
| Maintainers | jamuhl |
| Keywords | i18next, i18next-postProcessor, i18next-sprintf |

## Links

- npm: https://www.npmjs.com/package/i18next-sprintf-postprocessor
- Repository: https://github.com/i18next/i18next-sprintf-postProcessor
- Issues: https://github.com/i18next/i18next-sprintf-postProcessor
- npm.io page: https://npm.io/package/i18next-sprintf-postprocessor

## 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

- 0.2.2 (latest) — 2016-03-10
- 0.2.1 — 2016-03-09
- 0.2.0 — 2016-03-09
- 0.1.0 — 2016-03-04
- 0.0.6 — 2015-12-16
- 0.0.5 — 2015-10-29
- 0.0.3 — 2015-10-28
- 0.0.2 — 2015-10-28
- 0.0.1 — 2015-10-28

## README

# Introduction

This is a i18next postProcessor enabling sprintf usage for translations.

# Getting started

Source can be loaded via [npm](https://www.npmjs.com/package/i18next-sprintf-postprocessor), bower or [downloaded](https://github.com/i18next/i18next-sprintf-postprocessor/blob/master/i18nextSprintfPostProcessor.min.js) from this repo.

```
# npm package
$ npm install i18next-sprintf-postprocessor

# bower
$ bower install i18next-sprintf-postprocessor
```

- If you don't use a module loader it will be added to window.i18nextSprintfPostProcessor


Wiring up:

```js
import i18next from 'i18next';
import sprintf from 'i18next-sprintf-postprocessor';

i18next
  .use(sprintf)
  .init(i18nextOptions);
```

# usage sample

```js
// given loaded resources
// translation: {
//   key1: 'The first 4 letters of the english alphabet are: %s, %s, %s and %s',
//   key2: 'Hello %(users[0].name)s, %(users[1].name)s and %(users[2].name)s',
//   key3: 'The last letter of the english alphabet is %s',
//   key3: 'Water freezes at %d degrees'
// }

i18next.t('key1', { postProcess: 'sprintf', sprintf: ['a', 'b', 'c', 'd'] });
// --> 'The first 4 letters of the english alphabet are: a, b, c and d'

i18next.t('key2', { postProcess: 'sprintf', sprintf: { users: [{name: 'Dolly'}, {name: 'Molly'}, {name: 'Polly'}] } });
// --> 'Hello Dolly, Molly and Polly'
```

# Using overloadTranslationOptionHandler

```js
import i18next from 'i18next';
import sprintf from 'i18next-sprintf-postprocessor';

i18next.init({
  overloadTranslationOptionHandler: sprintf.overloadTranslationOptionHandler
});

// given loaded resources
// translation: {
//   key1: 'The first 4 letters of the english alphabet are: %s, %s, %s and %s',
//   key2: 'Hello %(users[0].name)s, %(users[1].name)s and %(users[2].name)s',
//   key3: 'The last letter of the english alphabet is %s',
//   key3: 'Water freezes at %d degrees'
// }

i18next.t('interpolationTest1', 'a', 'b', 'c', 'd');
// --> 'The first 4 letters of the english alphabet are: a, b, c and d'

i18next.t('interpolationTest3', 'z');
// --> 'The last letter of the english alphabet is z'

i18next.t('interpolationTest4', 0);
// --> 'Water freezes at 0 degrees'
```

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