Skip to content

Instantly share code, notes, and snippets.

@vishaltelangre
Created November 21, 2013 10:50
Show Gist options
  • Save vishaltelangre/7579641 to your computer and use it in GitHub Desktop.
Save vishaltelangre/7579641 to your computer and use it in GitHub Desktop.
var pluralForms = {
"en" : function ( x ) {
if ( x === 1 ) {
return 0;
}
return 1;
},
"fr" : function ( x ) {
if ( x > 1 ) {
return 1;
}
return 0;
}
};
var translations = {
"en" : {
"somekey" : [ "There is one result.", "There are %s results." ]
}
"fr" : {
"somekey" : [ "Le, there is %s result.", "Le, there are %s results." ]
}
}
var lang = "en";
var msg = sprintf( translations[ lang ][ "somekey" ][ pluralForms[ lang ]( X ) ], X );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment