langfunctionlib.php 713 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. function get_plural($word)
  3. {
  4. if ($word[strlen($word) - 1] === 's') {
  5. $ret = "{$word}es";
  6. } else if ($word[strlen($word) - 1] === 'y') {
  7. if ($word[strlen($word) - 2] === 'e') {
  8. $ret = "{$word}s";
  9. } else {
  10. $ret = substr($word, 0, strlen($word) - 1) . "ies";
  11. }
  12. } else if ($word[strlen($word) - 1] === 'x') {
  13. $ret = substr($word, 0, strlen($word) - 1) . "xes";
  14. } else {
  15. $ret = "{$word}s";
  16. }
  17. return ucfirst($ret);
  18. }
  19. // This is an alternate get_plural, which has the all the plurals are defined in a file.
  20. function get_plural_alternate($word)
  21. {
  22. include_once "lang/en-us/lang_plural.inc";
  23. if (isset($__plural_desc[$word])) {
  24. return $__plural_desc[$word];
  25. }
  26. return "{$word}s";
  27. }