Debian Codegraph @

includes/languages/LanguageHy.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 * @author Ruben Vardanyan ([email protected])
20 */
21
22 use MediaWiki\Language\Language;
23 use MediaWiki\MainConfigNames;
24 use MediaWiki\MediaWikiServices;
25
26 /**
27 * Armenian (Հայերեն)
28 *
29 * @ingroup Languages
30 */
31 class 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 }