Kaldari has uploaded a new change for review.
https://gerrit.wikimedia.org/r/185090
Change subject: Adding LanguageConverter files for Tatar Language
......................................................................
Adding LanguageConverter files for Tatar Language
These were supplied via Bugzilla. I didn't write them and have no
idea if they make sense.
Change-Id: I948529190c57d01107beb089de549c0b11a8573c
---
M languages/LanguageConverter.php
A languages/classes/LanguageTt.php
A languages/classes/LanguageTt_cyrl.php
3 files changed, 1,202 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/90/185090/1
diff --git a/languages/LanguageConverter.php b/languages/LanguageConverter.php
index 43d6063..eea7703 100644
--- a/languages/LanguageConverter.php
+++ b/languages/LanguageConverter.php
@@ -42,6 +42,7 @@
'shi',
'sr',
'tg',
+ 'tt',
'uz',
'zh',
);
diff --git a/languages/classes/LanguageTt.php b/languages/classes/LanguageTt.php
new file mode 100644
index 0000000..cd89a22
--- /dev/null
+++ b/languages/classes/LanguageTt.php
@@ -0,0 +1,480 @@
+<?php
+/**
+ * Tatar (Татарча/Tatarça) 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
+ */
+
+require_once( dirname(__FILE__).'/../LanguageConverter.php' );
+require_once( dirname(__FILE__).'/LanguageTt_cyrl.php' );
+
+define( 'TT_C_UC', 'АӘБВГҒДЕЁЖҖЗИЙКҚЛМНҢОӨПРСТУҰҮФХҺЦЧШЩЪЫІЬЭЮЯ' ); # Tatar
Cyrillic uppercase
+define( 'TT_C_LC', 'аәбвгғдеёжҗзийкқлмнңоөпрстуұүфхһцчшщъыіьэюя' ); # Tatar
Cyrillic lowercase
+define( 'TT_L_UC', 'AÄBCÇDEÉFGĞHIİÏJKLMNÑOÖPQRSŞTUÜVWXYÝZ' ); # Tatar Latin
uppercase
+define( 'TT_L_LC', 'aäbcçdeéfgğhıiïjklmnñoöpqrsştuüvwxyýz' ); # Tatar Latin
lowercase
+define( 'H_HAMZA', 'ٴ' ); # U+0674 ARABIC LETTER HIGH HAMZA
+
+/**
+ * Tatar (Татарча/Tatarça) converter routines
+ *
+ * @ingroup Language
+ */
+class TtConverter extends LanguageConverter {
+
+ function __construct( $langobj, $maincode,
+
$variants=array(),
+
$variantfallbacks=array(),
+ $markup=array(),
+ $flags =
array()) {
+ parent::__construct( $langobj, $maincode,
+ $variants, $variantfallbacks, $markup, $flags );
+
+ // No point delaying this since they're in code.
+ // Waiting until loadDefaultTables() means they never get loaded
+ // when the tables themselves are loaded from cache.
+ $this->loadRegs();
+ }
+
+ function loadDefaultTables() {
+ // require(
dirname(__FILE__)."/../../includes/TtConversion.php" );
+ // Placeholder for future implementing. Remove variables
declarations
+ // after generating TtConversion.php
+ $tt2Cyrl = array();
+ $tt2Latn = array();
+ $tt2Arab = array();
+ $tt2KZ = array();
+ $tt2TR = array();
+ $tt2CN = array();
+
+ $this->mTables = array(
+ 'tt-cyrl' => new ReplacementArray( $tt2Cyrl ),
+ 'tt-latn' => new ReplacementArray( $tt2Latn ),
+ 'tt-arab' => new ReplacementArray( $tt2Arab ),
+ 'tt-kz' => new ReplacementArray(
array_merge($tt2Cyrl, $tt2KZ) ),
+ 'tt-tr' => new ReplacementArray(
array_merge($tt2Latn, $tt2TR) ),
+ 'tt-cn' => new ReplacementArray(
array_merge($tt2Arab, $tt2CN) ),
+ 'tt' => new ReplacementArray()
+ );
+ }
+
+ function postLoadTables() {
+ $this->mTables['tt-kz']->merge( $this->mTables['tt-cyrl'] );
+ $this->mTables['tt-tr']->merge( $this->mTables['tt-latn'] );
+ $this->mTables['tt-cn']->merge( $this->mTables['tt-arab'] );
+ }
+
+ function loadRegs() {
+
+ $this->mCyrl2Latn = array(
+ ## Punctuation
+ '/№/u' => 'No.',
+ ## Е after vowels
+ '/([АӘЕЁИОӨҰҮЭЮЯЪЬ])Е/u' => '$1YE',
+ '/([АӘЕЁИОӨҰҮЭЮЯЪЬ])е/ui' => '$1ye',
+ ## leading ЁЮЯЩ
+ '/^Ё(['.TT_C_UC.']|$)/u' => 'YO$1',
'/^Ё(['.TT_C_LC.']|$)/u' => 'Yo$1',
+ '/^Ю(['.TT_C_UC.']|$)/u' => 'YU$1',
'/^Ю(['.TT_C_LC.']|$)/u' => 'Yu$1',
+ '/^Я(['.TT_C_UC.']|$)/u' => 'YA$1',
'/^Я(['.TT_C_LC.']|$)/u' => 'Ya$1',
+ '/^Щ(['.TT_C_UC.']|$)/u' => 'ŞÇ$1',
'/^Щ(['.TT_C_LC.']|$)/u' => 'Şç$1',
+ ## other ЁЮЯ
+ '/Ё/u' => 'YO', '/ё/u' => 'yo',
+ '/Ю/u' => 'YU', '/ю/u' => 'yu',
+ '/Я/u' => 'YA', '/я/u' => 'ya',
+ '/Щ/u' => 'ŞÇ', '/щ/u' => 'şç',
+ '/Ц/u' => 'Ts', '/ц/u' => 'ts',
+ ## soft and hard signs
+ '/[ъЪ]/u' => 'ʺ', '/[ьЬ]/u' => 'ʹ',
+ ## other characters
+ '/А/u' => 'A', '/а/u' => 'a', '/Ә/u' => 'Ä', '/ә/u' =>
'ä',
+ '/Б/u' => 'B', '/б/u' => 'b', '/В/u' => 'V', '/в/u' =>
'v',
+ '/Г/u' => 'G', '/г/u' => 'g', '/Ғ/u' => 'Ğ', '/ғ/u' =>
'ğ',
+ '/Д/u' => 'D', '/д/u' => 'd', '/Е/u' => 'E', '/е/u' =>
'e',
+ '/Ж/u' => 'J', '/ж/u' => 'j', '/З/u' => 'Z', '/з/u' =>
'z',
+ '/И/u' => 'İ', '/и/u' => 'i', '/Й/u' => 'Y', '/й/u' =>
'y',
+ '/К/u' => 'K', '/к/u' => 'k', '/Қ/u' => 'Q', '/қ/u' =>
'q',
+ '/Л/u' => 'L', '/л/u' => 'l', '/М/u' => 'M', '/м/u' =>
'm',
+ '/Н/u' => 'N', '/н/u' => 'n', '/Ң/u' => 'Ñ', '/ң/u' =>
'ñ',
+ '/О/u' => 'O', '/о/u' => 'o', '/Ө/u' => 'Ö', '/ө/u' =>
'ö',
+ '/П/u' => 'P', '/п/u' => 'p', '/Р/u' => 'R', '/р/u' =>
'r',
+ '/С/u' => 'S', '/с/u' => 's', '/Т/u' => 'T', '/т/u' =>
't',
+ '/У/u' => 'U', '/у/u' => 'u', '/Ұ/u' => 'U', '/ұ/u' =>
'u',
+ '/Ү/u' => 'Ü', '/ү/u' => 'ü', '/Ф/u' => 'F', '/ф/u' =>
'f',
+ '/Х/u' => 'X', '/х/u' => 'x', '/Һ/u' => 'H', '/һ/u' =>
'h',
+ '/Ч/u' => 'Ç', '/ч/u' =>
'ç',
+ '/Ш/u' => 'Ş', '/ш/u' => 'ş', '/Ы/u' => 'I', '/ы/u' =>
'ı',
+ '/І/u' => 'İ', '/і/u' => 'i', '/Э/u' => 'E', '/э/u' =>
'e',
+ '/Җ/u' => 'C', '/җ/u' => 'c',
+ );
+
+ $this->mLatn2Cyrl = array(
+ ## Punctuation
+ '/#|No\./' => '№',
+ ## Şç
+ '/ŞÇʹ/u'=> 'ЩЬ', '/Şçʹ/u'=> 'Щь', '/Şçʹ/u'=> 'Щь',
+ '/Ş[Çç]/u' => 'Щ', '/şç/u' => 'щ',
+ ## soft and hard signs
+ '/(['.TT_L_UC.'])ʺ(['.TT_L_UC.'])/u' => '$1Ъ$2',
+ '/ʺ(['.TT_L_LC.'])/u' => 'ъ$1',
+ '/(['.TT_L_UC.'])ʹ(['.TT_L_UC.'])/u' => '$1Ь$2',
+ '/ʹ(['.TT_L_LC.'])/u' => 'ь$1',
+ '/ʺ/u' => 'ъ',
+ '/ʹ/u' => 'ь',
+ ## Ye Yo Yu Ya.
+ '/Y[Ee]/u' => 'Е', '/ye/u' => 'е',
+ '/Y[Oo]/u' => 'Ё', '/yo/u' => 'ё',
+ '/Y[UWuw]/u' => 'Ю', '/y[uw]/u' => 'ю',
+ '/Y[Aa]/u' => 'Я', '/ya/u' => 'я',
+ ## other characters
+ '/A/u' => 'А', '/a/u' => 'а', '/Ä/u' => 'Ә', '/ä/u' =>
'ә',
+ '/B/u' => 'Б', '/b/u' => 'б', '/C/u' => 'Җ', '/c/u' =>
'җ',
+ '/Ç/u' => 'Ч', '/ç/u' => 'ч', '/D/u' => 'Д', '/d/u' =>
'д',
+ '/E/u' => 'Е', '/e/u' => 'е', '/É/u' => 'Э', '/é/u' =>
'э',
+ '/F/u' => 'Ф', '/f/u' => 'ф', '/G/u' => 'Г', '/g/u' =>
'г',
+ '/Ğ/u' => 'Ғ', '/ğ/u' => 'ғ', '/H/u' => 'Һ', '/h/u' =>
'һ',
+ '/I/u' => 'Ы', '/ı/u' => 'ы', '/İ/u' => 'И', '/i/u' =>
'и',
+ '/Ï/u' => 'И', '/ï/u' => 'и', '/J/u' => 'Ж', '/j/u' =>
'ж',
+ '/K/u' => 'К', '/k/u' => 'к', '/L/u' => 'Л', '/l/u' =>
'л',
+ '/M/u' => 'М', '/m/u' => 'м', '/N/u' => 'Н', '/n/u' =>
'н',
+ '/Ñ/u' => 'Ң', '/ñ/u' => 'ң', '/O/u' => 'О', '/o/u' =>
'о',
+ '/Ö/u' => 'Ө', '/ö/u' => 'ө', '/P/u' => 'П', '/p/u' =>
'п',
+ '/Q/u' => 'Қ', '/q/u' => 'қ', '/R/u' => 'Р', '/r/u' =>
'р',
+ '/S/u' => 'С', '/s/u' => 'с', '/Ş/u' => 'Ш', '/ş/u' =>
'ш',
+ '/T/u' => 'Т', '/t/u' => 'т', '/U/u' => 'У', '/u/u' =>
'у',
+ '/Ü/u' => 'Ү', '/ü/u' => 'ү', '/V/u' => 'В', '/v/u' =>
'в',
+ '/W/u' => 'У', '/w/u' => 'у', '/Ý/u' => 'Й', '/ý/u' =>
'й',
+ '/X/u' => 'Х', '/x/u' => 'х', '/Z/u' => 'З', '/z/u' =>
'з',
+ '/Y/u' => 'Й', '/y/u' =>
'й',
+ );
+
+ $this->mCyLa2Arab = array(
+ ## Punctuation -> Arabic
+ '/#|№|No\./u' => '', # ؀
+ '/\,/' => '،', # ،
+ '/;/' => '؛', # ؛
+ '/\?/' => '؟', # ؟
+ '/%/' => '٪', # ٪
+ '/\*/' => '٭', # ٭
+ ## Digits -> Arabic
+ '/0/' => '۰', # ۰
+ '/1/' => '۱', # ۱
+ '/2/' => '۲', # ۲
+ '/3/' => '۳', # ۳
+ '/4/' => '۴', # ۴
+ '/5/' => '۵', # ۵
+ '/6/' => '۶', # ۶
+ '/7/' => '۷', # ۷
+ '/8/' => '۸', # ۸
+ '/9/' => '۹', # ۹
+ ## Cyrillic -> Arabic
+ '/Аллаһ/ui' => 'ﷲ',
+ '/([АӘЕЁИОӨҰҮЭЮЯЪЬ])е/ui' => '$1يە',
+ '/[еэ]/ui' => 'ە', '/[ъь]/ui' => '',
+ '/[аә]/ui' => 'ا', '/[оө]/ui' => 'و', '/[ұү]/ui' =>
'ۇ', '/[ыі]/ui' => 'ى',
+ '/[и]/ui' => 'ىي', '/ё/ui' => 'يو', '/ю/ui' => 'يۋ',
'/я/ui' => 'يا', '/[й]/ui' => 'ي',
+ '/ц/ui' => 'تس', '/щ/ui' => 'شش',
+ '/һ/ui' => 'ح', '/ч/ui' => 'تش',
+ #'/һ/ui' => 'ھ', '/ч/ui' => 'چ',
+ '/б/ui' => 'ب', '/в/ui' => 'ۆ', '/г/ui' => 'گ', '/ғ/ui'
=> 'ع',
+ '/д/ui' => 'د', '/ж/ui' => 'ج', '/з/ui' => 'ز', '/к/ui'
=> 'ك',
+ '/қ/ui' => 'ق', '/л/ui' => 'ل', '/м/ui' => 'م', '/н/ui'
=> 'ن',
+ '/ң/ui' => 'ڭ', '/п/ui' => 'پ', '/р/ui' => 'ر', '/с/ui'
=> 'س',
+ '/т/ui' => 'ت', '/у/ui' => 'ۋ', '/ф/ui' => 'ف', '/х/ui'
=> 'ح',
+ '/ш/ui' => 'ش',
+ ## Latin -> Arabic // commented for now...
+ /*'/Allah/ui' => 'ﷲ',
+ '/[eé]/ui' => 'ە', '/[yý]/ui' => 'ي', '/[ʺʹ]/ui' => '',
+ '/[aä]/ui' => 'ا', '/[oö]/ui' => 'و', '/[uü]/ui' => 'ۇ',
+ '/[ï]/ui' => 'ىي', '/[ıIiİ]/u' => 'ى',
+ '/c/ui' => 'تس',
+ '/ç/ui' => 'تش', '/h/ui' => 'ح',
+ #'/ç/ui' => 'چ', '/h/ui' => 'ھ',
+ '/b/ui' => 'ب','/d/ui' => 'د',
+ '/f/ui' => 'ف', '/g/ui' => 'گ', '/ğ/ui' => 'ع',
+ '/j/ui' => 'ج', '/k/ui' => 'ك', '/l/ui' => 'ل', '/m/ui'
=> 'م',
+ '/n/ui' => 'ن', '/ñ/ui' => 'ڭ', '/p/ui' => 'پ', '/q/ui'
=> 'ق',
+ '/r/ui' => 'ر', '/s/ui' => 'س', '/ş/ui' => 'ش', '/t/ui'
=> 'ت',
+ '/v/ui' => 'ۆ', '/w/ui' => 'ۋ', '/x/ui' => 'ح', '/z/ui'
=> 'ز',*/
+ );
+ }
+
+ /* rules should be defined as -{ekavian | iyekavian-} -or-
+ -{code:text | code:text | ...}-
+ update: delete all rule parsing because it's not used
+ currently, and just produces a couple of bugs
+ */
+ function parseManualRule($rule, $flags=array()) {
+ if(in_array('T',$flags)){
+ return parent::parseManualRule($rule, $flags);
+ }
+
+ // otherwise ignore all formatting
+ foreach($this->mVariants as $v) {
+ $carray[$v] = $rule;
+ }
+
+ return $carray;
+ }
+
+ // Do not convert content on talk pages
+ function parserConvert( $text, &$parser ){
+ if(is_object($parser->getTitle() ) &&
$parser->getTitle()->isTalkPage())
+ $this->mDoContentConvert=false;
+ else
+ $this->mDoContentConvert=true;
+
+ return parent::parserConvert($text, $parser );
+ }
+
+ /*
+ * A function wrapper:
+ * - if there is no selected variant, leave the link
+ * names as they were
+ * - do not try to find variants for usernames
+ */
+ function findVariantLink( &$link, &$nt, $ignoreOtherCond = false ) {
+ // check for user namespace
+ if(is_object($nt)){
+ $ns = $nt->getNamespace();
+ if($ns==NS_USER || $ns==NS_USER_TALK)
+ return;
+ }
+
+ $oldlink=$link;
+ parent::findVariantLink( $link, $nt, $ignoreOtherCond );
+ if( $this->getPreferredVariant()==$this->mMainLanguageCode )
+ $link=$oldlink;
+ }
+
+ /*
+ * An ugly function wrapper for parsing Image titles
+ * (to prevent image name conversion)
+ */
+ function autoConvert($text, $toVariant=false) {
+ global $wgTitle;
+ if(is_object($wgTitle) && $wgTitle->getNameSpace()==NS_FILE){
+ $imagename = $wgTitle->getNsText();
+ if(preg_match("/^$imagename:/",$text)) return $text;
+ }
+ return parent::autoConvert($text,$toVariant);
+ }
+
+ /**
+ * It translates text into variant
+ */
+ function translate( $text, $toVariant ){
+ global $wgContLanguageCode;
+ $text = parent::translate( $text, $toVariant );
+
+ $letters = '';
+ switch( $toVariant ) {
+ case 'tt-cyrl':
+ case 'tt-kz':
+ $letters = TT_L_UC . TT_L_LC . 'ʺʹ#0123456789';
+ $wgContLanguageCode = 'tt';
+ break;
+ case 'tt-latn':
+ case 'tt-tr':
+ $letters = TT_C_UC . TT_C_LC . '№0123456789';
+ $wgContLanguageCode = 'tt-Latn';
+ break;
+ case 'tt-arab':
+ case 'tt-cn':
+ $letters =
TT_C_UC.TT_C_LC./*TT_L_UC.TT_L_LC.'ʺʹ'.*/',;\?%\*№0123456789';
+ $wgContLanguageCode = 'tt-Arab';
+ break;
+ default:
+ $wgContLanguageCode = 'tt';
+ return $text;
+ }
+ // disable conversion variables like $1, $2...
+ $varsfix = '\$[0-9]';
+
+ $matches = preg_split( '/' . $varsfix . '[^' . $letters .
']+/u', $text, -1, PREG_SPLIT_OFFSET_CAPTURE);
+ $mstart = 0;
+ $ret = '';
+ foreach( $matches as $m ) {
+ $ret .= substr( $text, $mstart, $m[1]-$mstart );
+ $ret .= $this->regsConverter( $m[0], $toVariant );
+ $mstart = $m[1] + strlen($m[0]);
+ }
+ return $ret;
+ }
+
+ function regsConverter( $text, $toVariant ) {
+ if ($text == '') return $text;
+
+ $pat = array();
+ $rep = array();
+ switch( $toVariant ) {
+ case 'tt-arab':
+ case 'tt-cn':
+ $letters = TT_C_LC.TT_C_UC/*.TT_L_LC.TT_L_UC*/;
+ $front = 'әөүіӘӨҮІ'/*.'äöüiÄÖÜİ'*/;
+ $excludes = 'еэгғкқЕЭГҒКҚ'/*.'eégğkqEÉGĞKQ'*/;
+ // split text to words
+ $matches = preg_split( '/[\b\s\-\.:]+/', $text,
-1, PREG_SPLIT_OFFSET_CAPTURE);
+ $mstart = 0;
+ $ret = '';
+ foreach( $matches as $m ) {
+ $ret .= substr( $text, $mstart, $m[1] -
$mstart );
+ // is matched the word to front vowels?
+ // exclude a words matched to е, э, г,
к, к, қ,
+ // them should be without hamza
+ if ( preg_match('/['.$front.']/u',
$m[0]) && !preg_match('/['.$excludes.']/u', $m[0]) ) {
+ $ret .=
preg_replace('/['.$letters.']+/u', H_HAMZA.'$0', $m[0]);
+ } else {
+ $ret .= $m[0];
+ }
+ $mstart = $m[1] + strlen($m[0]);
+ }
+ $text =& $ret;
+ foreach( $this->mCyLa2Arab as $pat => $rep ) {
+ $text = preg_replace( $pat, $rep, $text
);
+ }
+ return $text;
+ break;
+ case 'tt-latn':
+ case 'tt-tr':
+ foreach( $this->mCyrl2Latn as $pat => $rep ) {
+ $text = preg_replace( $pat, $rep, $text
);
+ }
+ return $text;
+ break;
+ case 'tt-cyrl':
+ case 'tt-kz':
+ foreach( $this->mLatn2Cyrl as $pat => $rep ) {
+ $text = preg_replace( $pat, $rep, $text
);
+ }
+ return $text;
+ break;
+ default:
+ return $text;
+ }
+ }
+
+ /*
+ * We want our external link captions to be converted in variants,
+ * so we return the original text instead -{$text}-, except for URLs
+ */
+ function markNoConversion( $text, $noParse=false ) {
+ if( $noParse || preg_match( "/^https?:\/\/|ftp:\/\/|irc:\/\//",
$text ) )
+ return parent::markNoConversion( $text );
+ return $text;
+ }
+
+ function convertCategoryKey( $key ) {
+ return $this->autoConvert( $key, 'tt' );
+ }
+
+}
+
+/**
+ * class that handles Cyrillic, Latin and Arabic scripts for Kazakh
+ * right now it only distinguish tt_cyrl, tt_latn, tt_arab and tt_kz, tt_tr,
tt_cn.
+ *
+ * @ingroup Language
+ */
+class LanguageTt extends LanguageTt_cyrl {
+
+ function __construct() {
+ global $wgHooks;
+ parent::__construct();
+
+ $variants = array( 'tt', 'tt-cyrl', 'tt-latn', 'tt-arab'/*,
'tt-kz', 'tt-tr', 'tt-cn'*/ );
+ $variantfallbacks = array(
+ 'tt' => 'tt-cyrl',
+ 'tt-cyrl' => 'tt',
+ 'tt-latn' => 'tt',
+ 'tt-arab' => 'tt',
+ /*'tt-kz' => 'tt-cyrl',
+ 'tt-tr' => 'tt-latn',
+ 'tt-cn' => 'tt-arab'*/
+ );
+
+ $this->mConverter = new TtConverter( $this, 'tt', $variants,
$variantfallbacks );
+
+ $wgHooks['ArticleSaveComplete'][] = $this->mConverter;
+ }
+
+ /**
+ * Work around for right-to-left direction support in tt-arab and tt-cn
+ *
+ * @return bool
+ */
+ function isRTL() {
+ $variant = $this->getPreferredVariant();
+ if ( $variant == 'tt-arab' || $variant == 'tt-cn' ) {
+ return true;
+ } else {
+ return parent::isRTL();
+ }
+ }
+
+ /*
+ * It fixes issue with ucfirst for transforming 'i' to 'İ'
+ *
+ */
+ function ucfirst ( $string ) {
+ $variant = $this->getPreferredVariant();
+ if ( ($variant == 'tt-latn' || $variant == 'tt-tr') &&
$string[0] == 'i' ) {
+ $string = 'İ' . substr( $string, 1 );
+ } else {
+ $string = parent::ucfirst( $string );
+ }
+ return $string;
+ }
+
+ /*
+ * It fixes issue with lcfirst for transforming 'I' to 'ı'
+ *
+ */
+ function lcfirst ( $string ) {
+ $variant = $this->getPreferredVariant();
+ if ( ($variant == 'tt-latn' || $variant == 'tt-tr') &&
$string[0] == 'I' ) {
+ $string = 'ı' . substr( $string, 1 );
+ } else {
+ $string = parent::lcfirst( $string );
+ }
+ return $string;
+ }
+
+ function convertGrammar( $word, $case ) {
+ wfProfileIn( __METHOD__ );
+
+ $variant = $this->getPreferredVariant();
+ switch ( $variant ) {
+ case 'tt-arab':
+ case 'tt-cn':
+ $word = parent::convertGrammarTt_arab( $word,
$case );
+ break;
+ case 'tt-latn':
+ case 'tt-tr':
+ $word = parent::convertGrammarTt_latn( $word,
$case );
+ break;
+ case 'tt-cyrl':
+ case 'tt-kz':
+ case 'tt':
+ default:
+ $word = parent::convertGrammarTt_cyrl( $word,
$case );
+ }
+
+ wfProfileOut( __METHOD__ );
+ return $word;
+ }
+}
diff --git a/languages/classes/LanguageTt_cyrl.php
b/languages/classes/LanguageTt_cyrl.php
new file mode 100644
index 0000000..18aa88d
--- /dev/null
+++ b/languages/classes/LanguageTt_cyrl.php
@@ -0,0 +1,721 @@
+<?php
+/**
+ * Tatar (Татарча/Tatarça)
+ *
+ * @ingroup Language
+ */
+
+class LanguageTt_cyrl extends Language {
+
+ # Convert from the nominative form of a noun to some other case
+ # Invoked with {{GRAMMAR:case|word}}
+ /**
+ * Cases: genitive, dative, accusative, locative, ablative, comitative
+ possessive forms
+ */
+
+ function convertGrammarTt_cyrl( $word, $case ) {
+ global $wgGrammarForms;
+ if ( isset( $wgGrammarForms['tt-kz'][$case][$word] ) ) {
+ return $wgGrammarForms['tt-kz'][$case][$word];
+ }
+ if ( isset( $wgGrammarForms['tt-cyrl'][$case][$word] ) ) {
+ return $wgGrammarForms['tt-cyrl'][$case][$word];
+ }
+ // Set up some constants...
+ // Vowels in last syllable
+ $frontVowels = array( "е", "ө", "ү", "і", "ә", "э", "я", "ё",
"и" );
+ $backVowels = array( "а", "о", "ұ", "ы" );
+ $allVowels = array( "е", "ө", "ү", "і", "ә", "э", "а", "о",
"ұ", "ы", "я", "ё", "и" );
+ // Preceding letters
+ $Nasals = array( "м", "н", "ң" );
+ $Sonants = array( "и", "й", "л", "р", "у", "ю");
+ $Consonants = array( "п", "ф", "к", "қ", "т", "ш", "с", "х",
"ц", "ч", "щ", "б", "в", "г", "д" );
+ $Sibilants = array( "ж", "з" );
+ $Sonorants = array( "и", "й", "л", "р", "у", "ю", "м", "н",
"ң", "ж", "з");
+
+ // Possessives
+ $firstPerson = array( "м", "ң" ); // 1st singular, 2nd unformal
+ $secondPerson = array( "з" ); // 1st plural, 2nd formal
+ $thirdPerson = array( "ы", "і" ); // 3rd
+
+ $lastLetter = self::lastLetter( $word, $allVowels );
+ $wordEnding =& $lastLetter[0];
+ $wordLastVowel =& $lastLetter[1];
+
+ // Now convert the word
+ switch ( $case ) {
+ case "dc1":
+ case "genitive": #ilik
+ if ( in_array( $wordEnding, $Consonants ) ) {
+ if ( in_array( $wordLastVowel,
$frontVowels ) ) {
+ $word = $word . "тің";
+ } elseif ( in_array( $wordLastVowel,
$backVowels ) ) {
+ $word = $word . "тың";
+ }
+ } elseif ( in_array( $wordEnding, $allVowels )
|| in_array( $wordEnding, $Nasals ) ) {
+ if ( in_array( $wordLastVowel,
$frontVowels ) ) {
+ $word = $word . "нің";
+ } elseif ( in_array( $wordLastVowel,
$backVowels ) ) {
+ $word = $word . "ның";
+ }
+ } elseif ( in_array( $wordEnding, $Sonants ) ||
in_array( $wordEnding, $Sibilants )) {
+ if ( in_array( $wordLastVowel,
$frontVowels ) ) {
+ $word = $word . "дің";
+ } elseif ( in_array( $wordLastVowel,
$backVowels ) ) {
+ $word = $word . "дың";
+ }
+ }
+ break;
+ case "dc2":
+ case "dative": #barıs
+ if ( in_array( $wordEnding, $Consonants ) ) {
+ if ( in_array( $wordLastVowel,
$frontVowels ) ) {
+ $word = $word . "ке";
+ } elseif ( in_array( $wordLastVowel,
$backVowels ) ) {
+ $word = $word . "қа";
+ }
+ } elseif ( in_array( $wordEnding, $allVowels )
|| in_array( $wordEnding, $Sonorants ) ) {
+ if ( in_array( $wordLastVowel,
$frontVowels ) ) {
+ $word = $word . "ге";
+ } elseif ( in_array( $wordLastVowel,
$backVowels ) ) {
+ $word = $word . "ға";
+ }
+ }
+ break;
+ case "dc21":
+ case "possessive dative": #täweldık + barıs
+ if ( in_array( $wordEnding, $firstPerson ) ) {
+ if ( in_array( $wordLastVowel,
$frontVowels ) ) {
+ $word = $word . "е";
+ } elseif ( in_array( $wordLastVowel,
$backVowels ) ) {
+ $word = $word . "а";
+ }
+ } elseif ( in_array( $wordEnding, $secondPerson
) ) {
+ if ( in_array( $wordLastVowel,
$frontVowels ) ) {
+ $word = $word . "ге";
+ } elseif ( in_array( $wordLastVowel,
$backVowels ) ) {
+ $word = $word . "ға";
+ }
+ } elseif ( in_array( $wordEnding, $thirdPerson
) ) {
+ if ( in_array( $wordLastVowel, $frontVowels )
) {
+ $word = $word . "не";
+ } elseif ( in_array( $wordLastVowel,
$backVowels ) ) {
+ $word = $word . "на";
+ }
+ }
+ break;
+ case "dc3":
+ case "accusative": #tabıs
+ if ( in_array( $wordEnding, $Consonants ) ) {
+ if ( in_array( $wordLastVowel,
$frontVowels ) ) {
+ $word = $word . "ті";
+ } elseif ( in_array( $wordLastVowel,
$backVowels ) ) {
+ $word = $word . "ты";
+ }
+ } elseif ( in_array( $wordEnding, $allVowels )
) {
+ if ( in_array($wordLastVowel,
$frontVowels ) ) {
+ $word = $word . "ні";
+ } elseif ( in_array( $wordLastVowel,
$backVowels ) ) {
+ $word = $word . "ны";
+ }
+ } elseif ( in_array( $wordEnding, $Sonorants) )
{
+ if ( in_array( $wordLastVowel,
$frontVowels) ) {
+ $word = $word . "ді";
+ } elseif ( in_array( $wordLastVowel,
$backVowels ) ) {
+ $word = $word . "ды";
+ }
+ }
+ break;
+ case "dc31":
+ case "possessive accusative": #täweldık + tabıs
+ if ( in_array( $wordEnding, $firstPerson ) ||
in_array( $wordEnding, $secondPerson ) ) {
+ if ( in_array( $wordLastVowel,
$frontVowels ) ) {
+ $word = $word . "ді";
+ } elseif ( in_array( $wordLastVowel,
$backVowels ) ) {
+ $word = $word . "ды";
+ }
+ } elseif ( in_array( $wordEnding, $thirdPerson
) ) {
+ $word = $word . "н";
+ }
+ break;
+ case "dc4":
+ case "locative": #jatıs
+ if ( in_array( $wordEnding, $Consonants ) ) {
+ if ( in_array( $wordLastVowel,
$frontVowels ) ) {
+ $word = $word . "те";
+ } elseif ( in_array( $wordLastVowel,
$backVowels ) ) {
+ $word = $word . "та";
+ }
+ } elseif ( in_array( $wordEnding, $allVowels )
|| in_array( $wordEnding, $Sonorants ) ) {
+ if ( in_array( $wordLastVowel,
$frontVowels) ) {
+ $word = $word . "де";
+ } elseif ( in_array( $wordLastVowel,
$backVowels ) ) {
+ $word = $word . "да";
+ }
+ }
+ break;
+ case "dc41":
+ case "possessive locative": #täweldık + jatıs
+ if ( in_array( $wordEnding, $firstPerson ) ||
in_array( $wordEnding, $secondPerson ) ) {
+ if ( in_array( $wordLastVowel,
$frontVowels ) ) {
+ $word = $word . "де";
+ } elseif ( in_array( $wordLastVowel,
$backVowels ) ) {
+ $word = $word . "да";
+ }
+ } elseif ( in_array( $wordEnding, $thirdPerson
) ) {
+ if ( in_array( $wordLastVowel,
$frontVowels) ) {
+ $word = $word . "нде";
+ } elseif ( in_array( $wordLastVowel,
$backVowels ) ) {
+ $word = $word . "нда";
+ }
+ }
+ break;
+ case "dc5":
+ case "ablative": #şığıs
+ if ( in_array( $wordEnding, $Consonants ) ) {
+ if ( in_array( $wordLastVowel,
$frontVowels ) ) {
+ $word = $word . "тен";
+ } elseif ( in_array( $wordLastVowel,
$backVowels ) ) {
+ $word = $word . "тан";
+ }
+ } elseif ( in_array($wordEnding, $allVowels )
|| in_array($wordEnding, $Sonants ) || in_array($wordEnding, $Sibilants ) ) {
+ if ( in_array( $wordLastVowel,
$frontVowels ) ) {
+ $word = $word . "ден";
+ } elseif ( in_array( $wordLastVowel,
$backVowels ) ) {
+ $word = $word . "дан";
+ }
+ } elseif ( in_array($wordEnding, $Nasals ) ) {
+ if ( in_array( $wordLastVowel,
$frontVowels ) ) {
+ $word = $word . "нен";
+ } elseif ( in_array( $wordLastVowel,
$backVowels ) ) {
+ $word = $word . "нан";
+ }
+ }
+ break;
+ case "dc51":
+ case "possessive ablative": #täweldık + şığıs
+ if ( in_array( $wordEnding, $firstPerson ) ||
in_array( $wordEnding, $thirdPerson ) ) {
+ if ( in_array( $wordLastVowel,
$frontVowels ) ) {
+ $word = $word . "нен";
+ } elseif ( in_array( $wordLastVowel,
$backVowels ) ) {
+ $word = $word . "нан";
+ }
+ } elseif ( in_array($wordEnding, $secondPerson
) ) {
+ if ( in_array( $wordLastVowel,
$frontVowels ) ) {
+ $word = $word . "ден";
+ } elseif ( in_array( $wordLastVowel,
$backVowels ) ) {
+ $word = $word . "дан";
+ }
+ }
+ break;
+ case "dc6":
+ case "comitative": #kömektes
+ if ( in_array( $wordEnding, $Consonants ) ) {
+ $word = $word . "пен";
+ } elseif ( in_array( $wordEnding, $allVowels )
|| in_array( $wordEnding, $Nasals ) || in_array( $wordEnding, $Sonants ) ) {
+ $word = $word . "мен";
+ } elseif ( in_array( $wordEnding, $Sibilants )
) {
+ $word = $word . "бен";
+ }
+ break;
+ case "dc61":
+ case "possessive comitative": #täweldık + kömektes
+ if ( in_array( $wordEnding, $Consonants ) ) {
+ $word = $word . "пенен";
+ } elseif ( in_array( $wordEnding, $allVowels )
|| in_array( $wordEnding, $Nasals ) || in_array( $wordEnding, $Sonants ) ) {
+ $word = $word . "менен";
+ } elseif ( in_array( $wordEnding, $Sibilants )
) {
+ $word = $word . "бенен";
+ }
+ break;
+ default: #dc0 #nominative #ataw
+ }
+ return $word;
+ }
+
+ function convertGrammarTt_latn( $word, $case ) {
+ global $wgGrammarForms;
+ if ( isset( $wgGrammarForms['tt-tr'][$case][$word] ) ) {
+ return $wgGrammarForms['tt-tr'][$case][$word];
+ }
+ if ( isset( $wgGrammarForms['tt-latn'][$case][$word] ) ) {
+ return $wgGrammarForms['tt-latn'][$case][$word];
+ }
+ // Set up some constants...
+ // Vowels in last syllable
+ $frontVowels = array( "e", "ö", "ü", "i", "ä", "é" );
+ $backVowels = array( "a", "o", "u", "ı" );
+ $allVowels = array( "e", "ö", "ü", "i", "ä", "é", "a", "o",
"u", "ı" );
+ // Preceding letters
+ $Nasals = array( "m", "n", "ñ" );
+ $Sonants = array( "ï", "y", "ý", "l", "r", "w");
+ $Consonants = array( "p", "f", "k", "q", "t", "ş", "s", "x",
"c", "ç", "b", "v", "g", "d" );
+ $Sibilants = array( "j", "z" );
+ $Sonorants = array( "ï", "y", "ý", "l", "r", "w", "m", "n",
"ñ", "j", "z");
+
+ // Possessives
+ $firstPerson = array( "m", "ñ" ); // 1st singular, 2nd unformal
+ $secondPerson = array( "z" ); // 1st plural, 2nd formal
+ $thirdPerson = array( "ı", "i" ); // 3rd
+
+ $lastLetter = self::lastLetter( $word, $allVowels );
+ $wordEnding =& $lastLetter[0];
+ $wordLastVowel =& $lastLetter[1];
+
+ // Now convert the word
+ switch ( $case ) {
+ case "dc1":
+ case "genitive": #ilik
+ if ( in_array( $wordEnding, $Consonants ) ) {
+ if ( in_array( $wordLastVowel,
$frontVowels ) ) {
+ $word = $word . "tiñ";
+ } elseif ( in_array( $wordLastVowel,
$backVowels ) ) {
+ $word = $word . "tıñ";
+ }
+ } elseif ( in_array( $wordEnding, $allVowels )
|| in_array( $wordEnding, $Nasals ) ) {
+ if ( in_array( $wordLastVowel,
$frontVowels ) ) {
+ $word = $word . "niñ";
+ } elseif ( in_array( $wordLastVowel,
$backVowels ) ) {
+ $word = $word . "nıñ";
+ }
+ } elseif ( in_array( $wordEnding, $Sonants ) ||
in_array( $wordEnding, $Sibilants )) {
+ if ( in_array( $wordLastVowel,
$frontVowels ) ) {
+ $word = $word . "diñ";
+ } elseif ( in_array( $wordLastVowel,
$backVowels ) ) {
+ $word = $word . "dıñ";
+ }
+ }
+ break;
+ case "dc2":
+ case "dative": #barıs
+ if ( in_array( $wordEnding, $Consonants ) ) {
+ if ( in_array( $wordLastVowel,
$frontVowels ) ) {
+ $word = $word . "ke";
+ } elseif ( in_array( $wordLastVowel,
$backVowels ) ) {
+ $word = $word . "qa";
+ }
+ } elseif ( in_array( $wordEnding, $allVowels )
|| in_array( $wordEnding, $Sonorants ) ) {
+ if ( in_array( $wordLastVowel,
$frontVowels ) ) {
+ $word = $word . "ge";
+ } elseif ( in_array( $wordLastVowel,
$backVowels ) ) {
+ $word = $word . "ğa";
+ }
+ }
+ break;
+ case "dc21":
+ case "possessive dative": #täweldık + barıs
+ if ( in_array( $wordEnding, $firstPerson ) ) {
+ if ( in_array( $wordLastVowel,
$frontVowels ) ) {
+ $word = $word . "e";
+ } elseif ( in_array( $wordLastVowel,
$backVowels ) ) {
+ $word = $word . "a";
+ }
+ } elseif ( in_array( $wordEnding, $secondPerson
) ) {
+ if ( in_array( $wordLastVowel,
$frontVowels ) ) {
+ $word = $word . "ge";
+ } elseif ( in_array( $wordLastVowel,
$backVowels ) ) {
+ $word = $word . "ğa";
+ }
+ } elseif ( in_array( $wordEnding, $thirdPerson
) ) {
+ if ( in_array( $wordLastVowel, $frontVowels )
) {
+ $word = $word . "ne";
+ } elseif ( in_array( $wordLastVowel,
$backVowels ) ) {
+ $word = $word . "na";
+ }
+ }
+ break;
+ case "dc3":
+ case "accusative": #tabıs
+ if ( in_array( $wordEnding, $Consonants ) ) {
+ if ( in_array( $wordLastVowel,
$frontVowels ) ) {
+ $word = $word . "ti";
+ } elseif ( in_array( $wordLastVowel,
$backVowels ) ) {
+ $word = $word . "tı";
+ }
+ } elseif ( in_array( $wordEnding, $allVowels )
) {
+ if ( in_array($wordLastVowel,
$frontVowels ) ) {
+ $word = $word . "ni";
+ } elseif ( in_array( $wordLastVowel,
$backVowels ) ) {
+ $word = $word . "nı";
+ }
+ } elseif ( in_array( $wordEnding, $Sonorants) )
{
+ if ( in_array( $wordLastVowel,
$frontVowels) ) {
+ $word = $word . "di";
+ } elseif ( in_array( $wordLastVowel,
$backVowels ) ) {
+ $word = $word . "dı";
+ }
+ }
+ break;
+ case "dc31":
+ case "possessive accusative": #täweldık + tabıs
+ if ( in_array( $wordEnding, $firstPerson ) ||
in_array( $wordEnding, $secondPerson ) ) {
+ if ( in_array( $wordLastVowel,
$frontVowels ) ) {
+ $word = $word . "di";
+ } elseif ( in_array( $wordLastVowel,
$backVowels ) ) {
+ $word = $word . "dı";
+ }
+ } elseif ( in_array( $wordEnding, $thirdPerson
) ) {
+ $word = $word . "n";
+ }
+ break;
+ case "dc4":
+ case "locative": #jatıs
+ if ( in_array( $wordEnding, $Consonants ) ) {
+ if ( in_array( $wordLastVowel,
$frontVowels ) ) {
+ $word = $word . "te";
+ } elseif ( in_array( $wordLastVowel,
$backVowels ) ) {
+ $word = $word . "ta";
+ }
+ } elseif ( in_array( $wordEnding, $allVowels )
|| in_array( $wordEnding, $Sonorants ) ) {
+ if ( in_array( $wordLastVowel,
$frontVowels) ) {
+ $word = $word . "de";
+ } elseif ( in_array( $wordLastVowel,
$backVowels ) ) {
+ $word = $word . "da";
+ }
+ }
+ break;
+ case "dc41":
+ case "possessive locative": #täweldık + jatıs
+ if ( in_array( $wordEnding, $firstPerson ) ||
in_array( $wordEnding, $secondPerson ) ) {
+ if ( in_array( $wordLastVowel,
$frontVowels ) ) {
+ $word = $word . "de";
+ } elseif ( in_array( $wordLastVowel,
$backVowels ) ) {
+ $word = $word . "da";
+ }
+ } elseif ( in_array( $wordEnding, $thirdPerson
) ) {
+ if ( in_array( $wordLastVowel,
$frontVowels) ) {
+ $word = $word . "nde";
+ } elseif ( in_array( $wordLastVowel,
$backVowels ) ) {
+ $word = $word . "nda";
+ }
+ }
+ break;
+ case "dc5":
+ case "ablative": #şığıs
+ if ( in_array( $wordEnding, $Consonants ) ) {
+ if ( in_array( $wordLastVowel,
$frontVowels ) ) {
+ $word = $word . "ten";
+ } elseif ( in_array( $wordLastVowel,
$backVowels ) ) {
+ $word = $word . "tan";
+ }
+ } elseif ( in_array($wordEnding, $allVowels )
|| in_array($wordEnding, $Sonants ) || in_array($wordEnding, $Sibilants ) ) {
+ if ( in_array( $wordLastVowel,
$frontVowels ) ) {
+ $word = $word . "den";
+ } elseif ( in_array( $wordLastVowel,
$backVowels ) ) {
+ $word = $word . "dan";
+ }
+ } elseif ( in_array($wordEnding, $Nasals ) ) {
+ if ( in_array( $wordLastVowel,
$frontVowels ) ) {
+ $word = $word . "nen";
+ } elseif ( in_array( $wordLastVowel,
$backVowels ) ) {
+ $word = $word . "nan";
+ }
+ }
+ break;
+ case "dc51":
+ case "possessive ablative": #täweldık + şığıs
+ if ( in_array( $wordEnding, $firstPerson ) ||
in_array( $wordEnding, $thirdPerson ) ) {
+ if ( in_array( $wordLastVowel,
$frontVowels ) ) {
+ $word = $word . "nen";
+ } elseif ( in_array( $wordLastVowel,
$backVowels ) ) {
+ $word = $word . "nan";
+ }
+ } elseif ( in_array($wordEnding, $secondPerson
) ) {
+ if ( in_array( $wordLastVowel,
$frontVowels ) ) {
+ $word = $word . "den";
+ } elseif ( in_array( $wordLastVowel,
$backVowels ) ) {
+ $word = $word . "dan";
+ }
+ }
+ break;
+ case "dc6":
+ case "comitative": #kömektes
+ if ( in_array( $wordEnding, $Consonants ) ) {
+ $word = $word . "pen";
+ } elseif ( in_array( $wordEnding, $allVowels )
|| in_array( $wordEnding, $Nasals ) || in_array( $wordEnding, $Sonants ) ) {
+ $word = $word . "men";
+ } elseif ( in_array( $wordEnding, $Sibilants )
) {
+ $word = $word . "ben";
+ }
+ break;
+ case "dc61":
+ case "possessive comitative": #täweldık + kömektes
+ if ( in_array( $wordEnding, $Consonants ) ) {
+ $word = $word . "penen";
+ } elseif ( in_array( $wordEnding, $allVowels )
|| in_array( $wordEnding, $Nasals ) || in_array( $wordEnding, $Sonants ) ) {
+ $word = $word . "menen";
+ } elseif ( in_array( $wordEnding, $Sibilants )
) {
+ $word = $word . "benen";
+ }
+ break;
+ default: #dc0 #nominative #ataw
+ }
+ return $word;
+ }
+
+ function convertGrammarTt_arab( $word, $case ) {
+ global $wgGrammarForms;
+ if ( isset( $wgGrammarForms['tt-cn'][$case][$word] ) ) {
+ return $wgGrammarForms['tt-cn'][$case][$word];
+ }
+ if ( isset( $wgGrammarForms['tt-arab'][$case][$word] ) ) {
+ return $wgGrammarForms['tt-arab'][$case][$word];
+ }
+ // Set up some constants...
+ // Vowels in last syllable
+ $frontVowels = array( "ە", "ٶ", "ٷ", "ٸ", "ٵ", "ە" );
+ $backVowels = array( "ا", "و", "ۇ", "ى" );
+ $allVowels = array( "ە", "ٶ", "ٷ", "ٸ", "ٵ", "ە", "ا", "و",
"ۇ", "ى" );
+ // Preceding letters
+ $Nasals = array( "م", "ن", "ڭ" );
+ $Sonants = array( "ي", "ي", "ل", "ر", "ۋ");
+ $Consonants = array( "پ", "ف", "ك", "ق", "ت", "ش", "س", "ح",
"تس", "چ", "ب", "ۆ", "گ", "د" );
+ $Sibilants = array( "ج", "ز" );
+ $Sonorants = array( "ي", "ي", "ل", "ر", "ۋ", "م", "ن", "ڭ",
"ج", "ز");
+
+ // Possessives
+ $firstPerson = array( "م", "ڭ" ); // 1st singular, 2nd unformal
+ $secondPerson = array( "ز" ); // 1st plural, 2nd formal
+ $thirdPerson = array( "ى", "ٸ" ); // 3rd
+
+ $lastLetter = self::lastLetter( $word, $allVowels );
+ $wordEnding =& $lastLetter[0];
+ $wordLastVowel =& $lastLetter[1];
+
+ // Now convert the word
+ switch ( $case ) {
+ case "dc1":
+ case "genitive": #ilik
+ if ( in_array( $wordEnding, $Consonants ) ) {
+ if ( in_array( $wordLastVowel,
$frontVowels ) ) {
+ $word = $word . "تٸڭ";
+ } elseif ( in_array( $wordLastVowel,
$backVowels ) ) {
+ $word = $word . "تىڭ";
+ }
+ } elseif ( in_array( $wordEnding, $allVowels )
|| in_array( $wordEnding, $Nasals ) ) {
+ if ( in_array( $wordLastVowel,
$frontVowels ) ) {
+ $word = $word . "نٸڭ";
+ } elseif ( in_array( $wordLastVowel,
$backVowels ) ) {
+ $word = $word . "نىڭ";
+ }
+ } elseif ( in_array( $wordEnding, $Sonants ) ||
in_array( $wordEnding, $Sibilants )) {
+ if ( in_array( $wordLastVowel,
$frontVowels ) ) {
+ $word = $word . "دٸڭ";
+ } elseif ( in_array( $wordLastVowel,
$backVowels ) ) {
+ $word = $word . "دىڭ";
+ }
+ }
+ break;
+ case "dc2":
+ case "dative": #barıs
+ if ( in_array( $wordEnding, $Consonants ) ) {
+ if ( in_array( $wordLastVowel,
$frontVowels ) ) {
+ $word = $word . "كە";
+ } elseif ( in_array( $wordLastVowel,
$backVowels ) ) {
+ $word = $word . "قا";
+ }
+ } elseif ( in_array( $wordEnding, $allVowels )
|| in_array( $wordEnding, $Sonorants ) ) {
+ if ( in_array( $wordLastVowel,
$frontVowels ) ) {
+ $word = $word . "گە";
+ } elseif ( in_array( $wordLastVowel,
$backVowels ) ) {
+ $word = $word . "عا";
+ }
+ }
+ break;
+ case "dc21":
+ case "possessive dative": #täweldık + barıs
+ if ( in_array( $wordEnding, $firstPerson ) ) {
+ if ( in_array( $wordLastVowel,
$frontVowels ) ) {
+ $word = $word . "ە";
+ } elseif ( in_array( $wordLastVowel,
$backVowels ) ) {
+ $word = $word . "ا";
+ }
+ } elseif ( in_array( $wordEnding, $secondPerson
) ) {
+ if ( in_array( $wordLastVowel,
$frontVowels ) ) {
+ $word = $word . "گە";
+ } elseif ( in_array( $wordLastVowel,
$backVowels ) ) {
+ $word = $word . "عا";
+ }
+ } elseif ( in_array( $wordEnding, $thirdPerson
) ) {
+ if ( in_array( $wordLastVowel, $frontVowels )
) {
+ $word = $word . "نە";
+ } elseif ( in_array( $wordLastVowel,
$backVowels ) ) {
+ $word = $word . "نا";
+ }
+ }
+ break;
+ case "dc3":
+ case "accusative": #tabıs
+ if ( in_array( $wordEnding, $Consonants ) ) {
+ if ( in_array( $wordLastVowel,
$frontVowels ) ) {
+ $word = $word . "تٸ";
+ } elseif ( in_array( $wordLastVowel,
$backVowels ) ) {
+ $word = $word . "تى";
+ }
+ } elseif ( in_array( $wordEnding, $allVowels )
) {
+ if ( in_array($wordLastVowel,
$frontVowels ) ) {
+ $word = $word . "نٸ";
+ } elseif ( in_array( $wordLastVowel,
$backVowels ) ) {
+ $word = $word . "نى";
+ }
+ } elseif ( in_array( $wordEnding, $Sonorants) )
{
+ if ( in_array( $wordLastVowel,
$frontVowels) ) {
+ $word = $word . "دٸ";
+ } elseif ( in_array( $wordLastVowel,
$backVowels ) ) {
+ $word = $word . "دى";
+ }
+ }
+ break;
+ case "dc31":
+ case "possessive accusative": #täweldık + tabıs
+ if ( in_array( $wordEnding, $firstPerson ) ||
in_array( $wordEnding, $secondPerson ) ) {
+ if ( in_array( $wordLastVowel,
$frontVowels ) ) {
+ $word = $word . "دٸ";
+ } elseif ( in_array( $wordLastVowel,
$backVowels ) ) {
+ $word = $word . "دى";
+ }
+ } elseif ( in_array( $wordEnding, $thirdPerson
) ) {
+ $word = $word . "ن";
+ }
+ break;
+ case "dc4":
+ case "locative": #jatıs
+ if ( in_array( $wordEnding, $Consonants ) ) {
+ if ( in_array( $wordLastVowel,
$frontVowels ) ) {
+ $word = $word . "تە";
+ } elseif ( in_array( $wordLastVowel,
$backVowels ) ) {
+ $word = $word . "تا";
+ }
+ } elseif ( in_array( $wordEnding, $allVowels )
|| in_array( $wordEnding, $Sonorants ) ) {
+ if ( in_array( $wordLastVowel,
$frontVowels) ) {
+ $word = $word . "دە";
+ } elseif ( in_array( $wordLastVowel,
$backVowels ) ) {
+ $word = $word . "دا";
+ }
+ }
+ break;
+ case "dc41":
+ case "possessive locative": #täweldık + jatıs
+ if ( in_array( $wordEnding, $firstPerson ) ||
in_array( $wordEnding, $secondPerson ) ) {
+ if ( in_array( $wordLastVowel,
$frontVowels ) ) {
+ $word = $word . "دە";
+ } elseif ( in_array( $wordLastVowel,
$backVowels ) ) {
+ $word = $word . "دا";
+ }
+ } elseif ( in_array( $wordEnding, $thirdPerson
) ) {
+ if ( in_array( $wordLastVowel,
$frontVowels) ) {
+ $word = $word . "ندە";
+ } elseif ( in_array( $wordLastVowel,
$backVowels ) ) {
+ $word = $word . "ندا";
+ }
+ }
+ break;
+ case "dc5":
+ case "ablative": #şığıs
+ if ( in_array( $wordEnding, $Consonants ) ) {
+ if ( in_array( $wordLastVowel,
$frontVowels ) ) {
+ $word = $word . "تەن";
+ } elseif ( in_array( $wordLastVowel,
$backVowels ) ) {
+ $word = $word . "تان";
+ }
+ } elseif ( in_array($wordEnding, $allVowels )
|| in_array($wordEnding, $Sonants ) || in_array($wordEnding, $Sibilants ) ) {
+ if ( in_array( $wordLastVowel,
$frontVowels ) ) {
+ $word = $word . "دەن";
+ } elseif ( in_array( $wordLastVowel,
$backVowels ) ) {
+ $word = $word . "دان";
+ }
+ } elseif ( in_array($wordEnding, $Nasals ) ) {
+ if ( in_array( $wordLastVowel,
$frontVowels ) ) {
+ $word = $word . "نەن";
+ } elseif ( in_array( $wordLastVowel,
$backVowels ) ) {
+ $word = $word . "نان";
+ }
+ }
+ break;
+ case "dc51":
+ case "possessive ablative": #täweldık + şığıs
+ if ( in_array( $wordEnding, $firstPerson ) ||
in_array( $wordEnding, $thirdPerson ) ) {
+ if ( in_array( $wordLastVowel,
$frontVowels ) ) {
+ $word = $word . "نەن";
+ } elseif ( in_array( $wordLastVowel,
$backVowels ) ) {
+ $word = $word . "نان";
+ }
+ } elseif ( in_array($wordEnding, $secondPerson
) ) {
+ if ( in_array( $wordLastVowel,
$frontVowels ) ) {
+ $word = $word . "دەن";
+ } elseif ( in_array( $wordLastVowel,
$backVowels ) ) {
+ $word = $word . "دان";
+ }
+ }
+ break;
+ case "dc6":
+ case "comitative": #kömektes
+ if ( in_array( $wordEnding, $Consonants ) ) {
+ $word = $word . "پەن";
+ } elseif ( in_array( $wordEnding, $allVowels )
|| in_array( $wordEnding, $Nasals ) || in_array( $wordEnding, $Sonants ) ) {
+ $word = $word . "مەن";
+ } elseif ( in_array( $wordEnding, $Sibilants )
) {
+ $word = $word . "بەن";
+ }
+ break;
+ case "dc61":
+ case "possessive comitative": #täweldık + kömektes
+ if ( in_array( $wordEnding, $Consonants ) ) {
+ $word = $word . "پەنەن";
+ } elseif ( in_array( $wordEnding, $allVowels )
|| in_array( $wordEnding, $Nasals ) || in_array( $wordEnding, $Sonants ) ) {
+ $word = $word . "مەنەن";
+ } elseif ( in_array( $wordEnding, $Sibilants )
) {
+ $word = $word . "بەنەن";
+ }
+ break;
+ default: #dc0 #nominative #ataw
+ }
+ return $word;
+ }
+
+ function lastLetter( $word, $allVowels ) {
+ $lastLetter = array();
+ $ar = array();
+
+ // Put the word in a form we can play with since we're using
UTF-8
+ $ar = preg_split('//u', parent::lc($word), -1,
PREG_SPLIT_NO_EMPTY);
+
+ // Here's an array with the order of the letters in the word
reversed
+ // so we can find a match quicker *shrug*
+ $wordReversed = array_reverse( $ar );
+
+ // Here's the last letter in the word
+ $lastLetter[0] = $ar[count( $ar ) - 1];
+
+ // Find the last vowel in the word
+ $lastLetter[1] = NULL;
+ foreach ( $wordReversed as $xvalue ) {
+ foreach ( $allVowels as $yvalue ) {
+ if ( strcmp( $xvalue, $yvalue ) == 0 ) {
+ $lastLetter[1] = $xvalue;
+ break;
+ } else {
+ continue;
+ }
+ }
+ if ( $lastLetter[1] !== NULL ) {
+ break;
+ } else {
+ continue;
+ }
+ }
+
+ return $lastLetter;
+ }
+
+ /**
+ * Avoid grouping whole numbers between 0 to 9999
+ */
+ function commafy( $_ ) {
+ if ( !preg_match( '/^\d{1,4}$/', $_ ) ) {
+ return strrev( (string)preg_replace(
'/(\d{3})(?=\d)(?!\d*\.)/', '$1,', strrev($_) ) );
+ } else {
+ return $_;
+ }
+ }
+}
--
To view, visit https://gerrit.wikimedia.org/r/185090
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I948529190c57d01107beb089de549c0b11a8573c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Kaldari <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits