MediaWiki  1.30.2
LanguageKu.php
Go to the documentation of this file.
1 <?php
29 class KuConverter extends LanguageConverter {
30  public $mArabicToLatin = [
31  'ب' => 'b', 'ج' => 'c', 'چ' => 'ç', 'د' => 'd', 'ف' => 'f', 'گ' => 'g', 'ھ' => 'h',
32  'ہ' => 'h', 'ه' => 'h', 'ح' => 'h', 'ژ' => 'j', 'ك' => 'k', 'ک' => 'k', 'ل' => 'l',
33  'م' => 'm', 'ن' => 'n', 'پ' => 'p', 'ق' => 'q', 'ر' => 'r', 'س' => 's', 'ش' => 'ş',
34  'ت' => 't', 'ڤ' => 'v', 'خ' => 'x', 'غ' => 'x', 'ز' => 'z',
35 
36 // ک و => ku -- ist richtig
37 // و ك=> ku -- ist auch richtig
38 
39  /* Doppel- und Halbvokale */
40  'ڵ' => 'll', # ll
41  'ڕ' => 'rr', # rr
42  'ا' => 'a',
43  # 'ئێ' => 'ê', # initial e
44  'ە' => 'e',
45  'ه‌' => 'e', # with one non-joiner
46  'ه‌‌' => 'e', # with two non-joiner
47  'ة' => 'e',
48  'ێ' => 'ê',
49  'ي' => 'î',
50  'ی' => 'î', # U+06CC db 8c ARABIC LETTER FARSI YEH
51  'ى' => 'î', # U+0649 d9 89 ARABIC LETTER ALEF MAKSURA
52  'ۆ' => 'o',
53  'و' => 'w',
54  'ئ' => '', # initial hemze should not be shown
55  '،' => ',',
56  'ع' => '\'', # ayn
57  '؟' => '?',
58 
59  # digits
60  '٠' => '0', # &#x0660;
61  '١' => '1', # &#x0661;
62  '٢' => '2', # &#x0662;
63  '٣' => '3', # &#x0663;
64  '٤' => '4', # &#x0664;
65  '٥' => '5', # &#x0665;
66  '٦' => '6', # &#x0666;
67  '٧' => '7', # &#x0667;
68  '٨' => '8', # &#x0668;
69  '٩' => '9', # &#x0669;
70  ];
71 
72  public $mLatinToArabic = [
73  'b' => 'ب', 'c' => 'ج', 'ç' => 'چ', 'd' => 'د', 'f' => 'ف', 'g' => 'گ',
74  'h' => 'ه', 'j' => 'ژ', 'k' => 'ک', 'l' => 'ل',
75  'm' => 'م', 'n' => 'ن', 'p' => 'پ', 'q' => 'ق', 'r' => 'ر', 's' => 'س', 'ş' => 'ش',
76  't' => 'ت', 'v' => 'ڤ',
77  'x' => 'خ', 'y' => 'ی', 'z' => 'ز',
78 
79  'B' => 'ب', 'C' => 'ج', 'Ç' => 'چ', 'D' => 'د', 'F' => 'ف', 'G' => 'گ', 'H' => 'ھ',
80  'H' => 'ہ', 'H' => 'ه', 'H' => 'ح', 'J' => 'ژ', 'K' => 'ك', 'K' => 'ک', 'L' => 'ل',
81  'M' => 'م', 'N' => 'ن', 'P' => 'پ', 'Q' => 'ق', 'R' => 'ر', 'S' => 'س', 'Ş' => 'ش',
82  'T' => 'ت', 'V' => 'ڤ', 'W' => 'و', 'X' => 'خ',
83  'Y' => 'ی', 'Z' => 'ز',
84 
85  /* Doppelkonsonanten */
86  # 'll' => 'ڵ', # wenn es geht, doppel-l und l getrennt zu behandeln
87  # 'rr' => 'ڕ', # selbiges für doppel-r
88 
89  /* Einzelne Großbuchstaben */
90  // ' C' => 'ج',
91 
92  /* Vowels */
93  'a' => 'ا',
94  'e' => 'ە',
95  'ê' => 'ێ',
96  'i' => '',
97  'î' => 'ی',
98  'o' => 'ۆ',
99  'u' => 'و',
100  'û' => 'وو',
101  'w' => 'و',
102  ',' => '،',
103  '?' => '؟',
104 
105  # Try to replace the leading vowel
106  ' a' => 'ئا ',
107  ' e' => 'ئە ',
108  ' ê' => 'ئێ ',
109  ' î' => 'ئی ',
110  ' o' => 'ئۆ ',
111  ' u' => 'ئو ',
112  ' û' => 'ئوو ',
113  'A' => 'ئا',
114  'E' => 'ئە',
115  'Ê' => 'ئێ',
116  'Î' => 'ئی',
117  'O' => 'ئۆ',
118  'U' => 'ئو',
119  'Û' => 'ئوو',
120  ' A' => 'ئا ',
121  ' E' => 'ئە ',
122  ' Ê' => 'ئێ ',
123  ' Î' => 'ئی ',
124  ' O' => 'ئۆ ',
125  ' U' => 'ئو ',
126  ' Û' => 'ئوو ',
127  # eyn erstmal deaktivieren, einfache Anführungsstriche sind einfach zu
128  # häufig, um sie als eyn zu interpretieren.
129  # '\'' => 'ع',
130 
131 /* # deactivated for now, breaks links i.e. in header of Special:Recentchanges :-(
132  # digits
133  '0' => '٠', # &#x0660;
134  '1' => '١', # &#x0661;
135  '2' => '٢', # &#x0662;
136  '3' => '٣', # &#x0663;
137  '4' => '٤', # &#x0664;
138  '5' => '٥', # &#x0665;
139  '6' => '٦', # &#x0666;
140  '7' => '٧', # &#x0667;
141  '8' => '٨', # &#x0668;
142  '9' => '٩', # &#x0669;
143 */
144  ];
145 
146  function loadDefaultTables() {
147  $this->mTables = [
148  'ku-latn' => new ReplacementArray( $this->mArabicToLatin ),
149  'ku-arab' => new ReplacementArray( $this->mLatinToArabic ),
150  'ku' => new ReplacementArray()
151  ];
152  }
153 
164  function findVariantLink( &$link, &$nt, $ignoreOtherCond = false ) {
165  // check for user namespace
166  if ( is_object( $nt ) ) {
167  $ns = $nt->getNamespace();
168  if ( $ns == NS_USER || $ns == NS_USER_TALK ) {
169  return;
170  }
171  }
172 
173  $oldlink = $link;
174  parent::findVariantLink( $link, $nt, $ignoreOtherCond );
175  if ( $this->getPreferredVariant() == $this->mMainLanguageCode ) {
176  $link = $oldlink;
177  }
178  }
179 
190  function translate( $text, $toVariant ) {
191  $this->loadTables();
192  /* From Kazakh interface, maybe we need it later
193  $breaks = '[^\w\x80-\xff]';
194  // regexp for roman numbers
195  $roman = 'M{0,4}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})';
196  $roman = '';
197 
198  $reg = '/^'.$roman.'$|^'.$roman.$breaks.'|'.$breaks.$roman.'$|'.$breaks.$roman.$breaks.'/';
199 
200  $matches = preg_split($reg, $text, -1, PREG_SPLIT_OFFSET_CAPTURE);
201 
202  $m = array_shift($matches);
203  if( !isset( $this->mTables[$toVariant] ) ) {
204  throw new MWException( "Broken variant table: " . implode( ',', array_keys( $this->mTables ) ) );
205  }
206  $ret = $this->mTables[$toVariant]->replace( $m[0] );
207  $mstart = $m[1]+strlen($m[0]);
208  foreach($matches as $m) {
209  $ret .= substr($text, $mstart, $m[1]-$mstart);
210  $ret .= parent::translate($m[0], $toVariant);
211  $mstart = $m[1] + strlen($m[0]);
212  }
213 
214  return $ret;
215  */
216 
217  if ( !isset( $this->mTables[$toVariant] ) ) {
218  throw new MWException( "Broken variant table: " . implode( ',', array_keys( $this->mTables ) ) );
219  }
220 
221  return parent::translate( $text, $toVariant );
222  }
223 }
224 
230 class LanguageKu extends LanguageKu_ku {
231 
232  function __construct() {
233  parent::__construct();
234 
235  $variants = [ 'ku', 'ku-arab', 'ku-latn' ];
236  $variantfallbacks = [
237  'ku' => 'ku-latn',
238  'ku-arab' => 'ku-latn',
239  'ku-latn' => 'ku-arab',
240  ];
241 
242  $this->mConverter = new KuConverter( $this, 'ku', $variants, $variantfallbacks );
243  }
244 }
KuConverter\loadDefaultTables
loadDefaultTables()
Definition: LanguageKu.php:146
KuConverter\findVariantLink
findVariantLink(&$link, &$nt, $ignoreOtherCond=false)
A function wrapper:
Definition: LanguageKu.php:164
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
LanguageKu\__construct
__construct()
Definition: LanguageKu.php:232
MWException
MediaWiki exception.
Definition: MWException.php:26
not
if not
Definition: COPYING.txt:307
LanguageKu_ku
Kurdish.
Definition: LanguageKu_ku.php:30
NS_USER_TALK
const NS_USER_TALK
Definition: Defines.php:68
ReplacementArray
Wrapper around strtr() that holds replacements.
Definition: ReplacementArray.php:24
KuConverter\translate
translate( $text, $toVariant)
It translates text into variant, specials:
Definition: LanguageKu.php:190
KuConverter
Kurdish converter routines.
Definition: LanguageKu.php:29
c
type show c for details The hypothetical commands show w and show c should show the appropriate parts of the General Public License Of the commands you use may be called something other than show w and show c
Definition: COPYING.txt:321
LanguageKu
Kurdish (Kurdî / كوردی)
Definition: LanguageKu.php:230
Makefile.translate
def translate(text, conv_table)
Definition: Makefile.py:235
KuConverter\$mLatinToArabic
$mLatinToArabic
Definition: LanguageKu.php:72
NS_USER
const NS_USER
Definition: Defines.php:67
$link
usually copyright or history_copyright This message must be in HTML not wikitext & $link
Definition: hooks.txt:2981
KuConverter\$mArabicToLatin
$mArabicToLatin
Definition: LanguageKu.php:30