Merge "Use Title::newFromRow in ApiPageSet::processDbRow"
[lhc/web/wiklou.git] / languages / classes / LanguageLa.php
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 /**
25 * Latin (lingua Latina)
26 *
27 * @ingroup Language
28 */
29 class LanguageLa extends Language {
30 /**
31 * Convert from the nominative form of a noun to some other case
32 *
33 * Just used in a couple places for sitenames; special-case as necessary.
34 * Rules are far from complete.
35 *
36 * Cases: genitive, accusative, ablative
37 *
38 * @param $word string
39 * @param $case string
40 *
41 * @return string
42 */
43 function convertGrammar( $word, $case ) {
44 global $wgGrammarForms;
45 if ( isset( $wgGrammarForms['la'][$case][$word] ) ) {
46 return $wgGrammarForms['la'][$case][$word];
47 }
48
49 switch ( $case ) {
50 case 'genitive':
51 // only a few declensions, and even for those mostly the singular only
52 $in = array( '/u[ms]$/', # 2nd declension singular
53 '/ommunia$/', # 3rd declension neuter plural (partly)
54 '/a$/', # 1st declension singular
55 '/libri$/', '/nuntii$/', # 2nd declension plural (partly)
56 '/tio$/', '/ns$/', '/as$/', # 3rd declension singular (partly)
57 '/es$/' # 5th declension singular
58 );
59 $out = array( 'i',
60 'ommunium',
61 'ae',
62 'librorum', 'nuntiorum',
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 = array( '/u[ms]$/', # 2nd declension singular
70 '/a$/', # 1st declension singular
71 '/ommuniam$/', # 3rd declension neuter plural (partly)
72 '/libri$/', '/nuntii$/', # 2nd declension plural (partly)
73 '/tio$/', '/ns$/', '/as$/', # 3rd declension singular (partly)
74 '/es$/' # 5th declension singular
75 );
76 $out = array( 'um',
77 'am',
78 'ommunia',
79 'libros', 'nuntios',
80 'tionem', 'ntem', 'atem',
81 'em'
82 );
83 return preg_replace( $in, $out, $word );
84 case 'ablative':
85 // only a few declensions, and even for those mostly the singular only
86 $in = array( '/u[ms]$/', # 2nd declension singular
87 '/ommunia$/', # 3rd declension neuter plural (partly)
88 '/a$/', # 1st declension singular
89 '/libri$/', '/nuntii$/', # 2nd declension plural (partly)
90 '/tio$/', '/ns$/', '/as$/', # 3rd declension singular (partly)
91 '/es$/' # 5th declension singular
92 );
93 $out = array( 'o',
94 'ommunibus',
95 'a',
96 'libris', 'nuntiis',
97 'tione', 'nte', 'ate',
98 'e'
99 );
100 return preg_replace( $in, $out, $word );
101 default:
102 return $word;
103 }
104 }
105 }