<?php
-require_once( dirname( __FILE__ ) . '/../LanguageConverter.php' );
-require_once( dirname( __FILE__ ) . '/LanguageKu_ku.php' );
+/**
+ * Kurdish 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
+ */
/**
* Kurdish converter routines
* @ingroup Language
*/
class KuConverter extends LanguageConverter {
- var $mArabicToLatin = array(
+ public $mArabicToLatin = [
'ب' => 'b', 'ج' => 'c', 'چ' => 'ç', 'د' => 'd', 'ف' => 'f', 'گ' => 'g', 'ھ' => 'h',
'ہ' => 'h', 'ه' => 'h', 'ح' => 'h', 'ژ' => 'j', 'ك' => 'k', 'ک' => 'k', 'ل' => 'l',
'م' => 'm', 'ن' => 'n', 'پ' => 'p', 'ق' => 'q', 'ر' => 'r', 'س' => 's', 'ش' => 'ş',
/* Doppel- und Halbvokale */
'ڵ' => 'll', # ll
- 'ڕ' => 'rr', # rr
- 'ا' => 'a',
+ 'ڕ' => 'rr', # rr
+ 'ا' => 'a',
# 'ئێ' => 'ê', # initial e
- 'ە' => 'e',
- 'ه' => 'e', # with one non-joiner
- 'ه' => 'e', # with two non-joiner
- 'ة' => 'e',
+ 'ە' => 'e',
+ 'ه' => 'e', # with one non-joiner
+ 'ه' => 'e', # with two non-joiner
+ 'ة' => 'e',
'ێ' => 'ê',
- 'ي' => 'î',
- 'ی' => 'î', # U+06CC db 8c ARABIC LETTER FARSI YEH
- 'ى' => 'î', # U+0649 d9 89 ARABIC LETTER ALEF MAKSURA
- 'ۆ' => 'o',
- 'و' => 'w',
- 'ئ' => '', # initial hemze should not be shown
- '،' => ',',
- 'ع' => '\'', # ayn
- '؟' => '?',
+ 'ي' => 'î',
+ 'ی' => 'î', # U+06CC db 8c ARABIC LETTER FARSI YEH
+ 'ى' => 'î', # U+0649 d9 89 ARABIC LETTER ALEF MAKSURA
+ 'ۆ' => 'o',
+ 'و' => 'w',
+ 'ئ' => '', # initial hemze should not be shown
+ '،' => ',',
+ 'ع' => '\'', # ayn
+ '؟' => '?',
# digits
'٠' => '0', # ٠
'٧' => '7', # ٧
'٨' => '8', # ٨
'٩' => '9', # ٩
- );
+ ];
- var $mLatinToArabic = array(
+ public $mLatinToArabic = [
'b' => 'ب', 'c' => 'ج', 'ç' => 'چ', 'd' => 'د', 'f' => 'ف', 'g' => 'گ',
'h' => 'ه', 'j' => 'ژ', 'k' => 'ک', 'l' => 'ل',
'm' => 'م', 'n' => 'ن', 'p' => 'پ', 'q' => 'ق', 'r' => 'ر', 's' => 'س', 'ş' => 'ش',
't' => 'ت', 'v' => 'ڤ',
- 'x' => 'خ', 'y' => 'ی', 'z' => 'ز',
-
+ 'x' => 'خ', 'y' => 'ی', 'z' => 'ز',
'B' => 'ب', 'C' => 'ج', 'Ç' => 'چ', 'D' => 'د', 'F' => 'ف', 'G' => 'گ', 'H' => 'ھ',
'H' => 'ہ', 'H' => 'ه', 'H' => 'ح', 'J' => 'ژ', 'K' => 'ك', 'K' => 'ک', 'L' => 'ل',
' o' => 'ئۆ ',
' u' => 'ئو ',
' û' => 'ئوو ',
- '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
+ # eyn erstmal deaktivieren, einfache Anführungsstriche sind einfach zu
+ # häufig, um sie als eyn zu interpretieren.
# '\'' => 'ع',
/* # deactivated for now, breaks links i.e. in header of Special:Recentchanges :-(
'8' => '٨', # ٨
'9' => '٩', # ٩
*/
- );
+ ];
function loadDefaultTables() {
- $this->mTables = array(
+ $this->mTables = [
'ku-latn' => new ReplacementArray( $this->mArabicToLatin ),
'ku-arab' => new ReplacementArray( $this->mLatinToArabic ),
- 'ku' => new ReplacementArray()
- );
+ 'ku' => new ReplacementArray()
+ ];
}
- /*
+ /**
* A function wrapper:
* - if there is no selected variant, leave the link
* names as they were
* - do not try to find variants for usernames
+ *
+ * @param string &$link
+ * @param Title &$nt
+ * @param bool $ignoreOtherCond
*/
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 )
+ if ( $ns == NS_USER || $ns == NS_USER_TALK ) {
return;
+ }
}
$oldlink = $link;
parent::findVariantLink( $link, $nt, $ignoreOtherCond );
- if ( $this->getPreferredVariant() == $this->mMainLanguageCode )
+ if ( $this->getPreferredVariant() == $this->mMainLanguageCode ) {
$link = $oldlink;
- }
-
- /*
- * 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;
- }
-
- /*
- * 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, specials:
* - ommiting roman numbers
+ *
+ * @param string $text
+ * @param bool $toVariant
+ *
+ * @throws MWException
+ * @return string
*/
function translate( $text, $toVariant ) {
+ $this->loadTables();
/* From Kazakh interface, maybe we need it later
$breaks = '[^\w\x80-\xff]';
// regexp for roman numbers
class LanguageKu extends LanguageKu_ku {
function __construct() {
- global $wgHooks;
parent::__construct();
- $variants = array( 'ku', 'ku-arab', 'ku-latn' );
- $variantfallbacks = array(
- 'ku' => 'ku-latn',
+ $variants = [ 'ku', 'ku-arab', 'ku-latn' ];
+ $variantfallbacks = [
+ 'ku' => 'ku-latn',
'ku-arab' => 'ku-latn',
'ku-latn' => 'ku-arab',
- );
+ ];
$this->mConverter = new KuConverter( $this, 'ku', $variants, $variantfallbacks );
- $wgHooks['ArticleSaveComplete'][] = $this->mConverter;
}
}