Merge "Remove not used private member variable mParserWarnings from OutputPage"
[mediawiki.git] / languages / classes / LanguageUz.php
blob985de68e068f694e19349e27a161bd6d0406ed26
1 <?php
2 /**
3 * Uzbek specific code.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
20 * @file
21 * @ingroup Language
24 require_once __DIR__ . '/../LanguageConverter.php';
26 /**
27 * @ingroup Language
29 class UzConverter extends LanguageConverter {
30 public $toLatin = array(
31 'а' => 'a', 'А' => 'A',
32 'б' => 'b', 'Б' => 'B',
33 'д' => 'd', 'Д' => 'D',
34 'е' => 'e', 'Е' => 'E',
35 'э' => 'e', 'Э' => 'E',
36 'в' => 'v', 'В' => 'V',
37 'х' => 'x', 'Х' => 'X',
38 'ғ' => 'gʻ', 'Ғ' => 'Gʻ',
39 'г' => 'g', 'Г' => 'G',
40 'ҳ' => 'h', 'Ҳ' => 'H',
41 'ж' => 'j', 'Ж' => 'J',
42 'з' => 'z', 'З' => 'Z',
43 'и' => 'i', 'И' => 'I',
44 'к' => 'k', 'К' => 'K',
45 'л' => 'l', 'Л' => 'L',
46 'м' => 'm', 'М' => 'M',
47 'н' => 'n', 'Н' => 'N',
48 'о' => 'o', 'О' => 'O',
49 'п' => 'p', 'П' => 'P',
50 'р' => 'r', 'Р' => 'R',
51 'с' => 's', 'С' => 'S',
52 'т' => 't', 'Т' => 'T',
53 'у' => 'u', 'У' => 'U',
54 'ф' => 'f', 'Ф' => 'F',
55 'ц' => 'c', 'Ц' => 'C',
56 'ў' => 'oʻ', 'Ў' => 'Oʻ',
57 // note: at the beginning of a word and right after a consonant, only "s" is used
58 'ц' => 'ts', 'Ц' => 'Ts',
59 'қ' => 'q', 'Қ' => 'Q',
60 'ё' => 'yo', 'Ё' => 'Yo',
61 'ю' => 'yu', 'Ю' => 'Yu',
62 'ч' => 'ch', 'Ч' => 'Ch',
63 'ш' => 'sh', 'Ш' => 'Sh',
64 'й' => 'y', 'Й' => 'Y',
65 'я' => 'ya', 'Я' => 'Ya',
66 'ъ' => 'ʼ',
69 public $toCyrillic = array(
70 'a' => 'а', 'A' => 'А',
71 'b' => 'б', 'B' => 'Б',
72 'd' => 'д', 'D' => 'Д',
73 // at the beginning of a word and after a vowel, "э" is used instead of "e"
74 // (see regex below)
75 'e' => 'э', 'E' => 'Э',
76 'f' => 'ф', 'F' => 'Ф',
77 'g' => 'г', 'G' => 'Г',
78 'g‘' => 'ғ', 'G‘' => 'Ғ', 'gʻ' => 'ғ', 'Gʻ' => 'Ғ',
79 'h' => 'ҳ', 'H' => 'Ҳ',
80 'i' => 'и', 'I' => 'И',
81 'k' => 'к', 'K' => 'К',
82 'l' => 'л', 'L' => 'Л',
83 'm' => 'м', 'M' => 'М',
84 'n' => 'н', 'N' => 'Н',
85 'o' => 'о', 'O' => 'О',
86 'p' => 'п', 'P' => 'П',
87 'r' => 'р', 'R' => 'Р',
88 's' => 'с', 'S' => 'С',
89 't' => 'т', 'T' => 'Т',
90 'u' => 'у', 'U' => 'У',
91 'v' => 'в', 'V' => 'В',
92 'x' => 'х', 'X' => 'Х',
93 'z' => 'з', 'Z' => 'З',
94 'j' => 'ж', 'J' => 'Ж',
95 'o‘' => 'ў', 'O‘' => 'Ў', 'oʻ' => 'ў', 'Oʻ' => 'Ў',
96 'yo‘' => 'йў', 'Yo‘' => 'Йў', 'yoʻ' => 'йў', 'Yoʻ' => 'Йў',
97 'ts' => 'ц', 'Ts' => 'Ц',
98 'q' => 'қ', 'Q' => 'Қ',
99 'yo' => 'ё', 'Yo' => 'Ё',
100 'yu' => 'ю', 'Yu' => 'Ю',
101 'ch' => 'ч', 'Ch' => 'Ч',
102 'sh' => 'ш', 'Sh' => 'Ш',
103 'y' => 'й', 'Y' => 'Й',
104 'ya' => 'я', 'Ya' => 'Я',
105 'ʼ' => 'ъ',
108 function loadDefaultTables() {
109 $this->mTables = array(
110 'uz-cyrl' => new ReplacementArray( $this->toCyrillic ),
111 'uz-latn' => new ReplacementArray( $this->toLatin ),
112 'uz' => new ReplacementArray()
116 function translate( $text, $toVariant ) {
117 if ( $toVariant == 'uz-cyrl' ) {
118 $text = str_replace( 'ye', 'е', $text );
119 $text = str_replace( 'Ye', 'Е', $text );
120 $text = str_replace( 'YE', 'Е', $text );
121 // "е" after consonants, otherwise "э" (see above)
122 $text = preg_replace( '/([BVGDJZYKLMNPRSTFXCWQʻ‘H])E/u', '$1Е', $text );
123 $text = preg_replace( '/([bvgdjzyklmnprstfxcwqʻ‘h])e/ui', '$1е', $text );
125 return parent::translate( $text, $toVariant );
131 * Uzbek
133 * @ingroup Language
135 class LanguageUz extends Language {
136 function __construct() {
137 global $wgHooks;
138 parent::__construct();
140 $variants = array( 'uz', 'uz-latn', 'uz-cyrl' );
141 $variantfallbacks = array(
142 'uz' => 'uz-latn',
143 'uz-cyrl' => 'uz',
144 'uz-latn' => 'uz',
147 $this->mConverter = new UzConverter( $this, 'uz', $variants, $variantfallbacks );
148 $wgHooks['PageContentSaveComplete'][] = $this->mConverter;