MediaWiki  1.30.0
LanguageUz.php
Go to the documentation of this file.
1 <?php
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  'ъ' => 'ʼ',
65  ];
66 
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  'ʼ' => 'ъ',
104  ];
105 
106  function loadDefaultTables() {
107  $this->mTables = [
108  'uz-cyrl' => new ReplacementArray( $this->toCyrillic ),
109  'uz-latn' => new ReplacementArray( $this->toLatin ),
110  'uz' => new ReplacementArray()
111  ];
112  }
113 
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 );
122  }
123  return parent::translate( $text, $toVariant );
124  }
125 
126 }
127 
133 class LanguageUz extends Language {
134  function __construct() {
135  parent::__construct();
136 
137  $variants = [ 'uz', 'uz-latn', 'uz-cyrl' ];
138  $variantfallbacks = [
139  'uz' => 'uz-latn',
140  'uz-cyrl' => 'uz',
141  'uz-latn' => 'uz',
142  ];
143 
144  $this->mConverter = new UzConverter( $this, 'uz', $variants, $variantfallbacks );
145  }
146 }
LanguageUz\__construct
__construct()
Definition: LanguageUz.php:134
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
UzConverter\$toCyrillic
$toCyrillic
Definition: LanguageUz.php:67
UzConverter
Definition: LanguageUz.php:27
ReplacementArray
Wrapper around strtr() that holds replacements.
Definition: ReplacementArray.php:24
LanguageUz
Uzbek.
Definition: LanguageUz.php:133
UzConverter\$toLatin
$toLatin
Definition: LanguageUz.php:28
UzConverter\translate
translate( $text, $toVariant)
Definition: LanguageUz.php:114
Makefile.translate
def translate(text, conv_table)
Definition: Makefile.py:235
UzConverter\loadDefaultTables
loadDefaultTables()
Definition: LanguageUz.php:106
Language
Internationalisation code.
Definition: Language.php:35