123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248 |
- <?php
- require_once( dirname(__FILE__).'/../LanguageConverter.php' );
- require_once( dirname(__FILE__).'/LanguageKu_ku.php' );
- 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', 'ش' => 'ş',
- 'ت' => 't', 'ڤ' => 'v', 'خ' => 'x', 'غ' => 'x', 'ز' => 'z',
-
- 'ڵ' => 'll',
- 'ڕ' => 'rr',
- 'ا' => 'a',
-
- 'ە' => 'e',
- 'ه' => 'e',
- 'ه' => 'e',
- 'ة' => 'e',
- 'ێ' => 'ê',
- 'ي' => 'î',
- 'ی' => 'î',
- 'ى' => 'î',
- 'ۆ' => 'o',
- 'و' => 'w',
- 'ئ' => '',
- '،' => ',',
- 'ع' => '\'',
- '؟' => '?',
-
- '٠' => '0',
- '١' => '1',
- '٢' => '2',
- '٣' => '3',
- '٤' => '4',
- '٥' => '5',
- '٦' => '6',
- '٧' => '7',
- '٨' => '8',
- '٩' => '9',
- );
- 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' => 'ز',
-
-
-
-
-
-
- 'a' => 'ا',
- 'e' => 'ە',
- 'ê' => 'ێ',
- 'i' => '',
- 'î' => 'ی',
- 'o' => 'ۆ',
- 'u' => 'و',
- 'û' => 'وو',
- 'w' => 'و',
- ',' => '،',
- '?' => '؟',
-
- ' a' => 'ئا ',
- ' e' => 'ئە ',
- ' ê' => 'ئێ ',
- ' î' => 'ئی ',
- ' o' => 'ئۆ ',
- ' u' => 'ئو ',
- ' û' => 'ئوو ',
- 'A' => 'ئا',
- 'E' => 'ئە',
- 'Ê' => 'ئێ',
- 'Î' => 'ئی',
- 'O' => 'ئۆ',
- 'U' => 'ئو',
- 'Û' => 'ئوو',
- ' A' => 'ئا ',
- ' E' => 'ئە ',
- ' Ê' => 'ئێ ',
- ' Î' => 'ئی ',
- ' O' => 'ئۆ ',
- ' U' => 'ئو ',
- ' Û' => 'ئوو ',
-
-
- );
- function loadDefaultTables() {
- $this->mTables = array(
- 'ku-latn' => new ReplacementArray( $this->mArabicToLatin ),
- 'ku-arab' => new ReplacementArray( $this->mLatinToArabic ),
- 'ku' => new ReplacementArray()
- );
- }
-
- function parserConvert( $text, &$parser ){
- if(is_object($parser->getTitle() ) && $parser->getTitle()->isTalkPage())
- $this->mDoContentConvert=false;
- else
- $this->mDoContentConvert=true;
- return parent::parserConvert($text, $parser );
- }
-
- function findVariantLink( &$link, &$nt, $ignoreOtherCond = false ) {
-
- 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;
- }
-
- function markNoConversion($text, $noParse=false) {
- if($noParse || preg_match("/^https?:\/\/|ftp:\/\/|irc:\/\//",$text))
- return parent::markNoConversion($text);
- return $text;
- }
-
- 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);
- }
-
- function translate($text, $toVariant){
- $breaks = '[^\w\x80-\xff]';
-
- if( !isset( $this->mTables[$toVariant] ) ) {
- throw new MWException( "Broken variant table: " . implode( ',', array_keys( $this->mTables ) ) );
- }
- return parent::translate( $text, $toVariant );
- }
- }
- 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;
- }
- }
|