Merge "Added release notes for 'ContentHandler::runLegacyHooks' removal"
[mediawiki.git] / languages / classes / LanguageUz.php
blobe205dc97c61bfbee2e6109ee3337962dc7acb0f1
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 /**
25 * @ingroup Language
27 class UzConverter extends LanguageConverter {
28 public $toLatin = [
29 'а' => 'a', 'А' => 'A',
30 'б' => 'b', 'Б' => 'B',
31 'д' => 'd', 'Д' => 'D',
32 'е' => 'e', 'Е' => 'E',
33 'э' => 'e', 'Э' => 'E',
34 'в' => 'v', 'В' => 'V',
35 'х' => 'x', 'Х' => 'X',
36 'ғ' => 'gʻ', 'Ғ' => 'Gʻ',
37 'г' => 'g', 'Г' => 'G',
38 'ҳ' => 'h', 'Ҳ' => 'H',
39 'ж' => 'j', 'Ж' => 'J',
40 'з' => 'z', 'З' => 'Z',
41 'и' => 'i', 'И' => 'I',
42 'к' => 'k', 'К' => 'K',
43 'л' => 'l', 'Л' => 'L',
44 'м' => 'm', 'М' => 'M',
45 'н' => 'n', 'Н' => 'N',
46 'о' => 'o', 'О' => 'O',
47 'п' => 'p', 'П' => 'P',
48 'р' => 'r', 'Р' => 'R',
49 'с' => 's', 'С' => 'S',
50 'т' => 't', 'Т' => 'T',
51 'у' => 'u', 'У' => 'U',
52 'ф' => 'f', 'Ф' => 'F',
53 'ц' => 'c', 'Ц' => 'C',
54 'ў' => 'oʻ', 'Ў' => 'Oʻ',
55 // note: at the beginning of a word and right after a consonant, only "s" is used
56 'ц' => 'ts', 'Ц' => 'Ts',
57 'қ' => 'q', 'Қ' => 'Q',
58 'ё' => 'yo', 'Ё' => 'Yo',
59 'ю' => 'yu', 'Ю' => 'Yu',
60 'ч' => 'ch', 'Ч' => 'Ch',
61 'ш' => 'sh', 'Ш' => 'Sh',
62 'й' => 'y', 'Й' => 'Y',
63 'я' => 'ya', 'Я' => 'Ya',
64 'ъ' => 'ʼ',
67 public $toCyrillic = [
68 'a' => 'а', 'A' => 'А',
69 'b' => 'б', 'B' => 'Б',
70 'd' => 'д', 'D' => 'Д',
71 // at the beginning of a word and after a vowel, "э" is used instead of "e"
72 // (see regex below)
73 'e' => 'э', 'E' => 'Э',
74 'f' => 'ф', 'F' => 'Ф',
75 'g' => 'г', 'G' => 'Г',
76 'g‘' => 'ғ', 'G‘' => 'Ғ', 'gʻ' => 'ғ', 'Gʻ' => 'Ғ',
77 'h' => 'ҳ', 'H' => 'Ҳ',
78 'i' => 'и', 'I' => 'И',
79 'k' => 'к', 'K' => 'К',
80 'l' => 'л', 'L' => 'Л',
81 'm' => 'м', 'M' => 'М',
82 'n' => 'н', 'N' => 'Н',
83 'o' => 'о', 'O' => 'О',
84 'p' => 'п', 'P' => 'П',
85 'r' => 'р', 'R' => 'Р',
86 's' => 'с', 'S' => 'С',
87 't' => 'т', 'T' => 'Т',
88 'u' => 'у', 'U' => 'У',
89 'v' => 'в', 'V' => 'В',
90 'x' => 'х', 'X' => 'Х',
91 'z' => 'з', 'Z' => 'З',
92 'j' => 'ж', 'J' => 'Ж',
93 'o‘' => 'ў', 'O‘' => 'Ў', 'oʻ' => 'ў', 'Oʻ' => 'Ў',
94 'yo‘' => 'йў', 'Yo‘' => 'Йў', 'yoʻ' => 'йў', 'Yoʻ' => 'Йў',
95 'ts' => 'ц', 'Ts' => 'Ц',
96 'q' => 'қ', 'Q' => 'Қ',
97 'yo' => 'ё', 'Yo' => 'Ё',
98 'yu' => 'ю', 'Yu' => 'Ю',
99 'ch' => 'ч', 'Ch' => 'Ч',
100 'sh' => 'ш', 'Sh' => 'Ш',
101 'y' => 'й', 'Y' => 'Й',
102 'ya' => 'я', 'Ya' => 'Я',
103 'ʼ' => 'ъ',
106 function loadDefaultTables() {
107 $this->mTables = [
108 'uz-cyrl' => new ReplacementArray( $this->toCyrillic ),
109 'uz-latn' => new ReplacementArray( $this->toLatin ),
110 'uz' => new ReplacementArray()
114 function translate( $text, $toVariant ) {
115 if ( $toVariant == 'uz-cyrl' ) {
116 $text = str_replace( 'ye', 'е', $text );
117 $text = str_replace( 'Ye', 'Е', $text );
118 $text = str_replace( 'YE', 'Е', $text );
119 // "е" after consonants, otherwise "э" (see above)
120 $text = preg_replace( '/([BVGDJZYKLMNPRSTFXCWQʻ‘H])E/u', '$1Е', $text );
121 $text = preg_replace( '/([bvgdjzyklmnprstfxcwqʻ‘h])e/ui', '$1е', $text );
123 return parent::translate( $text, $toVariant );
129 * Uzbek
131 * @ingroup Language
133 class LanguageUz extends Language {
134 function __construct() {
135 parent::__construct();
137 $variants = [ 'uz', 'uz-latn', 'uz-cyrl' ];
138 $variantfallbacks = [
139 'uz' => 'uz-latn',
140 'uz-cyrl' => 'uz',
141 'uz-latn' => 'uz',
144 $this->mConverter = new UzConverter( $this, 'uz', $variants, $variantfallbacks );