2011-09-10 04:09:20 +00:00
|
|
|
|
<?php
|
|
|
|
|
|
/**
|
2012-06-09 20:24:16 +00:00
|
|
|
|
* Shilha specific code.
|
|
|
|
|
|
*
|
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
|
*
|
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
|
*
|
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
|
|
*
|
|
|
|
|
|
* @file
|
|
|
|
|
|
* @ingroup Language
|
|
|
|
|
|
*/
|
2011-09-10 04:09:20 +00:00
|
|
|
|
|
|
|
|
|
|
/**
|
2012-06-09 20:24:16 +00:00
|
|
|
|
* Conversion script between Latin and Tifinagh for Tachelhit.
|
|
|
|
|
|
* - Tifinagh -> lowercase Latin
|
|
|
|
|
|
* - lowercase/uppercase Latin -> Tifinagh
|
|
|
|
|
|
*
|
|
|
|
|
|
*
|
|
|
|
|
|
* Based on:
|
2016-10-09 17:48:14 +00:00
|
|
|
|
* - https://en.wikipedia.org/wiki/Shilha_language
|
2012-06-09 20:24:16 +00:00
|
|
|
|
* - LanguageSr.php
|
2011-09-10 04:09:20 +00:00
|
|
|
|
*
|
2012-06-09 20:24:16 +00:00
|
|
|
|
* @ingroup Language
|
2011-09-10 04:09:20 +00:00
|
|
|
|
*/
|
|
|
|
|
|
class ShiConverter extends LanguageConverter {
|
2011-10-18 17:27:52 +00:00
|
|
|
|
protected $mDoContentConvert;
|
|
|
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
|
public $mToLatin = [
|
2011-09-10 04:09:20 +00:00
|
|
|
|
'ⴰ' => 'a', 'ⴱ' => 'b', 'ⴳ' => 'g', 'ⴷ' => 'd', 'ⴹ' => 'ḍ', 'ⴻ' => 'e',
|
|
|
|
|
|
'ⴼ' => 'f', 'ⴽ' => 'k', 'ⵀ' => 'h', 'ⵃ' => 'ḥ', 'ⵄ' => 'ε', 'ⵅ' => 'x',
|
2013-04-17 19:10:02 +00:00
|
|
|
|
'ⵇ' => 'q', 'ⵉ' => 'i', 'ⵊ' => 'j', 'ⵍ' => 'l', 'ⵎ' => 'm', 'ⵏ' => 'n',
|
2011-09-10 04:09:20 +00:00
|
|
|
|
'ⵓ' => 'u', 'ⵔ' => 'r', 'ⵕ' => 'ṛ', 'ⵖ' => 'γ', 'ⵙ' => 's', 'ⵚ' => 'ṣ',
|
|
|
|
|
|
'ⵛ' => 'š', 'ⵜ' => 't', 'ⵟ' => 'ṭ', 'ⵡ' => 'w', 'ⵢ' => 'y', 'ⵣ' => 'z',
|
2011-12-22 01:27:59 +00:00
|
|
|
|
'ⵥ' => 'ẓ', 'ⵯ' => 'ʷ', 'ⵖ' => 'ɣ', 'ⵠ' => 'v', 'ⵒ' => 'p',
|
2016-02-17 09:09:32 +00:00
|
|
|
|
];
|
2011-09-10 04:09:20 +00:00
|
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
|
public $mUpperToLowerCaseLatin = [
|
2013-04-17 19:10:02 +00:00
|
|
|
|
'A' => 'a', 'B' => 'b', 'C' => 'c', 'D' => 'd', 'E' => 'e',
|
|
|
|
|
|
'F' => 'f', 'G' => 'g', 'H' => 'h', 'I' => 'i', 'J' => 'j',
|
|
|
|
|
|
'K' => 'k', 'L' => 'l', 'M' => 'm', 'N' => 'n', 'O' => 'o',
|
|
|
|
|
|
'P' => 'p', 'Q' => 'q', 'R' => 'r', 'S' => 's', 'T' => 't',
|
|
|
|
|
|
'U' => 'u', 'V' => 'v', 'W' => 'w', 'X' => 'x', 'Y' => 'y',
|
2011-12-22 01:27:59 +00:00
|
|
|
|
'Z' => 'z', 'Ɣ' => 'ɣ',
|
2016-02-17 09:09:32 +00:00
|
|
|
|
];
|
2011-09-10 04:09:20 +00:00
|
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
|
public $mToTifinagh = [
|
2011-09-10 04:09:20 +00:00
|
|
|
|
'a' => 'ⴰ', 'b' => 'ⴱ', 'g' => 'ⴳ', 'd' => 'ⴷ', 'ḍ' => 'ⴹ', 'e' => 'ⴻ',
|
|
|
|
|
|
'f' => 'ⴼ', 'k' => 'ⴽ', 'h' => 'ⵀ', 'ḥ' => 'ⵃ', 'ε' => 'ⵄ', 'x' => 'ⵅ',
|
2013-04-17 19:10:02 +00:00
|
|
|
|
'q' => 'ⵇ', 'i' => 'ⵉ', 'j' => 'ⵊ', 'l' => 'ⵍ', 'm' => 'ⵎ', 'n' => 'ⵏ',
|
2011-09-10 04:09:20 +00:00
|
|
|
|
'u' => 'ⵓ', 'r' => 'ⵔ', 'ṛ' => 'ⵕ', 'γ' => 'ⵖ', 's' => 'ⵙ', 'ṣ' => 'ⵚ',
|
|
|
|
|
|
'š' => 'ⵛ', 't' => 'ⵜ', 'ṭ' => 'ⵟ', 'w' => 'ⵡ', 'y' => 'ⵢ', 'z' => 'ⵣ',
|
2011-12-22 01:27:59 +00:00
|
|
|
|
'ẓ' => 'ⵥ', 'ʷ' => 'ⵯ', 'ɣ' => 'ⵖ', 'v' => 'ⵠ', 'p' => 'ⵒ',
|
2016-02-17 09:09:32 +00:00
|
|
|
|
];
|
2011-09-10 04:09:20 +00:00
|
|
|
|
|
|
|
|
|
|
function loadDefaultTables() {
|
2016-02-17 09:09:32 +00:00
|
|
|
|
$this->mTables = [
|
2011-09-10 04:09:20 +00:00
|
|
|
|
'lowercase' => new ReplacementArray( $this->mUpperToLowerCaseLatin ),
|
|
|
|
|
|
'shi-tfng' => new ReplacementArray( $this->mToTifinagh ),
|
|
|
|
|
|
'shi-latn' => new ReplacementArray( $this->mToLatin ),
|
2013-04-17 19:10:02 +00:00
|
|
|
|
'shi' => new ReplacementArray()
|
2016-02-17 09:09:32 +00:00
|
|
|
|
];
|
2011-09-10 04:09:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* A function wrapper:
|
|
|
|
|
|
* - if there is no selected variant, leave the link
|
|
|
|
|
|
* names as they were
|
|
|
|
|
|
* - do not try to find variants for usernames
|
|
|
|
|
|
*
|
2014-07-24 12:55:43 +00:00
|
|
|
|
* @param string &$link
|
|
|
|
|
|
* @param Title &$nt
|
2014-04-17 13:31:28 +00:00
|
|
|
|
* @param bool $ignoreOtherCond
|
2011-09-10 04:09:20 +00:00
|
|
|
|
*/
|
|
|
|
|
|
function findVariantLink( &$link, &$nt, $ignoreOtherCond = false ) {
|
2013-04-17 19:10:02 +00:00
|
|
|
|
// check for user namespace
|
2011-09-10 04:09:20 +00:00
|
|
|
|
if ( is_object( $nt ) ) {
|
|
|
|
|
|
$ns = $nt->getNamespace();
|
2013-04-17 19:10:02 +00:00
|
|
|
|
if ( $ns == NS_USER || $ns == NS_USER_TALK ) {
|
2011-09-10 04:09:20 +00:00
|
|
|
|
return;
|
2013-04-17 19:10:02 +00:00
|
|
|
|
}
|
2011-09-10 04:09:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$oldlink = $link;
|
|
|
|
|
|
parent::findVariantLink( $link, $nt, $ignoreOtherCond );
|
2013-04-17 19:10:02 +00:00
|
|
|
|
if ( $this->getPreferredVariant() == $this->mMainLanguageCode ) {
|
2011-09-10 04:09:20 +00:00
|
|
|
|
$link = $oldlink;
|
2013-04-17 19:10:02 +00:00
|
|
|
|
}
|
2011-09-10 04:09:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* It translates text into variant
|
|
|
|
|
|
*
|
2014-04-17 13:31:28 +00:00
|
|
|
|
* @param string $text
|
|
|
|
|
|
* @param string $toVariant
|
2011-09-10 04:09:20 +00:00
|
|
|
|
*
|
|
|
|
|
|
* @return string
|
|
|
|
|
|
*/
|
|
|
|
|
|
function translate( $text, $toVariant ) {
|
|
|
|
|
|
// If $text is empty or only includes spaces, do nothing
|
|
|
|
|
|
// Otherwise translate it
|
|
|
|
|
|
if ( trim( $text ) ) {
|
|
|
|
|
|
$this->loadTables();
|
|
|
|
|
|
// To Tifinagh, first translate uppercase to lowercase Latin
|
2013-04-17 19:10:02 +00:00
|
|
|
|
if ( $toVariant == 'shi-tfng' ) {
|
2011-09-10 04:09:20 +00:00
|
|
|
|
$text = $this->mTables['lowercase']->replace( $text );
|
|
|
|
|
|
}
|
|
|
|
|
|
$text = $this->mTables[$toVariant]->replace( $text );
|
|
|
|
|
|
}
|
|
|
|
|
|
return $text;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* Tachelhit
|
|
|
|
|
|
*
|
|
|
|
|
|
* @ingroup Language
|
|
|
|
|
|
*/
|
|
|
|
|
|
class LanguageShi extends Language {
|
|
|
|
|
|
function __construct() {
|
|
|
|
|
|
parent::__construct();
|
|
|
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
|
$variants = [ 'shi', 'shi-tfng', 'shi-latn' ];
|
|
|
|
|
|
$variantfallbacks = [
|
2013-04-17 19:10:02 +00:00
|
|
|
|
'shi' => 'shi-tfng',
|
2011-09-10 04:09:20 +00:00
|
|
|
|
'shi-tfng' => 'shi',
|
|
|
|
|
|
'shi-latn' => 'shi',
|
2016-02-17 09:09:32 +00:00
|
|
|
|
];
|
2011-09-10 04:09:20 +00:00
|
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
|
$flags = [];
|
2011-09-10 04:09:20 +00:00
|
|
|
|
$this->mConverter = new ShiConverter( $this, 'shi', $variants, $variantfallbacks, $flags );
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|