MediaWiki master
LanguageLa.php
Go to the documentation of this file.
1<?php
24
30class LanguageLa extends Language {
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}
Latin (lingua Latina)
convertGrammar( $word, $case)
Convert from the nominative form of a noun to some other case.
Base class for language-specific code.
Definition Language.php:81
A class containing constants representing the names of configuration variables.
Service locator for MediaWiki core services.