LanguageLa.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <?php
  2. /**
  3. * Latin (lingua Latina) specific code.
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License along
  16. * with this program; if not, write to the Free Software Foundation, Inc.,
  17. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  18. * http://www.gnu.org/copyleft/gpl.html
  19. *
  20. * @file
  21. * @ingroup Language
  22. */
  23. /**
  24. * Latin (lingua Latina)
  25. *
  26. * @ingroup Language
  27. */
  28. class LanguageLa extends Language {
  29. /**
  30. * Convert from the nominative form of a noun to some other case
  31. *
  32. * Just used in a couple places for sitenames; special-case as necessary.
  33. * Rules are far from complete.
  34. *
  35. * Cases: genitive, accusative, ablative
  36. *
  37. * @param string $word
  38. * @param string $case
  39. *
  40. * @return string
  41. */
  42. function convertGrammar( $word, $case ) {
  43. global $wgGrammarForms;
  44. if ( isset( $wgGrammarForms['la'][$case][$word] ) ) {
  45. return $wgGrammarForms['la'][$case][$word];
  46. }
  47. switch ( $case ) {
  48. case 'genitive':
  49. // only a few declensions, and even for those mostly the singular only
  50. $in = [
  51. '/u[ms]$/', # 2nd declension singular
  52. '/ommunia$/', # 3rd declension neuter plural (partly)
  53. '/a$/', # 1st declension singular
  54. '/libri$/', '/nuntii$/', '/datae$/', # 2nd declension plural (partly)
  55. '/tio$/', '/ns$/', '/as$/', # 3rd declension singular (partly)
  56. '/es$/' # 5th declension singular
  57. ];
  58. $out = [
  59. 'i',
  60. 'ommunium',
  61. 'ae',
  62. 'librorum', 'nuntiorum', 'datorum',
  63. 'tionis', 'ntis', 'atis',
  64. 'ei'
  65. ];
  66. return preg_replace( $in, $out, $word );
  67. case 'accusative':
  68. // only a few declensions, and even for those mostly the singular only
  69. $in = [
  70. '/u[ms]$/', # 2nd declension singular
  71. '/a$/', # 1st declension singular
  72. '/ommuniam$/', # 3rd declension neuter plural (partly)
  73. '/libri$/', '/nuntii$/', '/datam$/', # 2nd declension plural (partly)
  74. '/tio$/', '/ns$/', '/as$/', # 3rd declension singular (partly)
  75. '/es$/' # 5th declension singular
  76. ];
  77. $out = [
  78. 'um',
  79. 'am',
  80. 'ommunia',
  81. 'libros', 'nuntios', 'data',
  82. 'tionem', 'ntem', 'atem',
  83. 'em'
  84. ];
  85. return preg_replace( $in, $out, $word );
  86. case 'ablative':
  87. // only a few declensions, and even for those mostly the singular only
  88. $in = [
  89. '/u[ms]$/', # 2nd declension singular
  90. '/ommunia$/', # 3rd declension neuter plural (partly)
  91. '/a$/', # 1st declension singular
  92. '/libri$/', '/nuntii$/', '/data$/', # 2nd declension plural (partly)
  93. '/tio$/', '/ns$/', '/as$/', # 3rd declension singular (partly)
  94. '/es$/' # 5th declension singular
  95. ];
  96. $out = [
  97. 'o',
  98. 'ommunibus',
  99. 'a',
  100. 'libris', 'nuntiis', 'datis',
  101. 'tione', 'nte', 'ate',
  102. 'e'
  103. ];
  104. return preg_replace( $in, $out, $word );
  105. default:
  106. return $word;
  107. }
  108. }
  109. }