2007-06-18 12:55:01 +00:00
|
|
|
|
<?php
|
2010-07-29 09:43:18 +00:00
|
|
|
|
require_once( dirname( __FILE__ ) . '/../LanguageConverter.php' );
|
|
|
|
|
|
require_once( dirname( __FILE__ ) . '/LanguageKu_ku.php' );
|
2007-06-18 12:55:01 +00:00
|
|
|
|
|
2010-10-10 12:53:37 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* Kurdish converter routines
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
|
*
|
|
|
|
|
|
* @ingroup Language
|
|
|
|
|
|
*/
|
2007-06-18 12:55:01 +00:00
|
|
|
|
class KuConverter extends LanguageConverter {
|
|
|
|
|
|
var $mArabicToLatin = array(
|
|
|
|
|
|
'ب' => 'b', 'ج' => 'c', 'چ' => 'ç', 'د' => 'd', 'ف' => 'f', 'گ' => 'g', 'ھ' => 'h',
|
|
|
|
|
|
'ہ' => 'h', 'ه' => 'h', 'ح' => 'h', 'ژ' => 'j', 'ك' => 'k', 'ک' => 'k', 'ل' => 'l',
|
|
|
|
|
|
'م' => 'm', 'ن' => 'n', 'پ' => 'p', 'ق' => 'q', 'ر' => 'r', 'س' => 's', 'ش' => 'ş',
|
2008-05-17 17:10:18 +00:00
|
|
|
|
'ت' => 't', 'ڤ' => 'v', 'خ' => 'x', 'غ' => 'x', 'ز' => 'z',
|
2007-06-18 12:55:01 +00:00
|
|
|
|
|
2007-12-20 18:19:09 +00:00
|
|
|
|
// ک و => ku -- ist richtig
|
|
|
|
|
|
// و ك=> ku -- ist auch richtig
|
|
|
|
|
|
|
2007-06-18 12:55:01 +00:00
|
|
|
|
/* Doppel- und Halbvokale */
|
2010-07-29 09:43:18 +00:00
|
|
|
|
'ڵ' => 'll', # ll
|
|
|
|
|
|
'ڕ' => 'rr', # rr
|
2007-06-18 12:55:01 +00:00
|
|
|
|
'ا' => 'a',
|
2007-07-03 20:41:48 +00:00
|
|
|
|
# 'ئێ' => 'ê', # initial e
|
2007-06-18 12:55:01 +00:00
|
|
|
|
'ە' => 'e',
|
2007-07-03 20:41:48 +00:00
|
|
|
|
'ه' => 'e', # with one non-joiner
|
|
|
|
|
|
'ه' => 'e', # with two non-joiner
|
2007-06-18 12:55:01 +00:00
|
|
|
|
'ة' => 'e',
|
|
|
|
|
|
'ێ' => 'ê',
|
|
|
|
|
|
'ي' => 'î',
|
2007-07-03 20:41:48 +00:00
|
|
|
|
'ی' => 'î', # U+06CC db 8c ARABIC LETTER FARSI YEH
|
|
|
|
|
|
'ى' => 'î', # U+0649 d9 89 ARABIC LETTER ALEF MAKSURA
|
2007-06-18 12:55:01 +00:00
|
|
|
|
'ۆ' => 'o',
|
|
|
|
|
|
'و' => 'w',
|
2007-07-03 20:41:48 +00:00
|
|
|
|
'ئ' => '', # initial hemze should not be shown
|
2008-05-17 17:10:18 +00:00
|
|
|
|
'،' => ',',
|
2007-06-18 12:55:01 +00:00
|
|
|
|
'ع' => '\'', # ayn
|
|
|
|
|
|
'؟' => '?',
|
2007-12-20 18:19:09 +00:00
|
|
|
|
|
|
|
|
|
|
# digits
|
|
|
|
|
|
'٠' => '0', # ٠
|
|
|
|
|
|
'١' => '1', # ١
|
|
|
|
|
|
'٢' => '2', # ٢
|
|
|
|
|
|
'٣' => '3', # ٣
|
|
|
|
|
|
'٤' => '4', # ٤
|
|
|
|
|
|
'٥' => '5', # ٥
|
|
|
|
|
|
'٦' => '6', # ٦
|
|
|
|
|
|
'٧' => '7', # ٧
|
|
|
|
|
|
'٨' => '8', # ٨
|
|
|
|
|
|
'٩' => '9', # ٩
|
2007-06-18 12:55:01 +00:00
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
var $mLatinToArabic = array(
|
|
|
|
|
|
'b' => 'ب', 'c' => 'ج', 'ç' => 'چ', 'd' => 'د', 'f' => 'ف', 'g' => 'گ',
|
|
|
|
|
|
'h' => 'ه', 'j' => 'ژ', 'k' => 'ک', 'l' => 'ل',
|
|
|
|
|
|
'm' => 'م', 'n' => 'ن', 'p' => 'پ', 'q' => 'ق', 'r' => 'ر', 's' => 'س', 'ş' => 'ش',
|
|
|
|
|
|
't' => 'ت', 'v' => 'ڤ',
|
|
|
|
|
|
'x' => 'خ', 'y' => 'ی', 'z' => 'ز',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
'B' => 'ب', 'C' => 'ج', 'Ç' => 'چ', 'D' => 'د', 'F' => 'ف', 'G' => 'گ', 'H' => 'ھ',
|
|
|
|
|
|
'H' => 'ہ', 'H' => 'ه', 'H' => 'ح', 'J' => 'ژ', 'K' => 'ك', 'K' => 'ک', 'L' => 'ل',
|
|
|
|
|
|
'M' => 'م', 'N' => 'ن', 'P' => 'پ', 'Q' => 'ق', 'R' => 'ر', 'S' => 'س', 'Ş' => 'ش',
|
|
|
|
|
|
'T' => 'ت', 'V' => 'ڤ', 'W' => 'و', 'X' => 'خ',
|
|
|
|
|
|
'Y' => 'ی', 'Z' => 'ز',
|
|
|
|
|
|
|
|
|
|
|
|
/* Doppelkonsonanten */
|
|
|
|
|
|
# 'll' => 'ڵ', # wenn es geht, doppel-l und l getrennt zu behandeln
|
|
|
|
|
|
# 'rr' => 'ڕ', # selbiges für doppel-r
|
|
|
|
|
|
|
|
|
|
|
|
/* Einzelne Großbuchstaben */
|
2010-07-29 09:43:18 +00:00
|
|
|
|
// ' C' => 'ج',
|
2007-06-18 12:55:01 +00:00
|
|
|
|
|
|
|
|
|
|
/* Vowels */
|
|
|
|
|
|
'a' => 'ا',
|
|
|
|
|
|
'e' => 'ە',
|
|
|
|
|
|
'ê' => 'ێ',
|
|
|
|
|
|
'i' => '',
|
|
|
|
|
|
'î' => 'ی',
|
|
|
|
|
|
'o' => 'ۆ',
|
|
|
|
|
|
'u' => 'و',
|
|
|
|
|
|
'û' => 'وو',
|
|
|
|
|
|
'w' => 'و',
|
2008-05-17 17:10:18 +00:00
|
|
|
|
',' => '،',
|
2007-06-18 12:55:01 +00:00
|
|
|
|
'?' => '؟',
|
|
|
|
|
|
|
|
|
|
|
|
# Try to replace the leading vowel
|
|
|
|
|
|
' a' => 'ئا ',
|
|
|
|
|
|
' e' => 'ئە ',
|
|
|
|
|
|
' ê' => 'ئێ ',
|
|
|
|
|
|
' î' => 'ئی ',
|
|
|
|
|
|
' o' => 'ئۆ ',
|
|
|
|
|
|
' u' => 'ئو ',
|
|
|
|
|
|
' û' => 'ئوو ',
|
|
|
|
|
|
'A' => 'ئا',
|
|
|
|
|
|
'E' => 'ئە',
|
|
|
|
|
|
'Ê' => 'ئێ',
|
|
|
|
|
|
'Î' => 'ئی',
|
|
|
|
|
|
'O' => 'ئۆ',
|
|
|
|
|
|
'U' => 'ئو',
|
|
|
|
|
|
'Û' => 'ئوو',
|
|
|
|
|
|
' A' => 'ئا ',
|
|
|
|
|
|
' E' => 'ئە ',
|
|
|
|
|
|
' Ê' => 'ئێ ',
|
|
|
|
|
|
' Î' => 'ئی ',
|
|
|
|
|
|
' O' => 'ئۆ ',
|
|
|
|
|
|
' U' => 'ئو ',
|
|
|
|
|
|
' Û' => 'ئوو ',
|
|
|
|
|
|
# eyn erstmal deaktivieren, einfache Anführungsstriche sind einfach zu häufig, um sie als eyn zu interpretieren
|
2008-05-17 17:10:18 +00:00
|
|
|
|
# '\'' => 'ع',
|
2007-06-18 12:55:01 +00:00
|
|
|
|
|
2007-12-20 18:19:09 +00:00
|
|
|
|
/* # deactivated for now, breaks links i.e. in header of Special:Recentchanges :-(
|
|
|
|
|
|
# digits
|
|
|
|
|
|
'0' => '٠', # ٠
|
|
|
|
|
|
'1' => '١', # ١
|
|
|
|
|
|
'2' => '٢', # ٢
|
|
|
|
|
|
'3' => '٣', # ٣
|
|
|
|
|
|
'4' => '٤', # ٤
|
|
|
|
|
|
'5' => '٥', # ٥
|
|
|
|
|
|
'6' => '٦', # ٦
|
|
|
|
|
|
'7' => '٧', # ٧
|
|
|
|
|
|
'8' => '٨', # ٨
|
|
|
|
|
|
'9' => '٩', # ٩
|
|
|
|
|
|
*/
|
|
|
|
|
|
);
|
2007-06-18 12:55:01 +00:00
|
|
|
|
|
|
|
|
|
|
function loadDefaultTables() {
|
|
|
|
|
|
$this->mTables = array(
|
|
|
|
|
|
'ku-latn' => new ReplacementArray( $this->mArabicToLatin ),
|
|
|
|
|
|
'ku-arab' => new ReplacementArray( $this->mLatinToArabic ),
|
|
|
|
|
|
'ku' => new ReplacementArray()
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2011-05-22 22:05:18 +00:00
|
|
|
|
/**
|
2007-06-18 12:55:01 +00:00
|
|
|
|
* A function wrapper:
|
2008-05-17 17:10:18 +00:00
|
|
|
|
* - if there is no selected variant, leave the link
|
2007-06-18 12:55:01 +00:00
|
|
|
|
* names as they were
|
|
|
|
|
|
* - do not try to find variants for usernames
|
|
|
|
|
|
*/
|
2009-02-02 07:54:43 +00:00
|
|
|
|
function findVariantLink( &$link, &$nt, $ignoreOtherCond = false ) {
|
2007-06-18 12:55:01 +00:00
|
|
|
|
// check for user namespace
|
2010-07-29 09:43:18 +00:00
|
|
|
|
if ( is_object( $nt ) ) {
|
2007-06-18 12:55:01 +00:00
|
|
|
|
$ns = $nt->getNamespace();
|
2010-07-29 09:43:18 +00:00
|
|
|
|
if ( $ns == NS_USER || $ns == NS_USER_TALK )
|
2007-06-18 12:55:01 +00:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2010-07-29 09:43:18 +00:00
|
|
|
|
$oldlink = $link;
|
2009-02-02 07:54:43 +00:00
|
|
|
|
parent::findVariantLink( $link, $nt, $ignoreOtherCond );
|
2010-07-29 09:43:18 +00:00
|
|
|
|
if ( $this->getPreferredVariant() == $this->mMainLanguageCode )
|
|
|
|
|
|
$link = $oldlink;
|
2007-06-18 12:55:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2011-05-22 22:05:18 +00:00
|
|
|
|
/**
|
2007-06-18 12:55:01 +00:00
|
|
|
|
* We want our external link captions to be converted in variants,
|
|
|
|
|
|
* so we return the original text instead -{$text}-, except for URLs
|
|
|
|
|
|
*/
|
2010-07-29 09:43:18 +00:00
|
|
|
|
function markNoConversion( $text, $noParse = false ) {
|
|
|
|
|
|
if ( $noParse || preg_match( "/^https?:\/\/|ftp:\/\/|irc:\/\//", $text ) )
|
|
|
|
|
|
return parent::markNoConversion( $text );
|
2007-06-18 12:55:01 +00:00
|
|
|
|
return $text;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2011-05-22 22:05:18 +00:00
|
|
|
|
/**
|
2007-06-18 12:55:01 +00:00
|
|
|
|
* An ugly function wrapper for parsing Image titles
|
|
|
|
|
|
* (to prevent image name conversion)
|
|
|
|
|
|
*/
|
2010-07-29 09:43:18 +00:00
|
|
|
|
function autoConvert( $text, $toVariant = false ) {
|
2007-06-18 12:55:01 +00:00
|
|
|
|
global $wgTitle;
|
2010-07-29 09:43:18 +00:00
|
|
|
|
if ( is_object( $wgTitle ) && $wgTitle->getNameSpace() == NS_FILE ) {
|
2007-06-18 12:55:01 +00:00
|
|
|
|
$imagename = $wgTitle->getNsText();
|
2010-07-29 09:43:18 +00:00
|
|
|
|
if ( preg_match( "/^$imagename:/", $text ) ) return $text;
|
2007-06-18 12:55:01 +00:00
|
|
|
|
}
|
2010-07-29 09:43:18 +00:00
|
|
|
|
return parent::autoConvert( $text, $toVariant );
|
2007-06-18 12:55:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* It translates text into variant, specials:
|
|
|
|
|
|
* - ommiting roman numbers
|
|
|
|
|
|
*/
|
2010-07-29 09:43:18 +00:00
|
|
|
|
function translate( $text, $toVariant ) {
|
2007-06-18 12:55:01 +00:00
|
|
|
|
/* From Kazakh interface, maybe we need it later
|
2010-08-13 20:58:16 +00:00
|
|
|
|
$breaks = '[^\w\x80-\xff]';
|
2007-06-18 12:55:01 +00:00
|
|
|
|
// regexp for roman numbers
|
|
|
|
|
|
$roman = 'M{0,4}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})';
|
|
|
|
|
|
$roman = '';
|
|
|
|
|
|
|
|
|
|
|
|
$reg = '/^'.$roman.'$|^'.$roman.$breaks.'|'.$breaks.$roman.'$|'.$breaks.$roman.$breaks.'/';
|
|
|
|
|
|
|
|
|
|
|
|
$matches = preg_split($reg, $text, -1, PREG_SPLIT_OFFSET_CAPTURE);
|
|
|
|
|
|
|
|
|
|
|
|
$m = array_shift($matches);
|
|
|
|
|
|
if( !isset( $this->mTables[$toVariant] ) ) {
|
|
|
|
|
|
throw new MWException( "Broken variant table: " . implode( ',', array_keys( $this->mTables ) ) );
|
|
|
|
|
|
}
|
|
|
|
|
|
$ret = $this->mTables[$toVariant]->replace( $m[0] );
|
|
|
|
|
|
$mstart = $m[1]+strlen($m[0]);
|
|
|
|
|
|
foreach($matches as $m) {
|
|
|
|
|
|
$ret .= substr($text, $mstart, $m[1]-$mstart);
|
|
|
|
|
|
$ret .= parent::translate($m[0], $toVariant);
|
|
|
|
|
|
$mstart = $m[1] + strlen($m[0]);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return $ret;
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
2010-07-29 09:43:18 +00:00
|
|
|
|
if ( !isset( $this->mTables[$toVariant] ) ) {
|
2007-06-18 12:55:01 +00:00
|
|
|
|
throw new MWException( "Broken variant table: " . implode( ',', array_keys( $this->mTables ) ) );
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return parent::translate( $text, $toVariant );
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
|
/**
|
2010-10-10 12:53:37 +00:00
|
|
|
|
* Kurdish (Kurdî / كوردی)
|
|
|
|
|
|
*
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
|
* @ingroup Language
|
|
|
|
|
|
*/
|
2007-06-18 12:55:01 +00:00
|
|
|
|
class LanguageKu extends LanguageKu_ku {
|
|
|
|
|
|
|
|
|
|
|
|
function __construct() {
|
|
|
|
|
|
global $wgHooks;
|
|
|
|
|
|
parent::__construct();
|
|
|
|
|
|
|
|
|
|
|
|
$variants = array( 'ku', 'ku-arab', 'ku-latn' );
|
|
|
|
|
|
$variantfallbacks = array(
|
|
|
|
|
|
'ku' => 'ku-latn',
|
|
|
|
|
|
'ku-arab' => 'ku-latn',
|
|
|
|
|
|
'ku-latn' => 'ku-arab',
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
$this->mConverter = new KuConverter( $this, 'ku', $variants, $variantfallbacks );
|
|
|
|
|
|
$wgHooks['ArticleSaveComplete'][] = $this->mConverter;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|