MediaWiki  master
LanguageUz.php
Go to the documentation of this file.
1 <?php
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  'ў' => 'oʻ', 'Ў' => 'Oʻ',
54  // note: at the beginning of a word and right after a consonant, only "s" is used
55  'ц' => 'ts', 'Ц' => 'Ts',
56  'қ' => 'q', 'Қ' => 'Q',
57  'ё' => 'yo', 'Ё' => 'Yo',
58  'ю' => 'yu', 'Ю' => 'Yu',
59  'ч' => 'ch', 'Ч' => 'Ch',
60  'ш' => 'sh', 'Ш' => 'Sh',
61  'й' => 'y', 'Й' => 'Y',
62  'я' => 'ya', 'Я' => 'Ya',
63  'ъ' => 'ʼ',
64  ];
65 
66  public $toCyrillic = [
67  'a' => 'а', 'A' => 'А',
68  'b' => 'б', 'B' => 'Б',
69  'd' => 'д', 'D' => 'Д',
70  // at the beginning of a word and after a vowel, "э" is used instead of "e"
71  // (see regex below)
72  'e' => 'э', 'E' => 'Э',
73  'f' => 'ф', 'F' => 'Ф',
74  'g' => 'г', 'G' => 'Г',
75  'g‘' => 'ғ', 'G‘' => 'Ғ', 'gʻ' => 'ғ', 'Gʻ' => 'Ғ',
76  'h' => 'ҳ', 'H' => 'Ҳ',
77  'i' => 'и', 'I' => 'И',
78  'k' => 'к', 'K' => 'К',
79  'l' => 'л', 'L' => 'Л',
80  'm' => 'м', 'M' => 'М',
81  'n' => 'н', 'N' => 'Н',
82  'o' => 'о', 'O' => 'О',
83  'p' => 'п', 'P' => 'П',
84  'r' => 'р', 'R' => 'Р',
85  's' => 'с', 'S' => 'С',
86  't' => 'т', 'T' => 'Т',
87  'u' => 'у', 'U' => 'У',
88  'v' => 'в', 'V' => 'В',
89  'x' => 'х', 'X' => 'Х',
90  'z' => 'з', 'Z' => 'З',
91  'j' => 'ж', 'J' => 'Ж',
92  'o‘' => 'ў', 'O‘' => 'Ў', 'oʻ' => 'ў', 'Oʻ' => 'Ў',
93  'yo‘' => 'йў', 'Yo‘' => 'Йў', 'yoʻ' => 'йў', 'Yoʻ' => 'Йў',
94  'ts' => 'ц', 'Ts' => 'Ц',
95  'q' => 'қ', 'Q' => 'Қ',
96  'yo' => 'ё', 'Yo' => 'Ё',
97  'yu' => 'ю', 'Yu' => 'Ю',
98  'ch' => 'ч', 'Ch' => 'Ч',
99  'sh' => 'ш', 'Sh' => 'Ш',
100  'y' => 'й', 'Y' => 'Й',
101  'ya' => 'я', 'Ya' => 'Я',
102  'ʼ' => 'ъ',
103  ];
104 
105  function loadDefaultTables() {
106  $this->mTables = [
107  'uz-cyrl' => new ReplacementArray( $this->toCyrillic ),
108  'uz-latn' => new ReplacementArray( $this->toLatin ),
109  'uz' => new ReplacementArray()
110  ];
111  }
112 
113  function translate( $text, $toVariant ) {
114  if ( $toVariant == 'uz-cyrl' ) {
115  $text = str_replace( 'ye', 'е', $text );
116  $text = str_replace( 'Ye', 'Е', $text );
117  $text = str_replace( 'YE', 'Е', $text );
118  // "е" after consonants, otherwise "э" (see above)
119  $text = preg_replace( '/([BVGDJZYKLMNPRSTFXCWQʻ‘H])E/u', '$1Е', $text );
120  $text = preg_replace( '/([bvgdjzyklmnprstfxcwqʻ‘h])e/ui', '$1е', $text );
121  }
122  return parent::translate( $text, $toVariant );
123  }
124 
125 }
126 
132 class LanguageUz extends Language {
133  function __construct() {
134  parent::__construct();
135 
136  $variants = [ 'uz', 'uz-latn', 'uz-cyrl' ];
137  $variantfallbacks = [
138  'uz' => 'uz-latn',
139  'uz-cyrl' => 'uz',
140  'uz-latn' => 'uz',
141  ];
142 
143  $this->mConverter = new UzConverter( $this, 'uz', $variants, $variantfallbacks );
144  }
145 }
Wrapper around strtr() that holds replacements.
Uzbek.
Definition: LanguageUz.php:132
def translate(text, conv_table)
Definition: Makefile.py:235
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
translate( $text, $toVariant)
Definition: LanguageUz.php:113