Introduction
This is a i18next postProcessor enabling sprintf usage for translations.
Getting started
Source can be loaded via npm, bower or downloaded 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:
;; i18next ;
usage sample
// 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;// --> 'The first 4 letters of the english alphabet are: a, b, c and d' i18next;// --> 'Hello Dolly, Molly and Polly'
Using overloadTranslationOptionHandler
;; i18next; // 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;// --> 'The first 4 letters of the english alphabet are: a, b, c and d' i18next;// --> 'The last letter of the english alphabet is z' i18next;// --> 'Water freezes at 0 degrees'