Skip to content

Instantly share code, notes, and snippets.

@pfried
Last active December 19, 2015 01:38
Show Gist options
  • Save pfried/5876966 to your computer and use it in GitHub Desktop.
Save pfried/5876966 to your computer and use it in GitHub Desktop.
polyglot.js example
$(document).ready(function() {
var phrases = {
"car" : "%{smart_count} Auto |||| %{smart_count} Autos"
};
var polyglot = new Polyglot({phrases : phrases, locale : "de"});
// Zero form
console.log(polyglot.t("car",{ "smart_count" : 0}));
// Singular form
console.log(polyglot.t("car",{ "smart_count" : 1}));
// Plural form
console.log(polyglot.t("car",{ "smart_count" : 11}));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment