Debian Codegraph @

includes/languages/LanguageLa.php

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