MediaWiki
master
Toggle main menu visibility
LanguageHy.php
Go to the documentation of this file.
1
<?php
7
8
namespace
MediaWiki\Languages;
9
10
use MediaWiki\Language\Language;
11
use MediaWiki\MainConfigNames;
12
use MediaWiki\MediaWikiServices;
13
19
class
LanguageHy
extends
Language
{
20
22
public
function
convertGrammar
( $word, $case ) {
23
$grammarForms =
24
MediaWikiServices::getInstance
()->getMainConfig()->get(
MainConfigNames::GrammarForms
);
25
if
( isset( $grammarForms[
'hy'
][$case][$word] ) ) {
26
return
$grammarForms[
'hy'
][$case][$word];
27
}
28
29
# These rules are not perfect, but they are currently only used for site names so it doesn't
30
# matter if they are wrong sometimes. Just add a special case for your site name if necessary.
31
32
# join and array_slice instead mb_substr
33
$ar = [];
34
preg_match_all(
'/./us'
, $word, $ar );
35
if
( !preg_match(
"/[a-zA-Z_]/u"
, $word ) ) {
36
switch
( $case ) {
37
case
'genitive'
: # սեռական հոլով
38
if
( implode(
''
, array_slice( $ar[0], -1 ) ) ==
'ա'
) {
39
$word = implode(
''
, array_slice( $ar[0], 0, -1 ) ) .
'այի'
;
40
} elseif ( implode(
''
, array_slice( $ar[0], -1 ) ) ==
'ո'
) {
41
$word = implode(
''
, array_slice( $ar[0], 0, -1 ) ) .
'ոյի'
;
42
} elseif ( implode(
''
, array_slice( $ar[0], -4 ) ) ==
'գիրք'
) {
43
$word = implode(
''
, array_slice( $ar[0], 0, -4 ) ) .
'գրքի'
;
44
}
else
{
45
$word .=
'ի'
;
46
}
47
break
;
48
case
'dative'
: # Տրական հոլով
49
# stub
50
break
;
51
case
'accusative'
: # Հայցական հոլով
52
# stub
53
break
;
54
case
'instrumental'
:
55
# stub
56
break
;
57
case
'prepositional'
:
58
# stub
59
break
;
60
}
61
}
62
return
$word;
63
}
64
}
65
67
class_alias( LanguageHy::class,
'LanguageHy'
);
MediaWiki\Language\Language
Base class for language-specific code.
Definition
Language.php:65
MediaWiki\Languages\LanguageHy
Armenian (Հայերեն).
Definition
LanguageHy.php:19
MediaWiki\Languages\LanguageHy\convertGrammar
convertGrammar( $word, $case)
Grammatical transformations, needed for inflected languages Invoked by putting {{grammar:case|word}...
Definition
LanguageHy.php:22
MediaWiki\MainConfigNames\GrammarForms
const GrammarForms
Name constant for the GrammarForms setting, for use with Config\get().
Definition
MainConfigNames.php:1824
MediaWiki\MediaWikiServices\getInstance
static getInstance()
Returns the global default instance of the top level service locator.
Definition
MediaWikiServices.php:361
includes
Languages
LanguageHy.php
Generated on
for MediaWiki by
1.18.0