post processor for i18next enabling interval plurals
Switch branches/tags
greenkeeper-babel-cli-6.8.0 greenkeeper-babel-cli-6.10.1 greenkeeper-babel-core-6.5.0 greenkeeper-babel-core-6.5.1 greenkeeper-babel-core-6.5.2 greenkeeper-babel-core-6.6.0 greenkeeper-babel-core-6.6.4 greenkeeper-babel-core-6.6.5 greenkeeper-babel-core-6.7.0 greenkeeper-babel-core-6.7.2 greenkeeper-babel-core-6.7.4 greenkeeper-babel-core-6.7.5 greenkeeper-babel-core-6.7.6 greenkeeper-babel-core-6.7.7 greenkeeper-babel-core-6.8.0 greenkeeper-babel-core-6.9.0 greenkeeper-babel-core-6.9.1 greenkeeper-babel-core-6.10.4 greenkeeper-babel-core-6.11.4 greenkeeper-babel-core-6.13.0 greenkeeper-babel-core-6.13.1 greenkeeper-babel-core-6.13.2 greenkeeper-babel-eslint-5.0.0 greenkeeper-babel-eslint-6.0.0 greenkeeper-babel-eslint-6.0.1 greenkeeper-babel-eslint-6.0.2 greenkeeper-babel-eslint-6.0.3 greenkeeper-babel-eslint-6.0.4 greenkeeper-babel-eslint-6.0.5 greenkeeper-babel-eslint-6.1.0 greenkeeper-babel-eslint-6.1.1 greenkeeper-babel-eslint-6.1.2 greenkeeper-babel-preset-es2015-6.5.0 greenkeeper-babel-preset-es2015-6.6.0 greenkeeper-babel-preset-es2015-6.9.0 greenkeeper-babel-preset-es2015-6.13.0 greenkeeper-babel-preset-es2015-6.13.1 greenkeeper-babel-preset-es2015-6.13.2 greenkeeper-babel-preset-es2015-rollup-1.2.0 greenkeeper-babel-preset-stage-0-6.5.0 greenkeeper-babel-register-6.4.3 greenkeeper-babel-register-6.5.0 greenkeeper-babel-register-6.5.1 greenkeeper-babel-register-6.5.2 greenkeeper-babel-register-6.6.0 greenkeeper-babel-register-6.6.5 greenkeeper-browserify-12.0.2 greenkeeper-browserify-13.0.0 greenkeeper-coveralls-2.11.7 greenkeeper-coveralls-2.11.8 greenkeeper-coveralls-2.11.9 greenkeeper-coveralls-2.11.10 greenkeeper-coveralls-2.11.11 greenkeeper-coveralls-2.11.12 greenkeeper-eslint-2.0.0 greenkeeper-eslint-2.1.0 greenkeeper-eslint-2.2.0 greenkeeper-eslint-2.3.0 greenkeeper-eslint-2.4.0 greenkeeper-eslint-2.5.0 greenkeeper-eslint-2.5.1 greenkeeper-eslint-2.5.2 greenkeeper-eslint-2.5.3 greenkeeper-eslint-2.6.0 greenkeeper-eslint-2.7.0 greenkeeper-eslint-2.8.0 greenkeeper-eslint-2.9.0 greenkeeper-eslint-2.10.0 greenkeeper-eslint-2.10.1 greenkeeper-eslint-2.10.2 greenkeeper-eslint-2.11.0 greenkeeper-eslint-2.11.1 greenkeeper-eslint-2.12.0 greenkeeper-eslint-2.13.0 greenkeeper-eslint-2.13.1 greenkeeper-eslint-3.0.0 greenkeeper-eslint-3.0.1 greenkeeper-eslint-3.1.0 greenkeeper-eslint-3.1.1 greenkeeper-eslint-3.2.0 greenkeeper-eslint-3.2.1 greenkeeper-eslint-3.2.2 greenkeeper-eslint-3.3.0 greenkeeper-eslint-3.3.1 greenkeeper-eslint-config-airbnb-6.2.0 greenkeeper-eslint-config-airbnb-7.0.0 greenkeeper-eslint-config-airbnb-8.0.0 greenkeeper-eslint-config-airbnb-9.0.0 greenkeeper-eslint-config-airbnb-9.0.1 greenkeeper-eslint-config-airbnb-10.0.0 greenkeeper-eslint-config-airbnb-10.0.1 greenkeeper-gulp-3.9.1 greenkeeper-gulp-filter-4.0.0 greenkeeper-gulp-uglify-1.5.2 greenkeeper-gulp-uglify-1.5.3 greenkeeper-i18next-2.2.0 greenkeeper-i18next-2.3.1 greenkeeper-i18next-2.3.2 greenkeeper-i18next-2.3.3 greenkeeper-i18next-2.3.4 greenkeeper-i18next-2.3.5 greenkeeper-i18next-2.4.0 greenkeeper-i18next-2.4.1 greenkeeper-i18next-2.5.0 greenkeeper-i18next-2.5.1 greenkeeper-i18next-3.0.0 greenkeeper-i18next-3.1.0 greenkeeper-i18next-3.2.0 greenkeeper-i18next-3.3.0 greenkeeper-i18next-3.3.1 greenkeeper-i18next-3.4.0 greenkeeper-i18next-3.4.1 greenkeeper-mocha-2.5.0 greenkeeper-mocha-2.5.1 greenkeeper-mocha-2.5.2 greenkeeper-mocha-2.5.3 greenkeeper-mocha-3.0.0 greenkeeper-mocha-3.0.1 greenkeeper-mocha-3.0.2 greenkeeper-rimraf-2.5.3 greenkeeper-rimraf-2.5.4 greenkeeper-rollup-0.25.5 greenkeeper-rollup-0.25.6 greenkeeper-rollup-0.25.7 greenkeeper-rollup-0.25.8 greenkeeper-rollup-0.26.0 greenkeeper-rollup-0.26.1 greenkeeper-rollup-0.26.2 greenkeeper-rollup-0.26.3 greenkeeper-rollup-0.26.4 greenkeeper-rollup-0.26.5 greenkeeper-rollup-0.26.6 greenkeeper-rollup-0.27.0 greenkeeper-rollup-0.27.1 greenkeeper-rollup-0.28.0 greenkeeper-rollup-0.29.0 greenkeeper-rollup-0.29.1 greenkeeper-rollup-0.30.0 greenkeeper-rollup-0.31.0 greenkeeper-rollup-0.31.1 greenkeeper-rollup-0.31.2 greenkeeper-rollup-0.32.0 greenkeeper-rollup-0.32.1 greenkeeper-rollup-0.32.2 greenkeeper-rollup-0.32.3 greenkeeper-rollup-0.32.4 greenkeeper-rollup-0.33.0 greenkeeper-rollup-0.33.1 greenkeeper-rollup-0.33.2 greenkeeper-rollup-0.34.0 greenkeeper-rollup-0.34.1 greenkeeper-rollup-0.34.2 greenkeeper-rollup-0.34.3 greenkeeper-rollup-0.34.4 greenkeeper-rollup-0.34.5 greenkeeper-rollup-0.34.6 greenkeeper-rollup-0.34.7 greenkeeper-rollup-0.34.8 greenkeeper-rollup-0.34.9 greenkeeper-rollup-0.34.10 greenkeeper-rollup-plugin-babel-2.5.0 greenkeeper-rollup-plugin-babel-2.5.1 greenkeeper-rollup-plugin-babel-2.6.0 greenkeeper-rollup-plugin-babel-2.6.1 greenkeeper-rollup-plugin-npm-2.0.0 greenkeeper-rollup-plugin-uglify-1.0.0 greenkeeper-rollup-plugin-uglify-1.0.1 greenkeeper-update-all greenkeeper-yargs-4.1.0 greenkeeper-yargs-4.2.0 greenkeeper-yargs-4.3.1 greenkeeper-yargs-4.3.2 greenkeeper-yargs-4.4.0 greenkeeper-yargs-4.6.0 greenkeeper-yargs-4.7.0 greenkeeper-yargs-4.7.1 greenkeeper-yargs-4.8.0 greenkeeper-yargs-4.8.1 greenkeeper-yargs-5.0.0 master
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
dist
src
test
.babelrc
.coveralls.yml
.editorconfig
.eslintignore
.eslintrc
.gitignore
.npmignore
.travis.yml
LICENSE
README.md
bower.json
i18nextIntervalPluralPostProcessor.js
i18nextIntervalPluralPostProcessor.min.js
index.js
package.json
rollup.config.js

README.md

Introduction

Travis Coveralls npm version Bower David

This is a i18next postProcessor enabling interval based plurals.

Getting started

Source can be loaded via npm, bower or downloaded from this repo.

# npm package
$ npm install i18next-intervalplural-postprocessor

# bower
$ bower install i18next-intervalplural-postprocessor
  • If you don't use a module loader it will be added to window.i18nextIntervalPluralPostProcessor

Wiring up:

import i18next from 'i18next';
import intervalPlural from 'i18next-intervalplural-postprocessor';

i18next
  .use(intervalPlural)
  .init(i18nextOptions);

usage sample

// given loaded resources
// translation: {
//   key1: '{{count}} item',
//    key1_plural: '{{count}} items',
//    key1_interval: '(1){one item};(2-7){a few items};(7-inf){a lot of items};',
//    key2: '{{count}} item',
//    key2_plural: '{{count}} items',
//    key2_interval: '(1){one item};(2-7){a few items};'
// }

i18next.t('key1_interval', { postProcess: 'interval', count: 1 }); // -> one item
i18next.t('key1_interval', { postProcess: 'interval', count: 4 }); // -> a few items
i18next.t('key1_interval', { postProcess: 'interval', count: 100 }); // -> a lot of items

// if a interval is not specified i18next fallbacks to classic plural
i18next.t('key2_interval', { postProcess: 'interval', count: 1 }); // -> one item
i18next.t('key2_interval', { postProcess: 'interval', count: 4 }); // -> a few items
i18next.t('key2_interval', { postProcess: 'interval', count: 100 }); // -> 100 items

setting own options

import i18next from 'i18next';
import intervalPlural from 'i18next-intervalplural-postprocessor';

intervalPlural.setOptions({
  // this are the defaults
  intervalSeparator: ';',
  intervalRegex: /^\((\S*)\){(.*)}$/,
  intervalSuffix: '_interval'
});

i18next
  .use(intervalPlural)
  .init(i18nextOptions);

Gold Sponsors