Skip to content

Instantly share code, notes, and snippets.

@najlepsiwebdesigner
Last active December 17, 2015 06:39
Show Gist options
  • Save najlepsiwebdesigner/5567076 to your computer and use it in GitHub Desktop.
Save najlepsiwebdesigner/5567076 to your computer and use it in GitHub Desktop.
/* return pluralized form of input type, with respect to amount
*
* @param string type - defines type, possible values are: "hodina", "kus", "mesiac"
* @return string pluralized type in slovak language
*/
function pluralizeAmountSlovak(type, amount){
var dictionary = {
hodina : ['hodina', 'hodiny','hodín'],
kus : ['kus', 'kusy', 'kusov'],
mesiac : ['mesiac', 'mesiace', 'mesiacov']
}
if (dictionary[type] != undefined){
if (amount == 1){
return dictionary[type][0];
}
else if (amount > 1 && amount < 5) {
return dictionary[type][1];
}
else {
return dictionary[type][2];
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment