MediaWiki master
LanguageHy.php
Go to the documentation of this file.
1<?php
25
31class LanguageHy extends Language {
32
33 public function convertGrammar( $word, $case ) {
34 $grammarForms =
35 MediaWikiServices::getInstance()->getMainConfig()->get( MainConfigNames::GrammarForms );
36 if ( isset( $grammarForms['hy'][$case][$word] ) ) {
37 return $grammarForms['hy'][$case][$word];
38 }
39
40 # These rules are not perfect, but they are currently only used for site names so it doesn't
41 # matter if they are wrong sometimes. Just add a special case for your site name if necessary.
42
43 # join and array_slice instead mb_substr
44 $ar = [];
45 preg_match_all( '/./us', $word, $ar );
46 if ( !preg_match( "/[a-zA-Z_]/u", $word ) ) {
47 switch ( $case ) {
48 case 'genitive': # սեռական հոլով
49 if ( implode( '', array_slice( $ar[0], -1 ) ) == 'ա' ) {
50 $word = implode( '', array_slice( $ar[0], 0, -1 ) ) . 'այի';
51 } elseif ( implode( '', array_slice( $ar[0], -1 ) ) == 'ո' ) {
52 $word = implode( '', array_slice( $ar[0], 0, -1 ) ) . 'ոյի';
53 } elseif ( implode( '', array_slice( $ar[0], -4 ) ) == 'գիրք' ) {
54 $word = implode( '', array_slice( $ar[0], 0, -4 ) ) . 'գրքի';
55 } else {
56 $word .= 'ի';
57 }
58 break;
59 case 'dative': # Տրական հոլով
60 # stub
61 break;
62 case 'accusative': # Հայցական հոլով
63 # stub
64 break;
65 case 'instrumental':
66 # stub
67 break;
68 case 'prepositional':
69 # stub
70 break;
71 }
72 }
73 return $word;
74 }
75}
Armenian (Հայերեն)
convertGrammar( $word, $case)
Grammatical transformations, needed for inflected languages Invoked by putting {{grammar:case|word}} ...
Base class for language-specific code.
Definition Language.php:82
A class containing constants representing the names of configuration variables.
Service locator for MediaWiki core services.