Skip to content

Instantly share code, notes, and snippets.

@najlepsiwebdesigner
Created May 13, 2013 10:22
Show Gist options
  • Save najlepsiwebdesigner/5567393 to your computer and use it in GitHub Desktop.
Save najlepsiwebdesigner/5567393 to your computer and use it in GitHub Desktop.
<?php
/* 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){
$amount = $amount * 1;
var_dump($type);
var_dump($amount);
$dictionary = array(
'hodina' => array ('hodina', 'hodiny','hodín'),
'kus' => array('kus', 'kusy', 'kusov'),
'mesiac' => array('mesiac', 'mesiace', 'mesiacov'),
);
if (is_array($dictionary[$type]) > 0) {
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