Created
November 21, 2013 10:50
-
-
Save vishaltelangre/7579641 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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