Skip to content

Instantly share code, notes, and snippets.

@yuanqing
Created October 10, 2015 08:57
Show Gist options
  • Save yuanqing/dd60a4a90e500178dd5b to your computer and use it in GitHub Desktop.
Save yuanqing/dd60a4a90e500178dd5b to your computer and use it in GitHub Desktop.
var Polyglot = require('node-polyglot');
var phrases = {
x: 'foo',
y: '%{smart_count} bar |||| %{smart_count} bars'
};
var p = new Polyglot({
locale: 'en',
phrases: phrases
});
console.log(p.t('x')); //=> foo
console.log(p.t('y', 0)); //=> 0 bars
console.log(p.t('y', 1)); //=> 1 bar
console.log(p.t('y', 2)); //=> 2 bars
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment