MediaWiki  1.23.2
LanguageShi.php
Go to the documentation of this file.
1 <?php
24 require_once __DIR__ . '/../LanguageConverter.php';
25 
38 class ShiConverter extends LanguageConverter {
39 
40  protected $mDoContentConvert;
41 
42  public $mToLatin = array(
43  'ⴰ' => 'a', 'ⴱ' => 'b', 'ⴳ' => 'g', 'ⴷ' => 'd', 'ⴹ' => 'ḍ', 'ⴻ' => 'e',
44  'ⴼ' => 'f', 'ⴽ' => 'k', 'ⵀ' => 'h', 'ⵃ' => 'ḥ', 'ⵄ' => 'ε', 'ⵅ' => 'x',
45  'ⵇ' => 'q', 'ⵉ' => 'i', 'ⵊ' => 'j', 'ⵍ' => 'l', 'ⵎ' => 'm', 'ⵏ' => 'n',
46  'ⵓ' => 'u', 'ⵔ' => 'r', 'ⵕ' => 'ṛ', 'ⵖ' => 'γ', 'ⵙ' => 's', 'ⵚ' => 'ṣ',
47  'ⵛ' => 'š', 'ⵜ' => 't', 'ⵟ' => 'ṭ', 'ⵡ' => 'w', 'ⵢ' => 'y', 'ⵣ' => 'z',
48  'ⵥ' => 'ẓ', 'ⵯ' => 'ʷ', 'ⵖ' => 'ɣ', 'ⵠ' => 'v', 'ⵒ' => 'p',
49  );
50 
52  'A' => 'a', 'B' => 'b', 'C' => 'c', 'D' => 'd', 'E' => 'e',
53  'F' => 'f', 'G' => 'g', 'H' => 'h', 'I' => 'i', 'J' => 'j',
54  'K' => 'k', 'L' => 'l', 'M' => 'm', 'N' => 'n', 'O' => 'o',
55  'P' => 'p', 'Q' => 'q', 'R' => 'r', 'S' => 's', 'T' => 't',
56  'U' => 'u', 'V' => 'v', 'W' => 'w', 'X' => 'x', 'Y' => 'y',
57  'Z' => 'z', 'Ɣ' => 'ɣ',
58  );
59 
60  public $mToTifinagh = array(
61  'a' => 'ⴰ', 'b' => 'ⴱ', 'g' => 'ⴳ', 'd' => 'ⴷ', 'ḍ' => 'ⴹ', 'e' => 'ⴻ',
62  'f' => 'ⴼ', 'k' => 'ⴽ', 'h' => 'ⵀ', 'ḥ' => 'ⵃ', 'ε' => 'ⵄ', 'x' => 'ⵅ',
63  'q' => 'ⵇ', 'i' => 'ⵉ', 'j' => 'ⵊ', 'l' => 'ⵍ', 'm' => 'ⵎ', 'n' => 'ⵏ',
64  'u' => 'ⵓ', 'r' => 'ⵔ', 'ṛ' => 'ⵕ', 'γ' => 'ⵖ', 's' => 'ⵙ', 'ṣ' => 'ⵚ',
65  'š' => 'ⵛ', 't' => 'ⵜ', 'ṭ' => 'ⵟ', 'w' => 'ⵡ', 'y' => 'ⵢ', 'z' => 'ⵣ',
66  'ẓ' => 'ⵥ', 'ʷ' => 'ⵯ', 'ɣ' => 'ⵖ', 'v' => 'ⵠ', 'p' => 'ⵒ',
67  );
68 
69  function loadDefaultTables() {
70  $this->mTables = array(
71  'lowercase' => new ReplacementArray( $this->mUpperToLowerCaseLatin ),
72  'shi-tfng' => new ReplacementArray( $this->mToTifinagh ),
73  'shi-latn' => new ReplacementArray( $this->mToLatin ),
74  'shi' => new ReplacementArray()
75  );
76  }
77 
88  function parseManualRule( $rule, $flags = array() ) {
89  if ( in_array( 'T', $flags ) ) {
90  return parent::parseManualRule( $rule, $flags );
91  }
92 
93  $carray = array();
94  // otherwise ignore all formatting
95  foreach ( $this->mVariants as $v ) {
96  $carray[$v] = $rule;
97  }
98 
99  return $carray;
100  }
101 
109  function parserConvert( $text, &$parser ) {
110  $this->mDoContentConvert = !( is_object( $parser->getTitle() ) && $parser->getTitle()->isTalkPage() );
111 
112  return parent::parserConvert( $text, $parser );
113  }
114 
125  function findVariantLink( &$link, &$nt, $ignoreOtherCond = false ) {
126  // check for user namespace
127  if ( is_object( $nt ) ) {
128  $ns = $nt->getNamespace();
129  if ( $ns == NS_USER || $ns == NS_USER_TALK ) {
130  return;
131  }
132  }
133 
134  $oldlink = $link;
135  parent::findVariantLink( $link, $nt, $ignoreOtherCond );
136  if ( $this->getPreferredVariant() == $this->mMainLanguageCode ) {
137  $link = $oldlink;
138  }
139  }
140 
150  function autoConvert( $text, $toVariant = false ) {
152  if ( is_object( $wgTitle ) && $wgTitle->getNamespace() == NS_FILE ) {
153  $imagename = $wgTitle->getNsText();
154  if ( preg_match( "/^$imagename:/", $text ) ) {
155  return $text;
156  }
157  }
158  return parent::autoConvert( $text, $toVariant );
159  }
160 
169  function translate( $text, $toVariant ) {
170  // If $text is empty or only includes spaces, do nothing
171  // Otherwise translate it
172  if ( trim( $text ) ) {
173  $this->loadTables();
174  // To Tifinagh, first translate uppercase to lowercase Latin
175  if ( $toVariant == 'shi-tfng' ) {
176  $text = $this->mTables['lowercase']->replace( $text );
177  }
178  $text = $this->mTables[$toVariant]->replace( $text );
179  }
180  return $text;
181  }
182 }
183 
189 class LanguageShi extends Language {
190  function __construct() {
192 
193  parent::__construct();
194 
195  $variants = array( 'shi', 'shi-tfng', 'shi-latn' );
196  $variantfallbacks = array(
197  'shi' => 'shi-tfng',
198  'shi-tfng' => 'shi',
199  'shi-latn' => 'shi',
200  );
201 
202  $flags = array();
203  $this->mConverter = new ShiConverter( $this, 'shi', $variants, $variantfallbacks, $flags );
204  $wgHooks['PageContentSaveComplete'][] = $this->mConverter;
205  }
206 }
ShiConverter\$mDoContentConvert
$mDoContentConvert
Definition: LanguageShi.php:40
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
ShiConverter\parserConvert
parserConvert( $text, &$parser)
Do not convert content on talk pages.
Definition: LanguageShi.php:109
ShiConverter\translate
translate( $text, $toVariant)
It translates text into variant.
Definition: LanguageShi.php:169
LanguageShi
Tachelhit.
Definition: LanguageShi.php:189
Language\$mConverter
LanguageConverter $mConverter
Definition: Language.php:78
NS_FILE
const NS_FILE
Definition: Defines.php:85
$wgHooks
$wgHooks['ArticleShow'][]
Definition: hooks.txt:110
$flags
it s the revision text itself In either if gzip is the revision text is gzipped $flags
Definition: hooks.txt:2113
$link
set to $title object and return false for a match for latest after cache objects are set use the ContentHandler facility to handle CSS and JavaScript for highlighting & $link
Definition: hooks.txt:2149
LanguageShi\__construct
__construct()
Definition: LanguageShi.php:190
$parser
do that in ParserLimitReportFormat instead $parser
Definition: hooks.txt:1956
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
ShiConverter\$mToTifinagh
$mToTifinagh
Definition: LanguageShi.php:60
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
NS_USER_TALK
const NS_USER_TALK
Definition: Defines.php:82
ReplacementArray
Replacement array for FSS with fallback to strtr() Supports lazy initialisation of FSS resource.
Definition: StringUtils.php:411
ShiConverter\loadDefaultTables
loadDefaultTables()
Definition: LanguageShi.php:69
ShiConverter\findVariantLink
findVariantLink(&$link, &$nt, $ignoreOtherCond=false)
A function wrapper:
Definition: LanguageShi.php:125
as
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
ShiConverter
Conversion script between Latin and Tifinagh for Tachelhit.
Definition: LanguageShi.php:38
NS_USER
const NS_USER
Definition: Defines.php:81
ShiConverter\autoConvert
autoConvert( $text, $toVariant=false)
An ugly function wrapper for parsing Image titles (to prevent image name conversion)
Definition: LanguageShi.php:150
ShiConverter\$mToLatin
$mToLatin
Definition: LanguageShi.php:42
ShiConverter\$mUpperToLowerCaseLatin
$mUpperToLowerCaseLatin
Definition: LanguageShi.php:51
Language
Internationalisation code.
Definition: Language.php:74
ShiConverter\parseManualRule
parseManualRule( $rule, $flags=array())
rules should be defined as -{Tifinagh | Latin-} -or- -{code:text | code:text | ......
Definition: LanguageShi.php:88
$wgTitle
if(! $wgRequest->checkUrlExtension()) if(! $wgEnableAPI) $wgTitle
Definition: api.php:63