From 9db190c7e736ec8d063187d4241b59feaf7dc2d1 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Wed, 22 Jun 2011 11:28:20 +0200 Subject: update to MediaWiki 1.17.0 --- languages/classes/LanguageAm.php | 5 +- languages/classes/LanguageAr.php | 14 +- languages/classes/LanguageBat_smg.php | 8 +- languages/classes/LanguageBe.php | 6 +- languages/classes/LanguageBe_tarask.php | 45 +++++- languages/classes/LanguageBg.php | 6 +- languages/classes/LanguageBh.php | 5 +- languages/classes/LanguageBs.php | 8 +- languages/classes/LanguageCs.php | 2 +- languages/classes/LanguageCu.php | 24 +-- languages/classes/LanguageCy.php | 2 +- languages/classes/LanguageDsb.php | 2 +- languages/classes/LanguageEo.php | 114 ++++++++++----- languages/classes/LanguageEt.php | 6 +- languages/classes/LanguageFi.php | 22 +-- languages/classes/LanguageFr.php | 4 +- languages/classes/LanguageGa.php | 8 +- languages/classes/LanguageGan.php | 38 ++--- languages/classes/LanguageGd.php | 2 +- languages/classes/LanguageGv.php | 6 +- languages/classes/LanguageHe.php | 36 ++--- languages/classes/LanguageHi.php | 5 +- languages/classes/LanguageHr.php | 6 +- languages/classes/LanguageHsb.php | 2 +- languages/classes/LanguageHu.php | 2 +- languages/classes/LanguageHy.php | 44 +++--- languages/classes/LanguageJa.php | 10 +- languages/classes/LanguageKaa.php | 2 +- languages/classes/LanguageKk.deps.php | 4 +- languages/classes/LanguageKk.php | 153 ++++++++++--------- languages/classes/LanguageKk_cyrl.php | 153 ++++++++++--------- languages/classes/LanguageKm.php | 2 +- languages/classes/LanguageKsh.php | 162 +++++++++++++++++++- languages/classes/LanguageKu.deps.php | 4 +- languages/classes/LanguageKu.php | 48 +++--- languages/classes/LanguageKu_ku.php | 2 +- languages/classes/LanguageLa.php | 2 +- languages/classes/LanguageLn.php | 5 +- languages/classes/LanguageLt.php | 10 +- languages/classes/LanguageLv.php | 10 +- languages/classes/LanguageMg.php | 5 +- languages/classes/LanguageMk.php | 3 +- languages/classes/LanguageMl.php | 15 +- languages/classes/LanguageMo.php | 3 +- languages/classes/LanguageMt.php | 6 +- languages/classes/LanguageMy.php | 5 +- languages/classes/LanguageNso.php | 5 +- languages/classes/LanguagePl.php | 8 +- languages/classes/LanguagePt_br.php | 17 --- languages/classes/LanguageRo.php | 3 +- languages/classes/LanguageRu.php | 68 ++++----- languages/classes/LanguageSe.php | 5 +- languages/classes/LanguageSh.php | 11 +- languages/classes/LanguageSk.php | 2 +- languages/classes/LanguageSl.php | 4 +- languages/classes/LanguageSma.php | 5 +- languages/classes/LanguageSr.deps.php | 4 +- languages/classes/LanguageSr.php | 82 ++++++----- languages/classes/LanguageSr_ec.php | 8 +- languages/classes/LanguageSr_el.deps.php | 2 +- languages/classes/LanguageSr_el.php | 8 +- languages/classes/LanguageTg.php | 4 +- languages/classes/LanguageTi.php | 5 +- languages/classes/LanguageTl.php | 5 +- languages/classes/LanguageTr.php | 2 +- languages/classes/LanguageTyv.php | 244 +++++++++++++++---------------- languages/classes/LanguageUk.php | 75 +++++----- languages/classes/LanguageWa.php | 31 ++-- languages/classes/LanguageYue.php | 6 +- languages/classes/LanguageZh.deps.php | 4 +- languages/classes/LanguageZh.php | 64 ++++---- languages/classes/LanguageZh_hans.php | 12 +- 72 files changed, 970 insertions(+), 740 deletions(-) delete mode 100644 languages/classes/LanguagePt_br.php (limited to 'languages/classes') diff --git a/languages/classes/LanguageAm.php b/languages/classes/LanguageAm.php index cf31c709..77374d3c 100644 --- a/languages/classes/LanguageAm.php +++ b/languages/classes/LanguageAm.php @@ -1,5 +1,6 @@ preConvertPlural( $forms, 2 ); - return ($count <= 1) ? $forms[0] : $forms[1]; + return ( $count <= 1 ) ? $forms[0] : $forms[1]; } } diff --git a/languages/classes/LanguageAr.php b/languages/classes/LanguageAr.php index 70a53f86..77c46025 100644 --- a/languages/classes/LanguageAr.php +++ b/languages/classes/LanguageAr.php @@ -7,18 +7,18 @@ */ class LanguageAr extends Language { function convertPlural( $count, $forms ) { - if ( !count($forms) ) { return ''; } + if ( !count( $forms ) ) { return ''; } $forms = $this->preConvertPlural( $forms, 6 ); if ( $count == 0 ) { $index = 0; } elseif ( $count == 1 ) { $index = 1; - } elseif( $count == 2 ) { + } elseif ( $count == 2 ) { $index = 2; - } elseif( $count % 100 >= 3 && $count % 100 <= 10 ) { + } elseif ( $count % 100 >= 3 && $count % 100 <= 10 ) { $index = 3; - } elseif( $count % 100 >= 11 && $count % 100 <= 99 ) { + } elseif ( $count % 100 >= 11 && $count % 100 <= 99 ) { $index = 4; } else { $index = 5; @@ -27,10 +27,10 @@ class LanguageAr extends Language { } /** - * Temporary hack for bug 9413: replace Arabic presentation forms with their - * standard equivalents. + * Temporary hack for bug 9413: replace Arabic presentation forms with their + * standard equivalents. * - * FIXME: This is language-specific for now only to avoid the negative + * FIXME: This is language-specific for now only to avoid the negative * performance impact of enabling it for all languages. */ function normalize( $s ) { diff --git a/languages/classes/LanguageBat_smg.php b/languages/classes/LanguageBat_smg.php index 8d3450ac..5b6c92a6 100644 --- a/languages/classes/LanguageBat_smg.php +++ b/languages/classes/LanguageBat_smg.php @@ -8,15 +8,15 @@ class LanguageBat_smg extends Language { function convertPlural( $count, $forms ) { - if ( !count($forms) ) { return ''; } + if ( !count( $forms ) ) { return ''; } $forms = $this->preConvertPlural( $forms, 4 ); $count = abs( $count ); - if ( $count === 0 || ($count%100 === 0 || ($count%100 >= 10 && $count%100 < 20)) ) { + if ( $count === 0 || ( $count % 100 === 0 || ( $count % 100 >= 10 && $count % 100 < 20 ) ) ) { return $forms[2]; - } elseif ( $count%10 === 1 ) { + } elseif ( $count % 10 === 1 ) { return $forms[0]; - } elseif ( $count%10 === 2 ) { + } elseif ( $count % 10 === 2 ) { return $forms[1]; } else { return $forms[3]; diff --git a/languages/classes/LanguageBe.php b/languages/classes/LanguageBe.php index b86a5f30..0b147333 100644 --- a/languages/classes/LanguageBe.php +++ b/languages/classes/LanguageBe.php @@ -15,15 +15,15 @@ class LanguageBe extends Language { function convertPlural( $count, $forms ) { - if ( !count($forms) ) { return ''; } + if ( !count( $forms ) ) { return ''; } // FIXME: CLDR defines 4 plural forms instead of 3 // http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/language_plural_rules.html $forms = $this->preConvertPlural( $forms, 3 ); - if ($count > 10 && floor(($count % 100) / 10) == 1) { + if ( $count > 10 && floor( ( $count % 100 ) / 10 ) == 1 ) { return $forms[2]; } else { - switch ($count % 10) { + switch ( $count % 10 ) { case 1: return $forms[0]; case 2: case 3: diff --git a/languages/classes/LanguageBe_tarask.php b/languages/classes/LanguageBe_tarask.php index 96ad9467..b29d8770 100644 --- a/languages/classes/LanguageBe_tarask.php +++ b/languages/classes/LanguageBe_tarask.php @@ -4,7 +4,7 @@ * @ingroup Language * * @author Ævar Arnfjörð Bjarmason - * @link http://be.wikipedia.org/wiki/Talk:LanguageBe.php + * @link http://be-x-old.wikipedia.org/wiki/Project_talk:LanguageBe_tarask.php * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License * @license http://www.gnu.org/copyleft/fdl.html GNU Free Documentation License */ @@ -19,19 +19,19 @@ class LanguageBe_tarask extends Language { */ function convertPlural( $count, $forms ) { - if ( !count($forms) ) { return ''; } + if ( !count( $forms ) ) { return ''; } - //if no number with word, then use $form[0] for singular and $form[1] for plural or zero - if( count($forms) === 2 ) return $count == 1 ? $forms[0] : $forms[1]; + // if no number with word, then use $form[0] for singular and $form[1] for plural or zero + if ( count( $forms ) === 2 ) return $count == 1 ? $forms[0] : $forms[1]; // FIXME: CLDR defines 4 plural forms instead of 3 // http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/language_plural_rules.html $forms = $this->preConvertPlural( $forms, 3 ); - if ($count > 10 && floor(($count % 100) / 10) == 1) { + if ( $count > 10 && floor( ( $count % 100 ) / 10 ) == 1 ) { return $forms[2]; } else { - switch ($count % 10) { + switch ( $count % 10 ) { case 1: return $forms[0]; case 2: case 3: @@ -40,4 +40,37 @@ class LanguageBe_tarask extends Language { } } } + + /* + * The Belarusian language uses apostrophe sign, + * but the characters used for this could be both U+0027 and U+2019. + * This function unifies apostrophe sign in search index values + * to enable seach using both apostrophe signs. + */ + function normalizeForSearch( $string ) { + wfProfileIn( __METHOD__ ); + + # MySQL fulltext index doesn't grok utf-8, so we + # need to fold cases and convert to hex + + # Replacing apostrophe sign U+2019 with U+0027 + $s = preg_replace( '/\xe2\x80\x99/', '\'', $string ); + + $s = parent::normalizeForSearch( $s ); + + wfProfileOut( __METHOD__ ); + return $s; + } + + /* + * Four-digit number should be without group commas (spaces) + * So "1 234 567", "12 345" but "1234" + */ + function commafy( $_ ) { + if ( preg_match( '/^-?\d{1,4}(\.\d*)?$/', $_ ) ) { + return $_; + } else { + return strrev( (string)preg_replace( '/(\d{3})(?=\d)(?!\d*\.)/', '$1,', strrev( $_ ) ) ); + } + } } diff --git a/languages/classes/LanguageBg.php b/languages/classes/LanguageBg.php index bb10675a..d6d34090 100644 --- a/languages/classes/LanguageBg.php +++ b/languages/classes/LanguageBg.php @@ -9,9 +9,9 @@ class LanguageBg extends Language { * ISO number formatting: 123 456 789,99. * Avoid tripple grouping by numbers with whole part up to 4 digits. */ - function commafy($_) { - if (!preg_match('/^\d{1,4}$/',$_)) { - return strrev((string)preg_replace('/(\d{3})(?=\d)(?!\d*\.)/','$1,',strrev($_))); + function commafy( $_ ) { + if ( !preg_match( '/^\d{1,4}$/', $_ ) ) { + return strrev( (string)preg_replace( '/(\d{3})(?=\d)(?!\d*\.)/', '$1,', strrev( $_ ) ) ); } else { return $_; } diff --git a/languages/classes/LanguageBh.php b/languages/classes/LanguageBh.php index 80119ec7..3272e2f3 100644 --- a/languages/classes/LanguageBh.php +++ b/languages/classes/LanguageBh.php @@ -1,5 +1,6 @@ preConvertPlural( $forms, 2 ); - return ($count <= 1) ? $forms[0] : $forms[1]; + return ( $count <= 1 ) ? $forms[0] : $forms[1]; } } diff --git a/languages/classes/LanguageBs.php b/languages/classes/LanguageBs.php index df522f83..6432109d 100644 --- a/languages/classes/LanguageBs.php +++ b/languages/classes/LanguageBs.php @@ -7,15 +7,15 @@ class LanguageBs extends Language { function convertPlural( $count, $forms ) { - if ( !count($forms) ) { return ''; } + if ( !count( $forms ) ) { return ''; } $forms = $this->preConvertPlural( $forms, 3 ); // FIXME: CLDR defines 4 plural forms instead of 3. Plural for decimals is missing. // http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/language_plural_rules.html - if ($count > 10 && floor(($count % 100) / 10) == 1) { + if ( $count > 10 && floor( ( $count % 100 ) / 10 ) == 1 ) { return $forms[2]; } else { - switch ($count % 10) { + switch ( $count % 10 ) { case 1: return $forms[0]; case 2: case 3: @@ -32,7 +32,7 @@ class LanguageBs extends Language { */ function convertGrammar( $word, $case ) { global $wgGrammarForms; - if ( isset($wgGrammarForms['bs'][$case][$word]) ) { + if ( isset( $wgGrammarForms['bs'][$case][$word] ) ) { return $wgGrammarForms['bs'][$case][$word]; } switch ( $case ) { diff --git a/languages/classes/LanguageCs.php b/languages/classes/LanguageCs.php index ca1669b9..935aed4e 100644 --- a/languages/classes/LanguageCs.php +++ b/languages/classes/LanguageCs.php @@ -12,7 +12,7 @@ class LanguageCs extends Language { # {{plural:count|form1|form0,2+}} for single form plurals # in a message function convertPlural( $count, $forms ) { - if ( !count($forms) ) { return ''; } + if ( !count( $forms ) ) { return ''; } $forms = $this->preConvertPlural( $forms, 3 ); switch ( $count ) { diff --git a/languages/classes/LanguageCu.php b/languages/classes/LanguageCu.php index e4ef7b02..1aecbca5 100644 --- a/languages/classes/LanguageCu.php +++ b/languages/classes/LanguageCu.php @@ -9,36 +9,36 @@ class LanguageCu extends Language { # Invoked with {{grammar:case|word}} function convertGrammar( $word, $case ) { global $wgGrammarForms; - if ( isset($wgGrammarForms['сu'][$case][$word]) ) { + if ( isset( $wgGrammarForms['сu'][$case][$word] ) ) { return $wgGrammarForms['сu'][$case][$word]; } # These rules are not perfect, but they are currently only used for site names so it doesn't # matter if they are wrong sometimes. Just add a special case for your site name if necessary. - #join and array_slice instead mb_substr + # join and array_slice instead mb_substr $ar = array(); preg_match_all( '/./us', $word, $ar ); - if (!preg_match("/[a-zA-Z_]/us", $word)) + if ( !preg_match( "/[a-zA-Z_]/us", $word ) ) switch ( $case ) { - case 'genitive': #родительный падеж - if ((join('',array_slice($ar[0],-4))=='вики') || (join('',array_slice($ar[0],-4))=='Вики')) - {} - elseif (join('',array_slice($ar[0],-2))=='ї') - $word = join('',array_slice($ar[0],0,-2)).'їѩ'; + case 'genitive': # родительный падеж + if ( ( join( '', array_slice( $ar[0], -4 ) ) == 'вики' ) || ( join( '', array_slice( $ar[0], -4 ) ) == 'Вики' ) ) + { } + elseif ( join( '', array_slice( $ar[0], -2 ) ) == 'ї' ) + $word = join( '', array_slice( $ar[0], 0, -2 ) ) . 'їѩ'; break; - case 'accusative': #винительный падеж - #stub + case 'accusative': # винительный падеж + # stub break; } return $word; } function convertPlural( $count, $forms ) { - if ( !count($forms) ) { return ''; } + if ( !count( $forms ) ) { return ''; } $forms = $this->preConvertPlural( $forms, 4 ); - switch ($count % 10) { + switch ( $count % 10 ) { case 1: return $forms[0]; case 2: return $forms[1]; case 3: diff --git a/languages/classes/LanguageCy.php b/languages/classes/LanguageCy.php index 9a395393..d7727de2 100644 --- a/languages/classes/LanguageCy.php +++ b/languages/classes/LanguageCy.php @@ -7,7 +7,7 @@ */ class LanguageCy extends Language { function convertPlural( $count, $forms ) { - if ( !count($forms) ) { return ''; } + if ( !count( $forms ) ) { return ''; } // FIXME: CLDR defines 4 plural forms; very different, actually. // See http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/language_plural_rules.html#cy diff --git a/languages/classes/LanguageDsb.php b/languages/classes/LanguageDsb.php index 4ea1b893..1c97c8ad 100644 --- a/languages/classes/LanguageDsb.php +++ b/languages/classes/LanguageDsb.php @@ -27,7 +27,7 @@ class LanguageDsb extends Language { } function convertPlural( $count, $forms ) { - if ( !count($forms) ) { return ''; } + if ( !count( $forms ) ) { return ''; } $forms = $this->preConvertPlural( $forms, 4 ); switch ( abs( $count ) % 100 ) { diff --git a/languages/classes/LanguageEo.php b/languages/classes/LanguageEo.php index 822a43f7..7ec447e7 100644 --- a/languages/classes/LanguageEo.php +++ b/languages/classes/LanguageEo.php @@ -3,63 +3,103 @@ /** Esperanto (Esperanto) * * @ingroup Language + * @author Brion Vibber */ class LanguageEo extends Language { + /** + * Wrapper for charset conversions. + * + * In most languages, this calls through to standard system iconv(), but + * for Esperanto we're also adding a special pseudo-charset to convert + * accented characters to/from the ASCII-friendly "X" surrogate coding: + * + * cx = ĉ cxx = cx + * gx = ĝ gxx = gx + * hx = ĥ hxx = hx + * jx = ĵ jxx = jx + * sx = ŝ sxx = sx + * ux = ŭ uxx = ux + * xx = x + * + * http://en.wikipedia.org/wiki/Esperanto_orthography#X-system + * http://eo.wikipedia.org/wiki/X-sistemo + * + * X-conversion is applied, in either direction, between "utf-8" and "x" charsets; + * this comes into effect when input is run through $wgRequest->getText() and the + * $wgEditEncoding is set to 'x'. + * + * In the long run, this should be moved out of here and into the client-side + * editor behavior; the original server-side translation system dates to 2002-2003 + * when many browsers with really bad Unicode support were still in use. + * + * @param string $in input character set + * @param string $out output character set + * @param string $string text to be converted + * @return string + */ function iconv( $in, $out, $string ) { - # Por multaj lingvoj, ĉi tiu nur voku la sisteman funkcion iconv() - # Ni ankaŭ konvertu X-sistemajn surogotajn - if( strcasecmp( $in, 'x' ) == 0 and strcasecmp( $out, 'utf-8' ) == 0) { - $xu = array ( - 'xx' => 'x' , 'xX' => 'x' , - 'Xx' => 'X' , 'XX' => 'X' , - "Cx" => "\xc4\x88" , "CX" => "\xc4\x88" , - "cx" => "\xc4\x89" , "cX" => "\xc4\x89" , - "Gx" => "\xc4\x9c" , "GX" => "\xc4\x9c" , - "gx" => "\xc4\x9d" , "gX" => "\xc4\x9d" , - "Hx" => "\xc4\xa4" , "HX" => "\xc4\xa4" , - "hx" => "\xc4\xa5" , "hX" => "\xc4\xa5" , - "Jx" => "\xc4\xb4" , "JX" => "\xc4\xb4" , - "jx" => "\xc4\xb5" , "jX" => "\xc4\xb5" , - "Sx" => "\xc5\x9c" , "SX" => "\xc5\x9c" , - "sx" => "\xc5\x9d" , "sX" => "\xc5\x9d" , - "Ux" => "\xc5\xac" , "UX" => "\xc5\xac" , - "ux" => "\xc5\xad" , "uX" => "\xc5\xad" - ) ; - return preg_replace ( '/([cghjsu]x?)((?:xx)*)(?!x)/ei', - 'strtr( "$1", $xu ) . strtr( "$2", $xu )', $string ); - } else if( strcasecmp( $in, 'UTF-8' ) == 0 and strcasecmp( $out, 'x' ) == 0 ) { - $ux = array ( - 'x' => 'xx' , 'X' => 'Xx' , - "\xc4\x88" => "Cx" , "\xc4\x89" => "cx" , - "\xc4\x9c" => "Gx" , "\xc4\x9d" => "gx" , - "\xc4\xa4" => "Hx" , "\xc4\xa5" => "hx" , - "\xc4\xb4" => "Jx" , "\xc4\xb5" => "jx" , - "\xc5\x9c" => "Sx" , "\xc5\x9d" => "sx" , - "\xc5\xac" => "Ux" , "\xc5\xad" => "ux" - ) ; + if ( strcasecmp( $in, 'x' ) == 0 && strcasecmp( $out, 'utf-8' ) == 0 ) { + return preg_replace_callback ( + '/([cghjsu]x?)((?:xx)*)(?!x)/i', + array( $this, 'strrtxuCallback' ), $string ); + } else if ( strcasecmp( $in, 'UTF-8' ) == 0 && strcasecmp( $out, 'x' ) == 0 ) { # Double Xs only if they follow cxapelutaj literoj. - return preg_replace( '/((?:[cghjsu]|\xc4[\x88\x89\x9c\x9d\xa4\xa5\xb4\xb5]'. - '|\xc5[\x9c\x9d\xac\xad])x*)/ei', 'strtr( "$1", $ux )', $string ); + return preg_replace_callback( + '/((?:[cghjsu]|\xc4[\x88\x89\x9c\x9d\xa4\xa5\xb4\xb5]|\xc5[\x9c\x9d\xac\xad])x*)/i', + array( $this, 'strrtuxCallback' ), $string ); } return parent::iconv( $in, $out, $string ); } + function strrtuxCallback( $matches ) { + static $ux = array ( + 'x' => 'xx' , 'X' => 'Xx' , + "\xc4\x88" => "Cx" , "\xc4\x89" => "cx" , + "\xc4\x9c" => "Gx" , "\xc4\x9d" => "gx" , + "\xc4\xa4" => "Hx" , "\xc4\xa5" => "hx" , + "\xc4\xb4" => "Jx" , "\xc4\xb5" => "jx" , + "\xc5\x9c" => "Sx" , "\xc5\x9d" => "sx" , + "\xc5\xac" => "Ux" , "\xc5\xad" => "ux" + ); + return strtr( $matches[1], $ux ); + } + + function strrtxuCallback( $matches ) { + static $xu = array ( + 'xx' => 'x' , 'xX' => 'x' , + 'Xx' => 'X' , 'XX' => 'X' , + "Cx" => "\xc4\x88" , "CX" => "\xc4\x88" , + "cx" => "\xc4\x89" , "cX" => "\xc4\x89" , + "Gx" => "\xc4\x9c" , "GX" => "\xc4\x9c" , + "gx" => "\xc4\x9d" , "gX" => "\xc4\x9d" , + "Hx" => "\xc4\xa4" , "HX" => "\xc4\xa4" , + "hx" => "\xc4\xa5" , "hX" => "\xc4\xa5" , + "Jx" => "\xc4\xb4" , "JX" => "\xc4\xb4" , + "jx" => "\xc4\xb5" , "jX" => "\xc4\xb5" , + "Sx" => "\xc5\x9c" , "SX" => "\xc5\x9c" , + "sx" => "\xc5\x9d" , "sX" => "\xc5\x9d" , + "Ux" => "\xc5\xac" , "UX" => "\xc5\xac" , + "ux" => "\xc5\xad" , "uX" => "\xc5\xad" + ); + return strtr( $matches[1], $xu ) . strtr( $matches[2], $xu ); + } + function checkTitleEncoding( $s ) { # Check for X-system backwards-compatibility URLs - $ishigh = preg_match( '/[\x80-\xff]/', $s); + $ishigh = preg_match( '/[\x80-\xff]/', $s ); $isutf = preg_match( '/^([\x00-\x7f]|[\xc0-\xdf][\x80-\xbf]|' . '[\xe0-\xef][\x80-\xbf]{2}|[\xf0-\xf7][\x80-\xbf]{3})+$/', $s ); - if($ishigh and !$isutf) { + if ( $ishigh and !$isutf ) { # Assume Latin1 $s = utf8_encode( $s ); } else { - if( preg_match( '/(\xc4[\x88\x89\x9c\x9d\xa4\xa5\xb4\xb5]'. + if ( preg_match( '/(\xc4[\x88\x89\x9c\x9d\xa4\xa5\xb4\xb5]' . '|\xc5[\x9c\x9d\xac\xad])/', $s ) ) return $s; } - //if( preg_match( '/[cghjsu]x/i', $s ) ) + // if( preg_match( '/[cghjsu]x/i', $s ) ) // return $this->iconv( 'x', 'utf-8', $s ); return $s; } diff --git a/languages/classes/LanguageEt.php b/languages/classes/LanguageEt.php index c6729d99..226c2d73 100644 --- a/languages/classes/LanguageEt.php +++ b/languages/classes/LanguageEt.php @@ -9,9 +9,9 @@ class LanguageEt extends Language { /** * 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($_))); + function commafy( $_ ) { + if ( !preg_match( '/^\d{1,4}$/', $_ ) ) { + return strrev( (string)preg_replace( '/(\d{3})(?=\d)(?!\d*\.)/', '$1,', strrev( $_ ) ) ); } else { return $_; } diff --git a/languages/classes/LanguageFi.php b/languages/classes/LanguageFi.php index d1348f03..e3d922c4 100644 --- a/languages/classes/LanguageFi.php +++ b/languages/classes/LanguageFi.php @@ -12,7 +12,7 @@ class LanguageFi extends Language { # Invoked with {{GRAMMAR:case|word}} function convertGrammar( $word, $case ) { global $wgGrammarForms; - if ( isset($wgGrammarForms['fi'][$case][$word]) ) { + if ( isset( $wgGrammarForms['fi'][$case][$word] ) ) { return $wgGrammarForms['fi'][$case][$word]; } @@ -38,18 +38,18 @@ class LanguageFi extends Language { $word .= 'n'; break; case 'elative': - $word .= ($aou ? 'sta' : 'stä'); + $word .= ( $aou ? 'sta' : 'stä' ); break; case 'partitive': - $word .= ($aou ? 'a' : 'ä'); + $word .= ( $aou ? 'a' : 'ä' ); break; case 'illative': # Double the last letter and add 'n' # mb_substr has a compatibility function in GlobalFunctions.php - $word = $word . mb_substr($word, -1) . 'n'; + $word = $word . mb_substr( $word, -1 ) . 'n'; break; case 'inessive': - $word .= ($aou ? 'ssa' : 'ssä'); + $word .= ( $aou ? 'ssa' : 'ssä' ); break; } return $word; @@ -113,15 +113,15 @@ class LanguageFi extends Language { ); $final = ''; - $tokens = explode ( ' ', $str); - foreach( $tokens as $item ) { - if ( !is_numeric($item) ) { - if ( count ( explode( '-', $item ) ) == 3 && strlen($item) == 10 ) { + $tokens = explode ( ' ', $str ); + foreach ( $tokens as $item ) { + if ( !is_numeric( $item ) ) { + if ( count ( explode( '-', $item ) ) == 3 && strlen( $item ) == 10 ) { list( $yyyy, $mm, $dd ) = explode( '-', $item ); - $final .= ' ' . $this->date( "{$yyyy}{$mm}{$dd}00000000"); + $final .= ' ' . $this->date( "{$yyyy}{$mm}{$dd}000000" ); continue; } - if( isset( $weekds[$item] ) ) { + if ( isset( $weekds[$item] ) ) { $final .= ' ' . $weekds[$item]; continue; } diff --git a/languages/classes/LanguageFr.php b/languages/classes/LanguageFr.php index 7341bb86..dec1204c 100644 --- a/languages/classes/LanguageFr.php +++ b/languages/classes/LanguageFr.php @@ -9,9 +9,9 @@ class LanguageFr extends Language { * Use singular form for zero (see bug 7309) */ function convertPlural( $count, $forms ) { - if ( !count($forms) ) { return ''; } + if ( !count( $forms ) ) { return ''; } $forms = $this->preConvertPlural( $forms, 2 ); - return ($count <= 1) ? $forms[0] : $forms[1]; + return ( $count <= 1 ) ? $forms[0] : $forms[1]; } } diff --git a/languages/classes/LanguageGa.php b/languages/classes/LanguageGa.php index 344fdc84..a55e5f30 100644 --- a/languages/classes/LanguageGa.php +++ b/languages/classes/LanguageGa.php @@ -9,13 +9,13 @@ class LanguageGa extends Language { # Invoked with {{GRAMMAR:transformation|word}} function convertGrammar( $word, $case ) { global $wgGrammarForms; - if ( isset($wgGrammarForms['ga'][$case][$word]) ) { + if ( isset( $wgGrammarForms['ga'][$case][$word] ) ) { return $wgGrammarForms['ga'][$case][$word]; } switch ( $case ) { case 'ainmlae': - switch ($word) { + switch ( $word ) { case 'an Domhnach': $word = 'Dé Domhnaigh'; break; case 'an Luan': @@ -36,14 +36,14 @@ class LanguageGa extends Language { } function convertPlural( $count, $forms ) { - if ( !count($forms) ) { return ''; } + if ( !count( $forms ) ) { return ''; } // plural forms per http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/language_plural_rules.html#ga $forms = $this->preConvertPlural( $forms, 3 ); if ( $count == 1 ) { $index = 0; - } elseif( $count == 2 ) { + } elseif ( $count == 2 ) { $index = 1; } else { $index = 2; diff --git a/languages/classes/LanguageGan.php b/languages/classes/LanguageGan.php index 54202e48..da5e1d22 100644 --- a/languages/classes/LanguageGan.php +++ b/languages/classes/LanguageGan.php @@ -1,35 +1,35 @@ mDescCodeSep = ':'; $this->mDescVarSep = ';'; - parent::__construct($langobj, $maincode, + parent::__construct( $langobj, $maincode, $variants, $variantfallbacks, $flags, - $manualLevel); + $manualLevel ); $names = array( 'gan' => '原文', 'gan-hans' => '简体', 'gan-hant' => '繁體', ); - $this->mVariantNames = array_merge($this->mVariantNames,$names); + $this->mVariantNames = array_merge( $this->mVariantNames, $names ); } function loadDefaultTables() { - require( dirname(__FILE__)."/../../includes/ZhConversion.php" ); + require( dirname( __FILE__ ) . "/../../includes/ZhConversion.php" ); $this->mTables = array( 'gan-hans' => new ReplacementArray( $zh2Hans ), 'gan-hant' => new ReplacementArray( $zh2Hant ), @@ -41,7 +41,7 @@ class GanConverter extends LanguageConverter { to mark anything. $noParse is there for compatibility with LanguageConvert::markNoConversion */ - function markNoConversion($text, $noParse = false) { + function markNoConversion( $text, $noParse = false ) { return $text; } @@ -62,20 +62,20 @@ class LanguageGan extends LanguageZh { global $wgHooks; parent::__construct(); - $variants = array('gan','gan-hans','gan-hant'); + $variants = array( 'gan', 'gan-hans', 'gan-hant' ); $variantfallbacks = array( - 'gan' => array('gan-hans','gan-hant'), - 'gan-hans' => array('gan'), - 'gan-hant' => array('gan'), + 'gan' => array( 'gan-hans', 'gan-hant' ), + 'gan-hans' => array( 'gan' ), + 'gan-hant' => array( 'gan' ), ); - $ml=array( + $ml = array( 'gan' => 'disable', ); $this->mConverter = new GanConverter( $this, 'gan', $variants, $variantfallbacks, array(), - $ml); + $ml ); $wgHooks['ArticleSaveComplete'][] = $this->mConverter; } @@ -84,13 +84,13 @@ class LanguageGan extends LanguageZh { function segmentForDiff( $text ) { return preg_replace( "/([\\xc0-\\xff][\\x80-\\xbf]*)/e", - "' ' .\"$1\"", $text); + "' ' .\"$1\"", $text ); } function unsegmentForDiff( $text ) { return preg_replace( "/ ([\\xc0-\\xff][\\x80-\\xbf]*)/e", - "\"$1\"", $text); + "\"$1\"", $text ); } // word segmentation @@ -103,7 +103,7 @@ class LanguageGan extends LanguageZh { $terms = implode( '|', $termsArray ); $terms = self::convertDoubleWidth( $terms ); $terms = implode( '|', $this->mConverter->autoConvertToAllVariants( $terms ) ); - $ret = array_unique( explode('|', $terms) ); + $ret = array_unique( explode( '|', $terms ) ); return $ret; } } diff --git a/languages/classes/LanguageGd.php b/languages/classes/LanguageGd.php index 6c307f60..1b1b278e 100644 --- a/languages/classes/LanguageGd.php +++ b/languages/classes/LanguageGd.php @@ -18,7 +18,7 @@ class LanguageGd extends Language { * */ function convertPlural( $count, $forms ) { - if ( !count($forms) ) { return ''; } + if ( !count( $forms ) ) { return ''; } $forms = $this->preConvertPlural( $forms, 4 ); $count = abs( $count ); diff --git a/languages/classes/LanguageGv.php b/languages/classes/LanguageGv.php index 5683826d..6e25e21c 100644 --- a/languages/classes/LanguageGv.php +++ b/languages/classes/LanguageGv.php @@ -9,14 +9,14 @@ class LanguageGv extends Language { function convertPlural( $count, $forms ) { - if ( !count($forms) ) { return ''; } + if ( !count( $forms ) ) { return ''; } $forms = $this->preConvertPlural( $forms, 4 ); - if ($count > 0 && ($count % 20) === 0 ) { + if ( $count > 0 && ( $count % 20 ) === 0 ) { return $forms[0]; } else { - switch ($count % 10) { + switch ( $count % 10 ) { case 1: return $forms[1]; case 2: return $forms[2]; default: return $forms[3]; diff --git a/languages/classes/LanguageHe.php b/languages/classes/LanguageHe.php index d8256cb8..95beca79 100644 --- a/languages/classes/LanguageHe.php +++ b/languages/classes/LanguageHe.php @@ -8,62 +8,58 @@ * @author Rotem Liss */ class LanguageHe extends Language { + /** * Convert grammar forms of words. * * Available cases: * "prefixed" (or "תחילית") - when the word has a prefix * - * @param string the word to convert - * @param string the case + * @param $word String: the word to convert + * @param $case String: the case */ public function convertGrammar( $word, $case ) { global $wgGrammarForms; - if ( isset($wgGrammarForms['he'][$case][$word]) ) { + if ( isset( $wgGrammarForms['he'][$case][$word] ) ) { return $wgGrammarForms['he'][$case][$word]; } - + switch ( $case ) { case 'prefixed': case 'תחילית': # Duplicate the "Waw" if prefixed if ( substr( $word, 0, 2 ) == "ו" && substr( $word, 0, 4 ) != "וו" ) { - $word = "ו".$word; + $word = "ו" . $word; } - + # Remove the "He" if prefixed if ( substr( $word, 0, 2 ) == "ה" ) { $word = substr( $word, 2 ); } - + # Add a hyphen if non-Hebrew letters if ( substr( $word, 0, 2 ) < "א" || substr( $word, 0, 2 ) > "ת" ) { - $word = "־".$word; + $word = "־" . $word; } } - + return $word; } - + /** * Gets a number and uses the suited form of the word. * - * @param integer the number of items - * @param string the first form (singular) - * @param string the second form (plural) - * @param string the third form (2 items, plural is used if not applicable and not specified - * @param not used (for compatibility with ancestor) - * @param not used (for compatibility with ancestor) - * - * @return string of the suited form of word + * @param $count Integer: the number of items + * @param $forms Array with 3 items: the three plural forms + * @return String: the suited form of word */ function convertPlural( $count, $forms ) { - if ( !count($forms) ) { return ''; } + if ( !count( $forms ) ) { return ''; } $forms = $this->preConvertPlural( $forms, 3 ); if ( $count == '1' ) { return $forms[0]; - } elseif ( $count == '2' && isset($forms[2]) ) { + } elseif ( $count == '2' && isset( $forms[2] ) ) { return $forms[2]; } else { return $forms[1]; diff --git a/languages/classes/LanguageHi.php b/languages/classes/LanguageHi.php index 705c73bc..fc9d0de8 100644 --- a/languages/classes/LanguageHi.php +++ b/languages/classes/LanguageHi.php @@ -1,5 +1,6 @@ preConvertPlural( $forms, 2 ); - return ($count <= 1) ? $forms[0] : $forms[1]; + return ( $count <= 1 ) ? $forms[0] : $forms[1]; } } diff --git a/languages/classes/LanguageHr.php b/languages/classes/LanguageHr.php index d8e84876..888029be 100644 --- a/languages/classes/LanguageHr.php +++ b/languages/classes/LanguageHr.php @@ -7,15 +7,15 @@ class LanguageHr extends Language { function convertPlural( $count, $forms ) { - if ( !count($forms) ) { return ''; } + if ( !count( $forms ) ) { return ''; } // FIXME: CLDR defines 4 plural forms instead of 3. Plural for for decimals is missing. // http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/language_plural_rules.html $forms = $this->preConvertPlural( $forms, 3 ); - if ($count > 10 && floor(($count % 100) / 10) == 1) { + if ( $count > 10 && floor( ( $count % 100 ) / 10 ) == 1 ) { return $forms[2]; } else { - switch ($count % 10) { + switch ( $count % 10 ) { case 1: return $forms[0]; case 2: case 3: diff --git a/languages/classes/LanguageHsb.php b/languages/classes/LanguageHsb.php index f1418782..1b83f5ab 100644 --- a/languages/classes/LanguageHsb.php +++ b/languages/classes/LanguageHsb.php @@ -28,7 +28,7 @@ class LanguageHsb extends Language { } function convertPlural( $count, $forms ) { - if ( !count($forms) ) { return ''; } + if ( !count( $forms ) ) { return ''; } $forms = $this->preConvertPlural( $forms, 4 ); switch ( abs( $count ) % 100 ) { diff --git a/languages/classes/LanguageHu.php b/languages/classes/LanguageHu.php index 7845bdbb..44ce330c 100644 --- a/languages/classes/LanguageHu.php +++ b/languages/classes/LanguageHu.php @@ -7,7 +7,7 @@ class LanguageHu extends Language { function convertGrammar( $word, $case ) { global $wgGrammarForms; - if ( isset($wgGrammarForms[$this->getCode()][$case][$word]) ) { + if ( isset( $wgGrammarForms[$this->getCode()][$case][$word] ) ) { return $wgGrammarForms[$this->getCode()][$case][$word]; } diff --git a/languages/classes/LanguageHy.php b/languages/classes/LanguageHy.php index 73777def..527a55f5 100644 --- a/languages/classes/LanguageHy.php +++ b/languages/classes/LanguageHy.php @@ -10,58 +10,58 @@ class LanguageHy extends Language { # Invoked with {{grammar:case|word}} function convertGrammar( $word, $case ) { global $wgGrammarForms; - if ( isset($wgGrammarForms['hy'][$case][$word]) ) { + if ( isset( $wgGrammarForms['hy'][$case][$word] ) ) { return $wgGrammarForms['hy'][$case][$word]; } # These rules are not perfect, but they are currently only used for site names so it doesn't # matter if they are wrong sometimes. Just add a special case for your site name if necessary. - #join and array_slice instead mb_substr + # join and array_slice instead mb_substr $ar = array(); preg_match_all( '/./us', $word, $ar ); - if (!preg_match("/[a-zA-Z_]/us", $word)) + if ( !preg_match( "/[a-zA-Z_]/us", $word ) ) switch ( $case ) { - case 'genitive': #սեռական հոլով - if (join('',array_slice($ar[0],-1))=='ա') - $word = join('',array_slice($ar[0],0,-1)).'այի'; - elseif (join('',array_slice($ar[0],-1))=='ո') - $word=join('',array_slice($ar[0],0,-1)).'ոյի'; - elseif (join('',array_slice($ar[0],-4))=='գիրք') - $word=join('',array_slice($ar[0],0,-4)).'գրքի'; + case 'genitive': # սեռական հոլով + if ( join( '', array_slice( $ar[0], -1 ) ) == 'ա' ) + $word = join( '', array_slice( $ar[0], 0, -1 ) ) . 'այի'; + elseif ( join( '', array_slice( $ar[0], -1 ) ) == 'ո' ) + $word = join( '', array_slice( $ar[0], 0, -1 ) ) . 'ոյի'; + elseif ( join( '', array_slice( $ar[0], -4 ) ) == 'գիրք' ) + $word = join( '', array_slice( $ar[0], 0, -4 ) ) . 'գրքի'; else - $word.='ի'; + $word .= 'ի'; break; - case 'dative': #Տրական հոլով - #stub + case 'dative': # Տրական հոլով + # stub break; - case 'accusative': #Հայցական հոլով - #stub + case 'accusative': # Հայցական հոլով + # stub break; case 'instrumental': # - #stub + # stub break; case 'prepositional': # - #stub + # stub break; } return $word; } function convertPlural( $count, $forms ) { - if ( !count($forms) ) { return ''; } + if ( !count( $forms ) ) { return ''; } $forms = $this->preConvertPlural( $forms, 2 ); - return (abs($count) <= 1) ? $forms[0] : $forms[1]; + return ( abs( $count ) <= 1 ) ? $forms[0] : $forms[1]; } /* * Armenian numeric format is "12 345,67" but "1234,56" */ - function commafy($_) { - if (!preg_match('/^\d{1,4}$/',$_)) { - return strrev((string)preg_replace('/(\d{3})(?=\d)(?!\d*\.)/','$1,',strrev($_))); + function commafy( $_ ) { + if ( !preg_match( '/^\d{1,4}$/', $_ ) ) { + return strrev( (string)preg_replace( '/(\d{3})(?=\d)(?!\d*\.)/', '$1,', strrev( $_ ) ) ); } else { return $_; } diff --git a/languages/classes/LanguageJa.php b/languages/classes/LanguageJa.php index 4a24260b..c5a992d5 100644 --- a/languages/classes/LanguageJa.php +++ b/languages/classes/LanguageJa.php @@ -6,7 +6,7 @@ * @ingroup Language */ class LanguageJa extends Language { - function wordSegmentation( $string ) { + function segmentByWord( $string ) { // Strip known punctuation ? // $s = preg_replace( '/\xe3\x80[\x80-\xbf]/', '', $s ); # U3000-303f @@ -23,14 +23,6 @@ class LanguageJa extends Language { return $s; } - function normalizeForSearch( $string ) { - // Double-width roman characters - $s = self::convertDoubleWidth( $string ); - - # Do general case folding and UTF-8 armoring - return parent::normalizeForSearch( $s ); - } - # Italic is not appropriate for Japanese script # Unfortunately most browsers do not recognise this, and render as italic function emphasize( $text ) { diff --git a/languages/classes/LanguageKaa.php b/languages/classes/LanguageKaa.php index f9f61dbd..4c6710ed 100644 --- a/languages/classes/LanguageKaa.php +++ b/languages/classes/LanguageKaa.php @@ -51,7 +51,7 @@ class LanguageKaa extends Language { */ function commafy( $_ ) { if ( !preg_match( '/^\d{1,4}$/', $_ ) ) { - return strrev( (string)preg_replace( '/(\d{3})(?=\d)(?!\d*\.)/', '$1,', strrev($_) ) ); + return strrev( (string)preg_replace( '/(\d{3})(?=\d)(?!\d*\.)/', '$1,', strrev( $_ ) ) ); } else { return $_; } diff --git a/languages/classes/LanguageKk.deps.php b/languages/classes/LanguageKk.deps.php index aa7361bb..0a2a8afb 100644 --- a/languages/classes/LanguageKk.deps.php +++ b/languages/classes/LanguageKk.deps.php @@ -5,5 +5,5 @@ // changed on a subsequent page view. // see http://lists.wikimedia.org/pipermail/wikitech-l/2006-January/021311.html -require_once( dirname(__FILE__).'/../LanguageConverter.php' ); -require_once( dirname(__FILE__).'/LanguageKk_cyrl.php' ); +require_once( dirname( __FILE__ ) . '/../LanguageConverter.php' ); +require_once( dirname( __FILE__ ) . '/LanguageKk_cyrl.php' ); diff --git a/languages/classes/LanguageKk.php b/languages/classes/LanguageKk.php index 318b82a8..e3caacc8 100644 --- a/languages/classes/LanguageKk.php +++ b/languages/classes/LanguageKk.php @@ -1,15 +1,15 @@ new ReplacementArray( $kk2Cyrl ), 'kk-latn' => new ReplacementArray( $kk2Latn ), 'kk-arab' => new ReplacementArray( $kk2Arab ), - 'kk-kz' => new ReplacementArray( array_merge($kk2Cyrl, $kk2KZ) ), - 'kk-tr' => new ReplacementArray( array_merge($kk2Latn, $kk2TR) ), - 'kk-cn' => new ReplacementArray( array_merge($kk2Arab, $kk2CN) ), + 'kk-kz' => new ReplacementArray( array_merge( $kk2Cyrl, $kk2KZ ) ), + 'kk-tr' => new ReplacementArray( array_merge( $kk2Latn, $kk2TR ) ), + 'kk-cn' => new ReplacementArray( array_merge( $kk2Arab, $kk2CN ) ), 'kk' => new ReplacementArray() ); } @@ -62,24 +62,24 @@ class KkConverter extends LanguageConverter { function loadRegs() { $this->mCyrl2Latn = array( - ## Punctuation + # # Punctuation '/№/u' => 'No.', - ## Е after vowels + # # Е after vowels '/([АӘЕЁИОӨҰҮЭЮЯЪЬ])Е/u' => '$1YE', '/([АӘЕЁИОӨҰҮЭЮЯЪЬ])е/ui' => '$1ye', - ## leading ЁЮЯЩ - '/^Ё(['.KK_C_UC.']|$)/u' => 'YO$1', '/^Ё(['.KK_C_LC.']|$)/u' => 'Yo$1', - '/^Ю(['.KK_C_UC.']|$)/u' => 'YU$1', '/^Ю(['.KK_C_LC.']|$)/u' => 'Yu$1', - '/^Я(['.KK_C_UC.']|$)/u' => 'YA$1', '/^Я(['.KK_C_LC.']|$)/u' => 'Ya$1', - '/^Щ(['.KK_C_UC.']|$)/u' => 'ŞÇ$1', '/^Щ(['.KK_C_LC.']|$)/u' => 'Şç$1', - ## other ЁЮЯ + # # leading ЁЮЯЩ + '/^Ё([' . KK_C_UC . ']|$)/u' => 'YO$1', '/^Ё([' . KK_C_LC . ']|$)/u' => 'Yo$1', + '/^Ю([' . KK_C_UC . ']|$)/u' => 'YU$1', '/^Ю([' . KK_C_LC . ']|$)/u' => 'Yu$1', + '/^Я([' . KK_C_UC . ']|$)/u' => 'YA$1', '/^Я([' . KK_C_LC . ']|$)/u' => 'Ya$1', + '/^Щ([' . KK_C_UC . ']|$)/u' => 'ŞÇ$1', '/^Щ([' . KK_C_LC . ']|$)/u' => 'Şç$1', + # # other ЁЮЯ '/Ё/u' => 'YO', '/ё/u' => 'yo', '/Ю/u' => 'YU', '/ю/u' => 'yu', '/Я/u' => 'YA', '/я/u' => 'ya', '/Щ/u' => 'ŞÇ', '/щ/u' => 'şç', - ## soft and hard signs + # # soft and hard signs '/[ъЪ]/u' => 'ʺ', '/[ьЬ]/u' => 'ʹ', - ## other characters + # # other characters '/А/u' => 'A', '/а/u' => 'a', '/Ә/u' => 'Ä', '/ә/u' => 'ä', '/Б/u' => 'B', '/б/u' => 'b', '/В/u' => 'V', '/в/u' => 'v', '/Г/u' => 'G', '/г/u' => 'g', '/Ғ/u' => 'Ğ', '/ғ/u' => 'ğ', @@ -101,24 +101,24 @@ class KkConverter extends LanguageConverter { ); $this->mLatn2Cyrl = array( - ## Punctuation + # # Punctuation '/#|No\./' => '№', - ## Şç - '/ŞÇʹ/u'=> 'ЩЬ', '/Şçʹ/u'=> 'Щь', '/Şçʹ/u'=> 'Щь', + # # Şç + '/ŞÇʹ/u' => 'ЩЬ', '/Şçʹ/u' => 'Щь', '/Şçʹ/u' => 'Щь', '/Ş[Çç]/u' => 'Щ', '/şç/u' => 'щ', - ## soft and hard signs - '/(['.KK_L_UC.'])ʺ(['.KK_L_UC.'])/u' => '$1Ъ$2', - '/ʺ(['.KK_L_LC.'])/u' => 'ъ$1', - '/(['.KK_L_UC.'])ʹ(['.KK_L_UC.'])/u' => '$1Ь$2', - '/ʹ(['.KK_L_LC.'])/u' => 'ь$1', + # # soft and hard signs + '/([' . KK_L_UC . '])ʺ([' . KK_L_UC . '])/u' => '$1Ъ$2', + '/ʺ([' . KK_L_LC . '])/u' => 'ъ$1', + '/([' . KK_L_UC . '])ʹ([' . KK_L_UC . '])/u' => '$1Ь$2', + '/ʹ([' . KK_L_LC . '])/u' => 'ь$1', '/ʺ/u' => 'ъ', '/ʹ/u' => 'ь', - ## Ye Yo Yu Ya. + # # 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 + # # other characters '/A/u' => 'А', '/a/u' => 'а', '/Ä/u' => 'Ә', '/ä/u' => 'ә', '/B/u' => 'Б', '/b/u' => 'б', '/C/u' => 'Ц', '/c/u' => 'ц', '/Ç/u' => 'Ч', '/ç/u' => 'ч', '/D/u' => 'Д', '/d/u' => 'д', @@ -140,14 +140,14 @@ class KkConverter extends LanguageConverter { ); $this->mCyLa2Arab = array( - ## Punctuation -> Arabic + # # Punctuation -> Arabic '/#|№|No\./u' => '؀', # ؀ '/\,/' => '،', # ، '/;/' => '؛', # ؛ '/\?/' => '؟', # ؟ '/%/' => '٪', # ٪ '/\*/' => '٭', # ٭ - ## Digits -> Arabic + # # Digits -> Arabic '/0/' => '۰', # ۰ '/1/' => '۱', # ۱ '/2/' => '۲', # ۲ @@ -158,7 +158,7 @@ class KkConverter extends LanguageConverter { '/7/' => '۷', # ۷ '/8/' => '۸', # ۸ '/9/' => '۹', # ۹ - ## Cyrillic -> Arabic + # # Cyrillic -> Arabic '/Аллаһ/ui' => 'ﷲ', '/([АӘЕЁИОӨҰҮЭЮЯЪЬ])е/ui' => '$1يە', '/[еэ]/ui' => 'ە', '/[ъь]/ui' => '', @@ -166,14 +166,14 @@ class KkConverter extends LanguageConverter { '/[и]/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... + # # Latin -> Arabic // commented for now... /*'/Allah/ui' => 'ﷲ', '/[eé]/ui' => 'ە', '/[yý]/ui' => 'ي', '/[ʺʹ]/ui' => '', '/[aä]/ui' => 'ا', '/[oö]/ui' => 'و', '/[uü]/ui' => 'ۇ', @@ -195,13 +195,13 @@ class KkConverter extends LanguageConverter { 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); + function parseManualRule( $rule, $flags = array() ) { + if ( in_array( 'T', $flags ) ) { + return parent::parseManualRule( $rule, $flags ); } // otherwise ignore all formatting - foreach($this->mVariants as $v) { + foreach ( $this->mVariants as $v ) { $carray[$v] = $rule; } @@ -216,116 +216,115 @@ class KkConverter extends LanguageConverter { */ function findVariantLink( &$link, &$nt, $ignoreOtherCond = false ) { // check for user namespace - if(is_object($nt)){ + 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; + $oldlink = $link; parent::findVariantLink( $link, $nt, $ignoreOtherCond ); - if( $this->getPreferredVariant()==$this->mMainLanguageCode ) - $link=$oldlink; + 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) { + function autoConvert( $text, $toVariant = false ) { global $wgTitle; - if(is_object($wgTitle) && $wgTitle->getNameSpace()==NS_FILE){ + if ( is_object( $wgTitle ) && $wgTitle->getNameSpace() == NS_FILE ) { $imagename = $wgTitle->getNsText(); - if(preg_match("/^$imagename:/",$text)) return $text; + if ( preg_match( "/^$imagename:/", $text ) ) return $text; } - return parent::autoConvert($text,$toVariant); + return parent::autoConvert( $text, $toVariant ); } /** * It translates text into variant */ - function translate( $text, $toVariant ){ - global $wgContLanguageCode; + function translate( $text, $toVariant ) { + global $wgLanguageCode; $text = parent::translate( $text, $toVariant ); - $letters = ''; switch( $toVariant ) { case 'kk-cyrl': case 'kk-kz': $letters = KK_L_UC . KK_L_LC . 'ʺʹ#0123456789'; - $wgContLanguageCode = 'kk'; + $wgLanguageCode = 'kk'; break; case 'kk-latn': case 'kk-tr': $letters = KK_C_UC . KK_C_LC . '№0123456789'; - $wgContLanguageCode = 'kk-Latn'; + $wgLanguageCode = 'kk-Latn'; break; case 'kk-arab': case 'kk-cn': - $letters = KK_C_UC.KK_C_LC./*KK_L_UC.KK_L_LC.'ʺʹ'.*/',;\?%\*№0123456789'; - $wgContLanguageCode = 'kk-Arab'; + $letters = KK_C_UC . KK_C_LC . /*KK_L_UC.KK_L_LC.'ʺʹ'.*/',;\?%\*№0123456789'; + $wgLanguageCode = 'kk-Arab'; break; default: - $wgContLanguageCode = 'kk'; + $wgLanguageCode = 'kk'; return $text; } // disable conversion variables like $1, $2... $varsfix = '\$[0-9]'; - $matches = preg_split( '/' . $varsfix . '[^' . $letters . ']+/u', $text, -1, PREG_SPLIT_OFFSET_CAPTURE); + $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 ); + foreach ( $matches as $m ) { + $ret .= substr( $text, $mstart, $m[1] -$mstart ); $ret .= $this->regsConverter( $m[0], $toVariant ); - $mstart = $m[1] + strlen($m[0]); + $mstart = $m[1] + strlen( $m[0] ); } return $ret; } function regsConverter( $text, $toVariant ) { - if ($text == '') return $text; + if ( $text == '' ) { + return $text; + } - $pat = array(); - $rep = array(); switch( $toVariant ) { case 'kk-arab': case 'kk-cn': - $letters = KK_C_LC.KK_C_UC/*.KK_L_LC.KK_L_UC*/; + $letters = KK_C_LC . KK_C_UC/*.KK_L_LC.KK_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); + $matches = preg_split( '/[\b\s\-\.:]+/', $text, -1, PREG_SPLIT_OFFSET_CAPTURE ); $mstart = 0; $ret = ''; - foreach( $matches as $m ) { + 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]); + 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]); + $mstart = $m[1] + strlen( $m[0] ); } $text =& $ret; - foreach( $this->mCyLa2Arab as $pat => $rep ) { + foreach ( $this->mCyLa2Arab as $pat => $rep ) { $text = preg_replace( $pat, $rep, $text ); } return $text; break; case 'kk-latn': case 'kk-tr': - foreach( $this->mCyrl2Latn as $pat => $rep ) { + foreach ( $this->mCyrl2Latn as $pat => $rep ) { $text = preg_replace( $pat, $rep, $text ); } return $text; break; case 'kk-cyrl': case 'kk-kz': - foreach( $this->mLatn2Cyrl as $pat => $rep ) { + foreach ( $this->mLatn2Cyrl as $pat => $rep ) { $text = preg_replace( $pat, $rep, $text ); } return $text; @@ -339,8 +338,8 @@ class KkConverter extends LanguageConverter { * 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 ) ) + function markNoConversion( $text, $noParse = false ) { + if ( $noParse || preg_match( "/^https?:\/\/|ftp:\/\/|irc:\/\//", $text ) ) return parent::markNoConversion( $text ); return $text; } @@ -399,7 +398,7 @@ class LanguageKk extends LanguageKk_cyrl { */ function ucfirst ( $string ) { $variant = $this->getPreferredVariant(); - if ( ($variant == 'kk-latn' || $variant == 'kk-tr') && $string[0] == 'i' ) { + if ( ( $variant == 'kk-latn' || $variant == 'kk-tr' ) && $string[0] == 'i' ) { $string = 'İ' . substr( $string, 1 ); } else { $string = parent::ucfirst( $string ); @@ -413,7 +412,7 @@ class LanguageKk extends LanguageKk_cyrl { */ function lcfirst ( $string ) { $variant = $this->getPreferredVariant(); - if ( ($variant == 'kk-latn' || $variant == 'kk-tr') && $string[0] == 'I' ) { + if ( ( $variant == 'kk-latn' || $variant == 'kk-tr' ) && $string[0] == 'I' ) { $string = 'ı' . substr( $string, 1 ); } else { $string = parent::lcfirst( $string ); diff --git a/languages/classes/LanguageKk_cyrl.php b/languages/classes/LanguageKk_cyrl.php index e0a1b125..78febae1 100644 --- a/languages/classes/LanguageKk_cyrl.php +++ b/languages/classes/LanguageKk_cyrl.php @@ -27,24 +27,24 @@ class LanguageKk_cyrl extends Language { $allVowels = array( "е", "ө", "ү", "і", "ә", "э", "а", "о", "ұ", "ы", "я", "ё", "и" ); // Preceding letters $Nasals = array( "м", "н", "ң" ); - $Sonants = array( "и", "й", "л", "р", "у", "ю"); + $Sonants = array( "и", "й", "л", "р", "у", "ю" ); $Consonants = array( "п", "ф", "к", "қ", "т", "ш", "с", "х", "ц", "ч", "щ", "б", "в", "г", "д" ); $Sibilants = array( "ж", "з" ); - $Sonorants = array( "и", "й", "л", "р", "у", "ю", "м", "н", "ң", "ж", "з"); + $Sonorants = array( "и", "й", "л", "р", "у", "ю", "м", "н", "ң", "ж", "з" ); // Possessives $firstPerson = array( "м", "ң" ); // 1st singular, 2nd unformal $secondPerson = array( "з" ); // 1st plural, 2nd formal $thirdPerson = array( "ы", "і" ); // 3rd - $lastLetter = self::lastLetter( $word, $allVowels ); + $lastLetter = $this->lastLetter( $word, $allVowels ); $wordEnding =& $lastLetter[0]; $wordLastVowel =& $lastLetter[1]; // Now convert the word switch ( $case ) { case "dc1": - case "genitive": #ilik + case "genitive": # ilik if ( in_array( $wordEnding, $Consonants ) ) { if ( in_array( $wordLastVowel, $frontVowels ) ) { $word = $word . "тің"; @@ -57,7 +57,7 @@ class LanguageKk_cyrl extends Language { } elseif ( in_array( $wordLastVowel, $backVowels ) ) { $word = $word . "ның"; } - } elseif ( in_array( $wordEnding, $Sonants ) || in_array( $wordEnding, $Sibilants )) { + } elseif ( in_array( $wordEnding, $Sonants ) || in_array( $wordEnding, $Sibilants ) ) { if ( in_array( $wordLastVowel, $frontVowels ) ) { $word = $word . "дің"; } elseif ( in_array( $wordLastVowel, $backVowels ) ) { @@ -66,7 +66,7 @@ class LanguageKk_cyrl extends Language { } break; case "dc2": - case "dative": #barıs + case "dative": # barıs if ( in_array( $wordEnding, $Consonants ) ) { if ( in_array( $wordLastVowel, $frontVowels ) ) { $word = $word . "ке"; @@ -82,7 +82,7 @@ class LanguageKk_cyrl extends Language { } break; case "dc21": - case "possessive dative": #täweldık + barıs + case "possessive dative": # täweldık + barıs if ( in_array( $wordEnding, $firstPerson ) ) { if ( in_array( $wordLastVowel, $frontVowels ) ) { $word = $word . "е"; @@ -104,7 +104,7 @@ class LanguageKk_cyrl extends Language { } break; case "dc3": - case "accusative": #tabıs + case "accusative": # tabıs if ( in_array( $wordEnding, $Consonants ) ) { if ( in_array( $wordLastVowel, $frontVowels ) ) { $word = $word . "ті"; @@ -112,13 +112,13 @@ class LanguageKk_cyrl extends Language { $word = $word . "ты"; } } elseif ( in_array( $wordEnding, $allVowels ) ) { - if ( in_array($wordLastVowel, $frontVowels ) ) { + if ( in_array( $wordLastVowel, $frontVowels ) ) { $word = $word . "ні"; } elseif ( in_array( $wordLastVowel, $backVowels ) ) { $word = $word . "ны"; } - } elseif ( in_array( $wordEnding, $Sonorants) ) { - if ( in_array( $wordLastVowel, $frontVowels) ) { + } elseif ( in_array( $wordEnding, $Sonorants ) ) { + if ( in_array( $wordLastVowel, $frontVowels ) ) { $word = $word . "ді"; } elseif ( in_array( $wordLastVowel, $backVowels ) ) { $word = $word . "ды"; @@ -126,7 +126,7 @@ class LanguageKk_cyrl extends Language { } break; case "dc31": - case "possessive accusative": #täweldık + tabıs + case "possessive accusative": # täweldık + tabıs if ( in_array( $wordEnding, $firstPerson ) || in_array( $wordEnding, $secondPerson ) ) { if ( in_array( $wordLastVowel, $frontVowels ) ) { $word = $word . "ді"; @@ -138,7 +138,7 @@ class LanguageKk_cyrl extends Language { } break; case "dc4": - case "locative": #jatıs + case "locative": # jatıs if ( in_array( $wordEnding, $Consonants ) ) { if ( in_array( $wordLastVowel, $frontVowels ) ) { $word = $word . "те"; @@ -146,7 +146,7 @@ class LanguageKk_cyrl extends Language { $word = $word . "та"; } } elseif ( in_array( $wordEnding, $allVowels ) || in_array( $wordEnding, $Sonorants ) ) { - if ( in_array( $wordLastVowel, $frontVowels) ) { + if ( in_array( $wordLastVowel, $frontVowels ) ) { $word = $word . "де"; } elseif ( in_array( $wordLastVowel, $backVowels ) ) { $word = $word . "да"; @@ -154,7 +154,7 @@ class LanguageKk_cyrl extends Language { } break; case "dc41": - case "possessive locative": #täweldık + jatıs + case "possessive locative": # täweldık + jatıs if ( in_array( $wordEnding, $firstPerson ) || in_array( $wordEnding, $secondPerson ) ) { if ( in_array( $wordLastVowel, $frontVowels ) ) { $word = $word . "де"; @@ -162,7 +162,7 @@ class LanguageKk_cyrl extends Language { $word = $word . "да"; } } elseif ( in_array( $wordEnding, $thirdPerson ) ) { - if ( in_array( $wordLastVowel, $frontVowels) ) { + if ( in_array( $wordLastVowel, $frontVowels ) ) { $word = $word . "нде"; } elseif ( in_array( $wordLastVowel, $backVowels ) ) { $word = $word . "нда"; @@ -170,20 +170,20 @@ class LanguageKk_cyrl extends Language { } break; case "dc5": - case "ablative": #şığıs + 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 ) ) { + } 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 ) ) { + } elseif ( in_array( $wordEnding, $Nasals ) ) { if ( in_array( $wordLastVowel, $frontVowels ) ) { $word = $word . "нен"; } elseif ( in_array( $wordLastVowel, $backVowels ) ) { @@ -192,14 +192,14 @@ class LanguageKk_cyrl extends Language { } break; case "dc51": - case "possessive ablative": #täweldık + şığıs + 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 ) ) { + } elseif ( in_array( $wordEnding, $secondPerson ) ) { if ( in_array( $wordLastVowel, $frontVowels ) ) { $word = $word . "ден"; } elseif ( in_array( $wordLastVowel, $backVowels ) ) { @@ -208,7 +208,7 @@ class LanguageKk_cyrl extends Language { } break; case "dc6": - case "comitative": #kömektes + case "comitative": # kömektes if ( in_array( $wordEnding, $Consonants ) ) { $word = $word . "пен"; } elseif ( in_array( $wordEnding, $allVowels ) || in_array( $wordEnding, $Nasals ) || in_array( $wordEnding, $Sonants ) ) { @@ -218,7 +218,7 @@ class LanguageKk_cyrl extends Language { } break; case "dc61": - case "possessive comitative": #täweldık + kömektes + 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 ) ) { @@ -227,7 +227,7 @@ class LanguageKk_cyrl extends Language { $word = $word . "бенен"; } break; - default: #dc0 #nominative #ataw + default: # dc0 #nominative #ataw } return $word; } @@ -247,24 +247,24 @@ class LanguageKk_cyrl extends Language { $allVowels = array( "e", "ö", "ü", "i", "ä", "é", "a", "o", "u", "ı" ); // Preceding letters $Nasals = array( "m", "n", "ñ" ); - $Sonants = array( "ï", "y", "ý", "l", "r", "w"); + $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"); + $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 ); + $lastLetter = $this->lastLetter( $word, $allVowels ); $wordEnding =& $lastLetter[0]; $wordLastVowel =& $lastLetter[1]; // Now convert the word switch ( $case ) { case "dc1": - case "genitive": #ilik + case "genitive": # ilik if ( in_array( $wordEnding, $Consonants ) ) { if ( in_array( $wordLastVowel, $frontVowels ) ) { $word = $word . "tiñ"; @@ -277,7 +277,7 @@ class LanguageKk_cyrl extends Language { } elseif ( in_array( $wordLastVowel, $backVowels ) ) { $word = $word . "nıñ"; } - } elseif ( in_array( $wordEnding, $Sonants ) || in_array( $wordEnding, $Sibilants )) { + } elseif ( in_array( $wordEnding, $Sonants ) || in_array( $wordEnding, $Sibilants ) ) { if ( in_array( $wordLastVowel, $frontVowels ) ) { $word = $word . "diñ"; } elseif ( in_array( $wordLastVowel, $backVowels ) ) { @@ -286,7 +286,7 @@ class LanguageKk_cyrl extends Language { } break; case "dc2": - case "dative": #barıs + case "dative": # barıs if ( in_array( $wordEnding, $Consonants ) ) { if ( in_array( $wordLastVowel, $frontVowels ) ) { $word = $word . "ke"; @@ -302,7 +302,7 @@ class LanguageKk_cyrl extends Language { } break; case "dc21": - case "possessive dative": #täweldık + barıs + case "possessive dative": # täweldık + barıs if ( in_array( $wordEnding, $firstPerson ) ) { if ( in_array( $wordLastVowel, $frontVowels ) ) { $word = $word . "e"; @@ -324,7 +324,7 @@ class LanguageKk_cyrl extends Language { } break; case "dc3": - case "accusative": #tabıs + case "accusative": # tabıs if ( in_array( $wordEnding, $Consonants ) ) { if ( in_array( $wordLastVowel, $frontVowels ) ) { $word = $word . "ti"; @@ -332,13 +332,13 @@ class LanguageKk_cyrl extends Language { $word = $word . "tı"; } } elseif ( in_array( $wordEnding, $allVowels ) ) { - if ( in_array($wordLastVowel, $frontVowels ) ) { + 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) ) { + } elseif ( in_array( $wordEnding, $Sonorants ) ) { + if ( in_array( $wordLastVowel, $frontVowels ) ) { $word = $word . "di"; } elseif ( in_array( $wordLastVowel, $backVowels ) ) { $word = $word . "dı"; @@ -346,7 +346,7 @@ class LanguageKk_cyrl extends Language { } break; case "dc31": - case "possessive accusative": #täweldık + tabıs + 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"; @@ -358,7 +358,7 @@ class LanguageKk_cyrl extends Language { } break; case "dc4": - case "locative": #jatıs + case "locative": # jatıs if ( in_array( $wordEnding, $Consonants ) ) { if ( in_array( $wordLastVowel, $frontVowels ) ) { $word = $word . "te"; @@ -366,7 +366,7 @@ class LanguageKk_cyrl extends Language { $word = $word . "ta"; } } elseif ( in_array( $wordEnding, $allVowels ) || in_array( $wordEnding, $Sonorants ) ) { - if ( in_array( $wordLastVowel, $frontVowels) ) { + if ( in_array( $wordLastVowel, $frontVowels ) ) { $word = $word . "de"; } elseif ( in_array( $wordLastVowel, $backVowels ) ) { $word = $word . "da"; @@ -374,7 +374,7 @@ class LanguageKk_cyrl extends Language { } break; case "dc41": - case "possessive locative": #täweldık + jatıs + 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"; @@ -382,7 +382,7 @@ class LanguageKk_cyrl extends Language { $word = $word . "da"; } } elseif ( in_array( $wordEnding, $thirdPerson ) ) { - if ( in_array( $wordLastVowel, $frontVowels) ) { + if ( in_array( $wordLastVowel, $frontVowels ) ) { $word = $word . "nde"; } elseif ( in_array( $wordLastVowel, $backVowels ) ) { $word = $word . "nda"; @@ -390,20 +390,20 @@ class LanguageKk_cyrl extends Language { } break; case "dc5": - case "ablative": #şığıs + 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 ) ) { + } 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 ) ) { + } elseif ( in_array( $wordEnding, $Nasals ) ) { if ( in_array( $wordLastVowel, $frontVowels ) ) { $word = $word . "nen"; } elseif ( in_array( $wordLastVowel, $backVowels ) ) { @@ -412,14 +412,14 @@ class LanguageKk_cyrl extends Language { } break; case "dc51": - case "possessive ablative": #täweldık + şığıs + 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 ) ) { + } elseif ( in_array( $wordEnding, $secondPerson ) ) { if ( in_array( $wordLastVowel, $frontVowels ) ) { $word = $word . "den"; } elseif ( in_array( $wordLastVowel, $backVowels ) ) { @@ -428,7 +428,7 @@ class LanguageKk_cyrl extends Language { } break; case "dc6": - case "comitative": #kömektes + 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 ) ) { @@ -438,7 +438,7 @@ class LanguageKk_cyrl extends Language { } break; case "dc61": - case "possessive comitative": #täweldık + kömektes + 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 ) ) { @@ -447,7 +447,7 @@ class LanguageKk_cyrl extends Language { $word = $word . "benen"; } break; - default: #dc0 #nominative #ataw + default: # dc0 #nominative #ataw } return $word; } @@ -467,24 +467,24 @@ class LanguageKk_cyrl extends Language { $allVowels = array( "ە", "ٶ", "ٷ", "ٸ", "ٵ", "ە", "ا", "و", "ۇ", "ى" ); // Preceding letters $Nasals = array( "م", "ن", "ڭ" ); - $Sonants = array( "ي", "ي", "ل", "ر", "ۋ"); + $Sonants = array( "ي", "ي", "ل", "ر", "ۋ" ); $Consonants = array( "پ", "ف", "ك", "ق", "ت", "ش", "س", "ح", "تس", "چ", "ب", "ۆ", "گ", "د" ); $Sibilants = array( "ج", "ز" ); - $Sonorants = 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]; + $lastLetter = $this->lastLetter( $word, $allVowels ); + $wordEnding = $lastLetter[0]; + $wordLastVowel = $lastLetter[1]; // Now convert the word switch ( $case ) { case "dc1": - case "genitive": #ilik + case "genitive": # ilik if ( in_array( $wordEnding, $Consonants ) ) { if ( in_array( $wordLastVowel, $frontVowels ) ) { $word = $word . "تٸڭ"; @@ -497,7 +497,7 @@ class LanguageKk_cyrl extends Language { } elseif ( in_array( $wordLastVowel, $backVowels ) ) { $word = $word . "نىڭ"; } - } elseif ( in_array( $wordEnding, $Sonants ) || in_array( $wordEnding, $Sibilants )) { + } elseif ( in_array( $wordEnding, $Sonants ) || in_array( $wordEnding, $Sibilants ) ) { if ( in_array( $wordLastVowel, $frontVowels ) ) { $word = $word . "دٸڭ"; } elseif ( in_array( $wordLastVowel, $backVowels ) ) { @@ -506,7 +506,7 @@ class LanguageKk_cyrl extends Language { } break; case "dc2": - case "dative": #barıs + case "dative": # barıs if ( in_array( $wordEnding, $Consonants ) ) { if ( in_array( $wordLastVowel, $frontVowels ) ) { $word = $word . "كە"; @@ -522,7 +522,7 @@ class LanguageKk_cyrl extends Language { } break; case "dc21": - case "possessive dative": #täweldık + barıs + case "possessive dative": # täweldık + barıs if ( in_array( $wordEnding, $firstPerson ) ) { if ( in_array( $wordLastVowel, $frontVowels ) ) { $word = $word . "ە"; @@ -544,7 +544,7 @@ class LanguageKk_cyrl extends Language { } break; case "dc3": - case "accusative": #tabıs + case "accusative": # tabıs if ( in_array( $wordEnding, $Consonants ) ) { if ( in_array( $wordLastVowel, $frontVowels ) ) { $word = $word . "تٸ"; @@ -552,13 +552,13 @@ class LanguageKk_cyrl extends Language { $word = $word . "تى"; } } elseif ( in_array( $wordEnding, $allVowels ) ) { - if ( in_array($wordLastVowel, $frontVowels ) ) { + if ( in_array( $wordLastVowel, $frontVowels ) ) { $word = $word . "نٸ"; } elseif ( in_array( $wordLastVowel, $backVowels ) ) { $word = $word . "نى"; } - } elseif ( in_array( $wordEnding, $Sonorants) ) { - if ( in_array( $wordLastVowel, $frontVowels) ) { + } elseif ( in_array( $wordEnding, $Sonorants ) ) { + if ( in_array( $wordLastVowel, $frontVowels ) ) { $word = $word . "دٸ"; } elseif ( in_array( $wordLastVowel, $backVowels ) ) { $word = $word . "دى"; @@ -566,7 +566,7 @@ class LanguageKk_cyrl extends Language { } break; case "dc31": - case "possessive accusative": #täweldık + tabıs + case "possessive accusative": # täweldık + tabıs if ( in_array( $wordEnding, $firstPerson ) || in_array( $wordEnding, $secondPerson ) ) { if ( in_array( $wordLastVowel, $frontVowels ) ) { $word = $word . "دٸ"; @@ -578,7 +578,7 @@ class LanguageKk_cyrl extends Language { } break; case "dc4": - case "locative": #jatıs + case "locative": # jatıs if ( in_array( $wordEnding, $Consonants ) ) { if ( in_array( $wordLastVowel, $frontVowels ) ) { $word = $word . "تە"; @@ -586,7 +586,7 @@ class LanguageKk_cyrl extends Language { $word = $word . "تا"; } } elseif ( in_array( $wordEnding, $allVowels ) || in_array( $wordEnding, $Sonorants ) ) { - if ( in_array( $wordLastVowel, $frontVowels) ) { + if ( in_array( $wordLastVowel, $frontVowels ) ) { $word = $word . "دە"; } elseif ( in_array( $wordLastVowel, $backVowels ) ) { $word = $word . "دا"; @@ -594,7 +594,7 @@ class LanguageKk_cyrl extends Language { } break; case "dc41": - case "possessive locative": #täweldık + jatıs + case "possessive locative": # täweldık + jatıs if ( in_array( $wordEnding, $firstPerson ) || in_array( $wordEnding, $secondPerson ) ) { if ( in_array( $wordLastVowel, $frontVowels ) ) { $word = $word . "دە"; @@ -602,7 +602,7 @@ class LanguageKk_cyrl extends Language { $word = $word . "دا"; } } elseif ( in_array( $wordEnding, $thirdPerson ) ) { - if ( in_array( $wordLastVowel, $frontVowels) ) { + if ( in_array( $wordLastVowel, $frontVowels ) ) { $word = $word . "ندە"; } elseif ( in_array( $wordLastVowel, $backVowels ) ) { $word = $word . "ندا"; @@ -610,20 +610,20 @@ class LanguageKk_cyrl extends Language { } break; case "dc5": - case "ablative": #şığıs + 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 ) ) { + } 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 ) ) { + } elseif ( in_array( $wordEnding, $Nasals ) ) { if ( in_array( $wordLastVowel, $frontVowels ) ) { $word = $word . "نەن"; } elseif ( in_array( $wordLastVowel, $backVowels ) ) { @@ -632,14 +632,14 @@ class LanguageKk_cyrl extends Language { } break; case "dc51": - case "possessive ablative": #täweldık + şığıs + 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 ) ) { + } elseif ( in_array( $wordEnding, $secondPerson ) ) { if ( in_array( $wordLastVowel, $frontVowels ) ) { $word = $word . "دەن"; } elseif ( in_array( $wordLastVowel, $backVowels ) ) { @@ -648,7 +648,7 @@ class LanguageKk_cyrl extends Language { } break; case "dc6": - case "comitative": #kömektes + case "comitative": # kömektes if ( in_array( $wordEnding, $Consonants ) ) { $word = $word . "پەن"; } elseif ( in_array( $wordEnding, $allVowels ) || in_array( $wordEnding, $Nasals ) || in_array( $wordEnding, $Sonants ) ) { @@ -658,7 +658,7 @@ class LanguageKk_cyrl extends Language { } break; case "dc61": - case "possessive comitative": #täweldık + kömektes + 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 ) ) { @@ -667,17 +667,16 @@ class LanguageKk_cyrl extends Language { $word = $word . "بەنەن"; } break; - default: #dc0 #nominative #ataw + 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); + $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* @@ -712,7 +711,7 @@ class LanguageKk_cyrl extends Language { */ function commafy( $_ ) { if ( !preg_match( '/^\d{1,4}$/', $_ ) ) { - return strrev( (string)preg_replace( '/(\d{3})(?=\d)(?!\d*\.)/', '$1,', strrev($_) ) ); + return strrev( (string)preg_replace( '/(\d{3})(?=\d)(?!\d*\.)/', '$1,', strrev( $_ ) ) ); } else { return $_; } diff --git a/languages/classes/LanguageKm.php b/languages/classes/LanguageKm.php index 831feb9c..128152f7 100644 --- a/languages/classes/LanguageKm.php +++ b/languages/classes/LanguageKm.php @@ -6,7 +6,7 @@ * @author Niklas Laxström */ class LanguageKm extends Language { - function commafy($_) { + function commafy( $_ ) { /* NO-op for Khmer. Cannot use * $separatorTransformTable = array( ',' => '' ) * That would break when parsing and doing strstr '' => 'foo'; diff --git a/languages/classes/LanguageKsh.php b/languages/classes/LanguageKsh.php index b21cc4d7..6d70b896 100644 --- a/languages/classes/LanguageKsh.php +++ b/languages/classes/LanguageKsh.php @@ -7,6 +7,166 @@ * @author Purodha Blissenbach */ class LanguageKsh extends Language { + static $familygender = array( + // Do not add male wiki families, since that's the default. + // No need add neuter wikis having names ending in -wiki. + 'wikipedia' => 'f', + 'wikiversity' => 'f', + 'wiktionary' => 'n', + 'wikibooks' => 'n', + 'wikiquote' => 'n', + 'wikisource' => 'n', + 'wikitravel' => 'n', + 'wikia' => 'f', + 'translatewiki.net' => 'n', + ); + /** + * Convert from the nominative form of a noun to other cases. + * Invoked with {{GRAMMAR:case|word}} inside messages. + * + * case is a sequence of words, each of which is case insensitive. + * Between words, there must be at least one space character. + * Only the 1st character of each word is considered. + * Word order is irrelevant. + * + * Possible values specifying the grammatical case are: + * 1, Nominative + * 2, Genitive + * 3, Dative + * 4, Accusative, -omitted- + * + * Possible values specifying the article type are: + * Betoont focussed or stressed article + * -omitted- unstressed or unfocussed article + * + * Possible values for for the type of genitive are: + * Sing, Iehr prepositioned genitive = possessive dative + * Vun, Fon, -omitted- postpositioned genitive + * = preposition "vun" with dative + * + * Values of case overrides & prepositions, in the order of preceedence: + * Sing, Iehr possessive dative = prepositioned genitive + * Vun, Fon preposition "vun" with dative + * = postpositioned genitive + * En, em preposition "en" with dative + * + * Values for object gender specifiers of the possessive dative, or + * prepositioned genitive, evaluated with "Sing, Iehr" of above only: + * Male a singular male object follows + * -omitted- a non-male or plural object follows + * + * We currently handle definite articles of the singular only. + * There is a full set of test cases at: + * http://translatewiki.net/wiki/Portal:Ksh#GRAMMAR_Pr%C3%B6%C3%B6fe + * Contents of the leftmost table column can be copied and pasted as + * "case" values. + * + */ + function convertGrammar( $word, $case ) + { + $lord = strtolower($word); + $gender = 'm'; // Nuutnaarel // default + if ( preg_match ( '/wiki$/', $lord ) ) + { + $gender = 'n'; // Dat xyz-wiki + } + if ( isset( self::$familygender[$lord] ) ) + { + $gender = (self::$familygender[$lord]); + } + $case = (' '.strtolower($case)); + if ( preg_match( '/ [is]/', $case ) ) + { + # däm WikiMaatplaz singe, dä Wikipeedija iere, däm Wikiwööterbooch singe + # dem/em WikiMaatplaz singe, de Wikipeedija iere, dem/em Wikiwööterbooch singe + # däm WikiMaatplaz sing, dä Wikipeedija ier, däm Wikiwööterbooch sing + # dem/em WikiMaatplaz sing, de Wikipeedija ier, dem/em Wikiwööterbooch sing + $word = ( preg_match( '/ b/', $case ) + ? ($gender=='f' + ? 'dä' + : 'däm' + ) + : ($gender=='f' + ? 'de' + : 'dem' + ) + ). + ' '.$word.' '. + ( $gender=='f' + ? 'ier' + : 'sing' + ). + ( preg_match( '/ m/', $case ) + ? 'e' + : '' + ); + } + elseif ( preg_match( '/ e/', $case ) ) + { + # en dämm WikiMaatPlaz, en dä Wikipeedija, en dämm Wikiwööterbooch + # em WikiMaatplaz, en de Wikipeedija, em Wikiwööterbooch + if ( preg_match( '/ b/', $case ) ) + { + $word = ('en '.($gender=='f'?'dä':'däm').' '.$word); + } + else + { + $word = (($gender=='f'?'en de':'em').' '.$word); + } + } + elseif ( preg_match( '/ [fv]/', $case ) || preg_match( '/ [2jg]/', $case ) ) + { + # vun däm WikiMaatplaz, vun dä Wikipeedija, vun däm Wikiwööterbooch + # vum WikiMaatplaz, vun de Wikipeedija, vum Wikiwööterbooch + if ( preg_match( '/ b/', $case ) ) + { + $word = ('vun '.($gender=='f'?'dä':'däm').' '.$word); + } + else + { + $word = (($gender=='f'?'vun de':'vum').' '.$word); + } + } + elseif ( preg_match( '/ [3d]/', $case ) ) + { + # dämm WikiMaatPlaz, dä Wikipeedija, dämm Wikiwööterbooch + # dem/em WikiMaatplaz, de Wikipeedija, dem/em Wikiwööterbooch + if ( preg_match( '/ b/', $case ) ) + { + $word = (($gender=='f'?'dää':'dämm').' '.$word); + } + else + { + $word = (($gender=='f'?'de':'dem').' '.$word); + } + } + else + { + # dä WikiMaatPlaz, di Wikipeedija, dat Wikiwööterbooch + # der WikiMaatplaz, de Wikipeedija, et Wikiwööterbooch + if ( preg_match( '/ b/', $case ) ) + { + switch ( $gender ) + { + case 'm' : $lord = 'dä' ; break ; + case 'f' : $lord = 'di' ; break ; + default : $lord = 'dat' ; break ; + } + } + else + { + switch ( $gender ) + { + case 'm' : $lord = 'der' ; break ; + case 'f' : $lord = 'de' ; break ; + default : $lord = 'et' ; break ; + } + } + $word = ($lord.' '.$word); + } + return($word); + } + /** * Avoid grouping whole numbers between 0 to 9999 */ @@ -22,7 +182,7 @@ class LanguageKsh extends Language { * Handle cases of (1, other, 0) or (1, other) */ function convertPlural( $count, $forms ) { - if ( !count($forms) ) { return ''; } + if ( !count( $forms ) ) { return ''; } $forms = $this->preConvertPlural( $forms, 3 ); if ( $count == 1 ) { diff --git a/languages/classes/LanguageKu.deps.php b/languages/classes/LanguageKu.deps.php index 43e2916c..a187b778 100644 --- a/languages/classes/LanguageKu.deps.php +++ b/languages/classes/LanguageKu.deps.php @@ -5,5 +5,5 @@ // changed on a subsequent page view. // see http://lists.wikimedia.org/pipermail/wikitech-l/2006-January/021311.html -require_once( dirname(__FILE__).'/../LanguageConverter.php' ); -require_once( dirname(__FILE__).'/LanguageKu_ku.php' ); +require_once( dirname( __FILE__ ) . '/../LanguageConverter.php' ); +require_once( dirname( __FILE__ ) . '/LanguageKu_ku.php' ); diff --git a/languages/classes/LanguageKu.php b/languages/classes/LanguageKu.php index 5ce68c57..1cc4f017 100644 --- a/languages/classes/LanguageKu.php +++ b/languages/classes/LanguageKu.php @@ -1,9 +1,9 @@ ku -- ist auch richtig /* Doppel- und Halbvokale */ - 'ڵ' => 'll', #ll - 'ڕ' => 'rr', #rr + 'ڵ' => 'll', # ll + 'ڕ' => 'rr', # rr 'ا' => 'a', # 'ئێ' => 'ê', # initial e 'ە' => 'e', @@ -69,7 +69,7 @@ class KuConverter extends LanguageConverter { # 'rr' => 'ڕ', # selbiges für doppel-r /* Einzelne Großbuchstaben */ - //' C' => 'ج', + // ' C' => 'ج', /* Vowels */ 'a' => 'ا', @@ -140,25 +140,25 @@ class KuConverter extends LanguageConverter { */ function findVariantLink( &$link, &$nt, $ignoreOtherCond = false ) { // check for user namespace - if(is_object($nt)){ + 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; + $oldlink = $link; parent::findVariantLink( $link, $nt, $ignoreOtherCond ); - if( $this->getPreferredVariant() == $this->mMainLanguageCode ) - $link=$oldlink; + 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); + function markNoConversion( $text, $noParse = false ) { + if ( $noParse || preg_match( "/^https?:\/\/|ftp:\/\/|irc:\/\//", $text ) ) + return parent::markNoConversion( $text ); return $text; } @@ -166,24 +166,22 @@ class KuConverter extends LanguageConverter { * An ugly function wrapper for parsing Image titles * (to prevent image name conversion) */ - function autoConvert($text, $toVariant=false) { + function autoConvert( $text, $toVariant = false ) { global $wgTitle; - if(is_object($wgTitle) && $wgTitle->getNameSpace()==NS_FILE){ + if ( is_object( $wgTitle ) && $wgTitle->getNameSpace() == NS_FILE ) { $imagename = $wgTitle->getNsText(); - if(preg_match("/^$imagename:/",$text)) return $text; + if ( preg_match( "/^$imagename:/", $text ) ) return $text; } - return parent::autoConvert($text,$toVariant); + return parent::autoConvert( $text, $toVariant ); } /** * It translates text into variant, specials: * - ommiting roman numbers */ - function translate($text, $toVariant){ - $breaks = '[^\w\x80-\xff]'; - + function translate( $text, $toVariant ) { /* From Kazakh interface, maybe we need it later - * + $breaks = '[^\w\x80-\xff]'; // 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 = ''; @@ -207,7 +205,7 @@ class KuConverter extends LanguageConverter { return $ret; */ - if( !isset( $this->mTables[$toVariant] ) ) { + if ( !isset( $this->mTables[$toVariant] ) ) { throw new MWException( "Broken variant table: " . implode( ',', array_keys( $this->mTables ) ) ); } @@ -216,6 +214,8 @@ class KuConverter extends LanguageConverter { } /** + * Kurdish (Kurdî / كوردی) + * * @ingroup Language */ class LanguageKu extends LanguageKu_ku { diff --git a/languages/classes/LanguageKu_ku.php b/languages/classes/LanguageKu_ku.php index cf2107ec..a9ec64e6 100644 --- a/languages/classes/LanguageKu_ku.php +++ b/languages/classes/LanguageKu_ku.php @@ -12,7 +12,7 @@ class LanguageKu_ku extends Language { function commafy( $_ ) { if ( !preg_match( '/^\d{1,4}$/', $_ ) ) { - return strrev( (string)preg_replace( '/(\d{3})(?=\d)(?!\d*\.)/', '$1,', strrev($_) ) ); + return strrev( (string)preg_replace( '/(\d{3})(?=\d)(?!\d*\.)/', '$1,', strrev( $_ ) ) ); } else { return $_; } diff --git a/languages/classes/LanguageLa.php b/languages/classes/LanguageLa.php index c26d0e8e..81fc30cf 100644 --- a/languages/classes/LanguageLa.php +++ b/languages/classes/LanguageLa.php @@ -15,7 +15,7 @@ class LanguageLa extends Language { */ function convertGrammar( $word, $case ) { global $wgGrammarForms; - if ( isset($wgGrammarForms['la'][$case][$word]) ) { + if ( isset( $wgGrammarForms['la'][$case][$word] ) ) { return $wgGrammarForms['la'][$case][$word]; } diff --git a/languages/classes/LanguageLn.php b/languages/classes/LanguageLn.php index bcf5f6e3..11d276d8 100644 --- a/languages/classes/LanguageLn.php +++ b/languages/classes/LanguageLn.php @@ -1,5 +1,6 @@ preConvertPlural( $forms, 2 ); - return ($count <= 1) ? $forms[0] : $forms[1]; + return ( $count <= 1 ) ? $forms[0] : $forms[1]; } } diff --git a/languages/classes/LanguageLt.php b/languages/classes/LanguageLt.php index 87519d98..4291e797 100644 --- a/languages/classes/LanguageLt.php +++ b/languages/classes/LanguageLt.php @@ -11,15 +11,15 @@ class LanguageLt extends Language { 3 - penkiolika (15) lapų */ function convertPlural( $count, $forms ) { - if ( !count($forms) ) { return ''; } + if ( !count( $forms ) ) { return ''; } - //if no number with word, then use $form[0] for singular and $form[1] for plural or zero - if( count($forms) === 2 ) return $count == 1 ? $forms[0] : $forms[1]; + // if no number with word, then use $form[0] for singular and $form[1] for plural or zero + if ( count( $forms ) === 2 ) return $count == 1 ? $forms[0] : $forms[1]; $forms = $this->preConvertPlural( $forms, 3 ); - if ($count%10==1 && $count%100!=11) return $forms[0]; - if ($count%10>=2 && ($count%100<10 || $count%100>=20)) return $forms[1]; + if ( $count % 10 == 1 && $count % 100 != 11 ) return $forms[0]; + if ( $count % 10 >= 2 && ( $count % 100 < 10 || $count % 100 >= 20 ) ) return $forms[1]; return $forms[2]; } } diff --git a/languages/classes/LanguageLv.php b/languages/classes/LanguageLv.php index 84974c37..fea2d21f 100644 --- a/languages/classes/LanguageLv.php +++ b/languages/classes/LanguageLv.php @@ -15,14 +15,12 @@ class LanguageLv extends Language { * * Example: {{plural:{{NUMBEROFARTICLES}}|article|articles}} * - * @param integer $count - * @param string $wordform1 - * @param string $wordform2 - * @param string $wordform3 (not used) - * @return string + * @param $count Integer + * @param $forms Array + * @return String */ function convertPlural( $count, $forms ) { - if ( !count($forms) ) { return ''; } + if ( !count( $forms ) ) { return ''; } // FIXME: CLDR defines 3 plural forms instead of 2. Form for 0 is missing. // http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/language_plural_rules.html#lv diff --git a/languages/classes/LanguageMg.php b/languages/classes/LanguageMg.php index 8593a298..54ef408f 100644 --- a/languages/classes/LanguageMg.php +++ b/languages/classes/LanguageMg.php @@ -1,5 +1,6 @@ preConvertPlural( $forms, 2 ); - return ($count <= 1) ? $forms[0] : $forms[1]; + return ( $count <= 1 ) ? $forms[0] : $forms[1]; } } diff --git a/languages/classes/LanguageMk.php b/languages/classes/LanguageMk.php index 268365df..9dc8a560 100644 --- a/languages/classes/LanguageMk.php +++ b/languages/classes/LanguageMk.php @@ -1,5 +1,6 @@ preConvertPlural( $forms, 2 ); if ( $count % 10 === 1 && $count % 100 !== 11 ) { diff --git a/languages/classes/LanguageMl.php b/languages/classes/LanguageMl.php index 98b5fc96..3cd30eb2 100644 --- a/languages/classes/LanguageMl.php +++ b/languages/classes/LanguageMl.php @@ -1,14 +1,19 @@ preConvertPlural( $forms, 3 ); diff --git a/languages/classes/LanguageMt.php b/languages/classes/LanguageMt.php index fff779ac..fb271bf6 100644 --- a/languages/classes/LanguageMt.php +++ b/languages/classes/LanguageMt.php @@ -9,13 +9,13 @@ class LanguageMt extends Language { function convertPlural( $count, $forms ) { - if ( !count($forms) ) { return ''; } + if ( !count( $forms ) ) { return ''; } $forms = $this->preConvertPlural( $forms, 4 ); if ( $count === 1 ) $index = 0; - elseif ( $count === 0 || ( $count%100>1 && $count%100<11) ) $index = 1; - elseif ( $count%100>10 && $count%100<20 ) $index = 2; + elseif ( $count === 0 || ( $count % 100 > 1 && $count % 100 < 11 ) ) $index = 1; + elseif ( $count % 100 > 10 && $count % 100 < 20 ) $index = 2; else $index = 3; return $forms[$index]; } diff --git a/languages/classes/LanguageMy.php b/languages/classes/LanguageMy.php index d76b99e7..4fa5b05e 100644 --- a/languages/classes/LanguageMy.php +++ b/languages/classes/LanguageMy.php @@ -1,14 +1,13 @@ '' ) * That would break when parsing and doing strstr '' => 'foo'; diff --git a/languages/classes/LanguageNso.php b/languages/classes/LanguageNso.php index 1b56e76a..9ff89039 100644 --- a/languages/classes/LanguageNso.php +++ b/languages/classes/LanguageNso.php @@ -1,5 +1,6 @@ preConvertPlural( $forms, 2 ); - return ($count <= 1) ? $forms[0] : $forms[1]; + return ( $count <= 1 ) ? $forms[0] : $forms[1]; } } diff --git a/languages/classes/LanguagePl.php b/languages/classes/LanguagePl.php index bb798913..40477f42 100644 --- a/languages/classes/LanguagePl.php +++ b/languages/classes/LanguagePl.php @@ -6,7 +6,7 @@ */ class LanguagePl extends Language { function convertPlural( $count, $forms ) { - if ( !count($forms) ) { return ''; } + if ( !count( $forms ) ) { return ''; } $forms = $this->preConvertPlural( $forms, 3 ); $count = abs( $count ); if ( $count == 1 ) @@ -22,9 +22,9 @@ class LanguagePl extends Language { } } - function commafy($_) { - if (!preg_match('/^\d{1,4}(.\d+)?$/',$_)) { - return strrev((string)preg_replace('/(\d{3})(?=\d)(?!\d*\.)/','$1,',strrev($_))); + function commafy( $_ ) { + if ( !preg_match( '/^\-?\d{1,4}(\.\d+)?$/', $_ ) ) { + return strrev( (string)preg_replace( '/(\d{3})(?=\d)(?!\d*\.)/', '$1,', strrev( $_ ) ) ); } else { return $_; } diff --git a/languages/classes/LanguagePt_br.php b/languages/classes/LanguagePt_br.php deleted file mode 100644 index 49726fe7..00000000 --- a/languages/classes/LanguagePt_br.php +++ /dev/null @@ -1,17 +0,0 @@ -preConvertPlural( $forms, 2 ); - - return ($count <= 1) ? $forms[0] : $forms[1]; - } -} diff --git a/languages/classes/LanguageRo.php b/languages/classes/LanguageRo.php index 928f79fb..89edce11 100644 --- a/languages/classes/LanguageRo.php +++ b/languages/classes/LanguageRo.php @@ -1,5 +1,6 @@ preConvertPlural( $forms, 3 ); diff --git a/languages/classes/LanguageRu.php b/languages/classes/LanguageRu.php index bb737e84..8f027048 100644 --- a/languages/classes/LanguageRu.php +++ b/languages/classes/LanguageRu.php @@ -11,45 +11,45 @@ class LanguageRu extends Language { # Invoked with {{grammar:case|word}} function convertGrammar( $word, $case ) { global $wgGrammarForms; - if ( isset($wgGrammarForms['ru'][$case][$word]) ) { + if ( isset( $wgGrammarForms['ru'][$case][$word] ) ) { return $wgGrammarForms['ru'][$case][$word]; } # These rules are not perfect, but they are currently only used for site names so it doesn't # matter if they are wrong sometimes. Just add a special case for your site name if necessary. - #join and array_slice instead mb_substr + # join and array_slice instead mb_substr $ar = array(); preg_match_all( '/./us', $word, $ar ); - if (!preg_match("/[a-zA-Z_]/us", $word)) + if ( !preg_match( "/[a-zA-Z_]/us", $word ) ) switch ( $case ) { - case 'genitive': #родительный падеж - if ((join('',array_slice($ar[0],-4))=='вики') || (join('',array_slice($ar[0],-4))=='Вики')) - {} - elseif (join('',array_slice($ar[0],-1))=='ь') - $word = join('',array_slice($ar[0],0,-1)).'я'; - elseif (join('',array_slice($ar[0],-2))=='ия') - $word=join('',array_slice($ar[0],0,-2)).'ии'; - elseif (join('',array_slice($ar[0],-2))=='ка') - $word=join('',array_slice($ar[0],0,-2)).'ки'; - elseif (join('',array_slice($ar[0],-2))=='ти') - $word=join('',array_slice($ar[0],0,-2)).'тей'; - elseif (join('',array_slice($ar[0],-2))=='ды') - $word=join('',array_slice($ar[0],0,-2)).'дов'; - elseif (join('',array_slice($ar[0],-3))=='ник') - $word=join('',array_slice($ar[0],0,-3)).'ника'; + case 'genitive': # родительный падеж + if ( ( join( '', array_slice( $ar[0], -4 ) ) == 'вики' ) || ( join( '', array_slice( $ar[0], -4 ) ) == 'Вики' ) ) + { } + elseif ( join( '', array_slice( $ar[0], -1 ) ) == 'ь' ) + $word = join( '', array_slice( $ar[0], 0, -1 ) ) . 'я'; + elseif ( join( '', array_slice( $ar[0], -2 ) ) == 'ия' ) + $word = join( '', array_slice( $ar[0], 0, -2 ) ) . 'ии'; + elseif ( join( '', array_slice( $ar[0], -2 ) ) == 'ка' ) + $word = join( '', array_slice( $ar[0], 0, -2 ) ) . 'ки'; + elseif ( join( '', array_slice( $ar[0], -2 ) ) == 'ти' ) + $word = join( '', array_slice( $ar[0], 0, -2 ) ) . 'тей'; + elseif ( join( '', array_slice( $ar[0], -2 ) ) == 'ды' ) + $word = join( '', array_slice( $ar[0], 0, -2 ) ) . 'дов'; + elseif ( join( '', array_slice( $ar[0], -3 ) ) == 'ник' ) + $word = join( '', array_slice( $ar[0], 0, -3 ) ) . 'ника'; break; - case 'dative': #дательный падеж - #stub + case 'dative': # дательный падеж + # stub break; - case 'accusative': #винительный падеж - #stub + case 'accusative': # винительный падеж + # stub break; - case 'instrumental': #творительный падеж - #stub + case 'instrumental': # творительный падеж + # stub break; - case 'prepositional': #предложный падеж - #stub + case 'prepositional': # предложный падеж + # stub break; } return $word; @@ -71,19 +71,19 @@ class LanguageRu extends Language { */ function convertPlural( $count, $forms ) { - if ( !count($forms) ) { return ''; } + if ( !count( $forms ) ) { return ''; } - //if no number with word, then use $form[0] for singular and $form[1] for plural or zero - if( count($forms) === 2 ) return $count == 1 ? $forms[0] : $forms[1]; + // if no number with word, then use $form[0] for singular and $form[1] for plural or zero + if ( count( $forms ) === 2 ) return $count == 1 ? $forms[0] : $forms[1]; // FIXME: CLDR defines 4 plural forms. Form with decimals missing. // See http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/language_plural_rules.html#ru $forms = $this->preConvertPlural( $forms, 3 ); - if ($count > 10 && floor(($count % 100) / 10) == 1) { + if ( $count > 10 && floor( ( $count % 100 ) / 10 ) == 1 ) { return $forms[2]; } else { - switch ($count % 10) { + switch ( $count % 10 ) { case 1: return $forms[0]; case 2: case 3: @@ -98,11 +98,11 @@ class LanguageRu extends Language { * See manual of style at http://ru.wikipedia.org/wiki/Википедия:Оформление_статей * So "1 234 567", "12 345" but "1234" */ - function commafy($_) { - if (preg_match('/^-?\d{1,4}(\.\d*)?$/',$_)) { + function commafy( $_ ) { + if ( preg_match( '/^-?\d{1,4}(\.\d*)?$/', $_ ) ) { return $_; } else { - return strrev((string)preg_replace('/(\d{3})(?=\d)(?!\d*\.)/','$1,',strrev($_))); + return strrev( (string)preg_replace( '/(\d{3})(?=\d)(?!\d*\.)/', '$1,', strrev( $_ ) ) ); } } } diff --git a/languages/classes/LanguageSe.php b/languages/classes/LanguageSe.php index aac943d6..3011bc7f 100644 --- a/languages/classes/LanguageSe.php +++ b/languages/classes/LanguageSe.php @@ -1,18 +1,19 @@ preConvertPlural( $forms, 3 ); if ( $count == 1 ) { $index = 0; - } elseif( $count == 2 ) { + } elseif ( $count == 2 ) { $index = 1; } else { $index = 2; diff --git a/languages/classes/LanguageSh.php b/languages/classes/LanguageSh.php index 29f06f4f..e62d7ba3 100644 --- a/languages/classes/LanguageSh.php +++ b/languages/classes/LanguageSh.php @@ -1,23 +1,24 @@ preConvertPlural( $forms, 3 ); - if ($count > 10 && floor(($count % 100) / 10) == 1) { + if ( $count > 10 && floor( ( $count % 100 ) / 10 ) == 1 ) { return $forms[2]; } else { - switch ($count % 10) { + switch ( $count % 10 ) { case 1: return $forms[0]; case 2: case 3: diff --git a/languages/classes/LanguageSk.php b/languages/classes/LanguageSk.php index 7ddbcbdb..ea74d1ba 100644 --- a/languages/classes/LanguageSk.php +++ b/languages/classes/LanguageSk.php @@ -6,7 +6,7 @@ */ class LanguageSk extends Language { function convertPlural( $count, $forms ) { - if ( !count($forms) ) { return ''; } + if ( !count( $forms ) ) { return ''; } $forms = $this->preConvertPlural( $forms, 3 ); if ( $count == 1 ) { diff --git a/languages/classes/LanguageSl.php b/languages/classes/LanguageSl.php index 734b274c..09138ea5 100644 --- a/languages/classes/LanguageSl.php +++ b/languages/classes/LanguageSl.php @@ -12,7 +12,7 @@ class LanguageSl extends Language { */ function convertGrammar( $word, $case ) { global $wgGrammarForms; - if ( isset($wgGrammarForms['sl'][$case][$word]) ) { + if ( isset( $wgGrammarForms['sl'][$case][$word] ) ) { return $wgGrammarForms['sl'][$case][$word]; } @@ -27,7 +27,7 @@ class LanguageSl extends Language { } function convertPlural( $count, $forms ) { - if ( !count($forms) ) { return ''; } + if ( !count( $forms ) ) { return ''; } $forms = $this->preConvertPlural( $forms, 5 ); if ( $count % 100 == 1 ) { diff --git a/languages/classes/LanguageSma.php b/languages/classes/LanguageSma.php index 5167fb08..a04c77da 100644 --- a/languages/classes/LanguageSma.php +++ b/languages/classes/LanguageSma.php @@ -1,18 +1,19 @@ preConvertPlural( $forms, 3 ); if ( $count == 1 ) { $index = 1; - } elseif( $count == 2 ) { + } elseif ( $count == 2 ) { $index = 2; } else { $index = 3; diff --git a/languages/classes/LanguageSr.deps.php b/languages/classes/LanguageSr.deps.php index ffdd234b..a3770378 100644 --- a/languages/classes/LanguageSr.deps.php +++ b/languages/classes/LanguageSr.deps.php @@ -5,5 +5,5 @@ // changed on a subsequent page view. // see http://lists.wikimedia.org/pipermail/wikitech-l/2006-January/021311.html -require_once( dirname(__FILE__).'/LanguageSr_ec.php' ); -require_once( dirname(__FILE__).'/../LanguageConverter.php' ); +require_once( dirname( __FILE__ ) . '/LanguageSr_ec.php' ); +require_once( dirname( __FILE__ ) . '/../LanguageConverter.php' ); diff --git a/languages/classes/LanguageSr.php b/languages/classes/LanguageSr.php index 693660fb..35c90102 100644 --- a/languages/classes/LanguageSr.php +++ b/languages/classes/LanguageSr.php @@ -1,8 +1,8 @@ 'О', 'P' => 'П', 'R' => 'Р', 'S' => 'С', 'Š' => 'Ш', 'T' => 'Т', 'U' => 'У', 'V' => 'В', 'Z' => 'З', 'Ž' => 'Ж', - 'DŽ' => 'Џ', 'd!ž' => 'дж', 'D!ž'=> 'Дж', 'D!Ž'=> 'ДЖ', - 'Lj' => 'Љ', 'l!j' => 'лј', 'L!j'=> 'Лј', 'L!J'=> 'ЛЈ', - 'Nj' => 'Њ', 'n!j' => 'нј', 'N!j'=> 'Нј', 'N!J'=> 'НЈ' + 'DŽ' => 'Џ', 'd!ž' => 'дж', 'D!ž' => 'Дж', 'D!Ž' => 'ДЖ', + 'Lj' => 'Љ', 'l!j' => 'лј', 'L!j' => 'Лј', 'L!J' => 'ЛЈ', + 'Nj' => 'Њ', 'n!j' => 'нј', 'N!j' => 'Нј', 'N!J' => 'НЈ' ); function loadDefaultTables() { $this->mTables = array( 'sr-ec' => new ReplacementArray( $this->mToCyrillics ), - 'sr-el' => new ReplacementArray( $this->mToLatin), + 'sr-el' => new ReplacementArray( $this->mToLatin ), 'sr' => new ReplacementArray() ); } @@ -63,13 +63,13 @@ class SrConverter extends LanguageConverter { 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); + function parseManualRule( $rule, $flags = array() ) { + if ( in_array( 'T', $flags ) ) { + return parent::parseManualRule( $rule, $flags ); } // otherwise ignore all formatting - foreach($this->mVariants as $v) { + foreach ( $this->mVariants as $v ) { $carray[$v] = $rule; } @@ -84,25 +84,25 @@ class SrConverter extends LanguageConverter { */ function findVariantLink( &$link, &$nt, $ignoreOtherCond = false ) { // check for user namespace - if(is_object($nt)){ + 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; + $oldlink = $link; parent::findVariantLink( $link, $nt, $ignoreOtherCond ); - if($this->getPreferredVariant()==$this->mMainLanguageCode) - $link=$oldlink; + 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); + function markNoConversion( $text, $noParse = false ) { + if ( $noParse || preg_match( "/^https?:\/\/|ftp:\/\/|irc:\/\//", $text ) ) + return parent::markNoConversion( $text ); return $text; } @@ -110,39 +110,39 @@ class SrConverter extends LanguageConverter { * An ugly function wrapper for parsing Image titles * (to prevent image name conversion) */ - function autoConvert($text, $toVariant=false) { + function autoConvert( $text, $toVariant = false ) { global $wgTitle; - if(is_object($wgTitle) && $wgTitle->getNameSpace()==NS_FILE){ + if ( is_object( $wgTitle ) && $wgTitle->getNameSpace() == NS_FILE ) { $imagename = $wgTitle->getNsText(); - if(preg_match("/^$imagename:/",$text)) return $text; + if ( preg_match( "/^$imagename:/", $text ) ) return $text; } - return parent::autoConvert($text,$toVariant); + return parent::autoConvert( $text, $toVariant ); } /** * It translates text into variant, specials: * - ommiting roman numbers */ - function translate($text, $toVariant){ + function translate( $text, $toVariant ) { $breaks = '[^\w\x80-\xff]'; // 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})'; - $reg = '/^'.$roman.'$|^'.$roman.$breaks.'|'.$breaks.$roman.'$|'.$breaks.$roman.$breaks.'/'; + $reg = '/^' . $roman . '$|^' . $roman . $breaks . '|' . $breaks . $roman . '$|' . $breaks . $roman . $breaks . '/'; - $matches = preg_split($reg, $text, -1, PREG_SPLIT_OFFSET_CAPTURE); + $matches = preg_split( $reg, $text, -1, PREG_SPLIT_OFFSET_CAPTURE ); - $m = array_shift($matches); - if( !isset( $this->mTables[$toVariant] ) ) { + $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]); + $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; @@ -150,6 +150,8 @@ class SrConverter extends LanguageConverter { } /** + * Serbian (Српски / Srpski) + * * @ingroup Language */ class LanguageSr extends LanguageSr_ec { @@ -158,7 +160,7 @@ class LanguageSr extends LanguageSr_ec { parent::__construct(); - $variants = array('sr', 'sr-ec', 'sr-el'); + $variants = array( 'sr', 'sr-ec', 'sr-el' ); $variantfallbacks = array( 'sr' => 'sr-ec', 'sr-ec' => 'sr', @@ -169,24 +171,24 @@ class LanguageSr extends LanguageSr_ec { 'S' => 'S', 'писмо' => 'S', 'pismo' => 'S', 'W' => 'W', 'реч' => 'W', 'reč' => 'W', 'ријеч' => 'W', 'riječ' => 'W' ); - $this->mConverter = new SrConverter($this, 'sr', $variants, $variantfallbacks, $flags); + $this->mConverter = new SrConverter( $this, 'sr', $variants, $variantfallbacks, $flags ); $wgHooks['ArticleSaveComplete'][] = $this->mConverter; } function convertPlural( $count, $forms ) { - if ( !count($forms) ) { return ''; } + if ( !count( $forms ) ) { return ''; } - //if no number with word, then use $form[0] for singular and $form[1] for plural or zero - if( count($forms) === 2 ) return $count == 1 ? $forms[0] : $forms[1]; + // if no number with word, then use $form[0] for singular and $form[1] for plural or zero + if ( count( $forms ) === 2 ) return $count == 1 ? $forms[0] : $forms[1]; // FIXME: CLDR defines 4 plural forms. Form with decimals missing. // See http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/language_plural_rules.html#ru $forms = $this->preConvertPlural( $forms, 3 ); - if ($count > 10 && floor(($count % 100) / 10) == 1) { + if ( $count > 10 && floor( ( $count % 100 ) / 10 ) == 1 ) { return $forms[2]; } else { - switch ($count % 10) { + switch ( $count % 10 ) { case 1: return $forms[0]; case 2: case 3: diff --git a/languages/classes/LanguageSr_ec.php b/languages/classes/LanguageSr_ec.php index c7300198..ed447e5e 100644 --- a/languages/classes/LanguageSr_ec.php +++ b/languages/classes/LanguageSr_ec.php @@ -1,17 +1,19 @@ preConvertPlural( $forms, 3 ); - if ($count > 10 && floor(($count % 100) / 10) == 1) { + if ( $count > 10 && floor( ( $count % 100 ) / 10 ) == 1 ) { return $forms[2]; } else { - switch ($count % 10) { + switch ( $count % 10 ) { case 1: return $forms[0]; case 2: case 3: diff --git a/languages/classes/LanguageSr_el.deps.php b/languages/classes/LanguageSr_el.deps.php index cec44dcc..67154c20 100644 --- a/languages/classes/LanguageSr_el.deps.php +++ b/languages/classes/LanguageSr_el.deps.php @@ -5,4 +5,4 @@ // changed on a subsequent page view. // see http://mail.wikipedia.org/pipermail/wikitech-l/2006-January/033660.html -require_once( dirname(__FILE__).'/LanguageSr_ec.php' ); +require_once( dirname( __FILE__ ) . '/LanguageSr_ec.php' ); diff --git a/languages/classes/LanguageSr_el.php b/languages/classes/LanguageSr_el.php index 6ad55f4d..d43772af 100644 --- a/languages/classes/LanguageSr_el.php +++ b/languages/classes/LanguageSr_el.php @@ -1,17 +1,19 @@ preConvertPlural( $forms, 3 ); - if ($count > 10 && floor(($count % 100) / 10) == 1) { + if ( $count > 10 && floor( ( $count % 100 ) / 10 ) == 1 ) { return $forms[2]; } else { - switch ($count % 10) { + switch ( $count % 10 ) { case 1: return $forms[0]; case 2: case 3: diff --git a/languages/classes/LanguageTg.php b/languages/classes/LanguageTg.php index 3a2840db..f73e2ba8 100644 --- a/languages/classes/LanguageTg.php +++ b/languages/classes/LanguageTg.php @@ -1,6 +1,6 @@ preConvertPlural( $forms, 2 ); - return ($count <= 1) ? $forms[0] : $forms[1]; + return ( $count <= 1 ) ? $forms[0] : $forms[1]; } } diff --git a/languages/classes/LanguageTl.php b/languages/classes/LanguageTl.php index 23b6ad6f..4495ddcc 100644 --- a/languages/classes/LanguageTl.php +++ b/languages/classes/LanguageTl.php @@ -1,5 +1,6 @@ preConvertPlural( $forms, 2 ); - return ($count <= 1) ? $forms[0] : $forms[1]; + return ( $count <= 1 ) ? $forms[0] : $forms[1]; } } diff --git a/languages/classes/LanguageTr.php b/languages/classes/LanguageTr.php index 57b0fd07..245b5b06 100644 --- a/languages/classes/LanguageTr.php +++ b/languages/classes/LanguageTr.php @@ -7,7 +7,7 @@ */ class LanguageTr extends Language { function ucfirst ( $string ) { - if ( !empty($string) && $string[0] == 'i' ) { + if ( !empty( $string ) && $string[0] == 'i' ) { return 'İ' . substr( $string, 1 ); } else { return parent::ucfirst( $string ); diff --git a/languages/classes/LanguageTyv.php b/languages/classes/LanguageTyv.php index d77f7966..9e5b6453 100644 --- a/languages/classes/LanguageTyv.php +++ b/languages/classes/LanguageTyv.php @@ -16,37 +16,37 @@ class LanguageTyv extends Language { */ function convertGrammar( $word, $case ) { global $wgGrammarForms; - if ( isset($wgGrammarForms['tyv'][$case][$word]) ) { + if ( isset( $wgGrammarForms['tyv'][$case][$word] ) ) { return $wgGrammarForms['tyv'][$case][$word]; } - // Set up some constants... - $allVowels = array("е", "и", "э", "ө", "ү", "а", "ё", "о", "у", "ы", "ю", "я", "a", "e", "i", "o", "ö", "u", "ü", "y"); - $frontVowels = array("е", "и", "э", "ө", "ү", "e", "i", "ö", "ü"); - $backVowels = array("а", "ё", "о", "у", "ы", "ю", "я", "a", "o", "u", "y"); - $unroundFrontVowels = array("е", "и", "э", "e", "i"); - $roundFrontVowels = array("ө", "ү", "ö", "ü"); - $unroundBackVowels = array("а", "ы", "я", "a", "y"); - $roundBackVowels = array("ё", "о", "у", "ю", "o", "u"); - $voicedPhonemes = array("д", "б", "з", "ж", "г", "d", "b", "z", "g"); - $unvoicedPhonemes = array("т", "п", "с", "ш", "к", "ч", "х", "t", "p", "s", "k", "x"); - $directiveUnvoicedStems = array("т", "п", "с", "ш", "к", "ч", "х", "л", "м", "н", "ң", "t", "p", "s", "k", "x", "l", "m", "n", "ŋ"); - $directiveVoicedStems = array("д", "б", "з", "ж", "г", "р", "й", "d", "b", "z", "g", "r", "j"); + // Set up some constants... + $allVowels = array( "е", "и", "э", "ө", "ү", "а", "ё", "о", "у", "ы", "ю", "я", "a", "e", "i", "o", "ö", "u", "ü", "y" ); + $frontVowels = array( "е", "и", "э", "ө", "ү", "e", "i", "ö", "ü" ); + $backVowels = array( "а", "ё", "о", "у", "ы", "ю", "я", "a", "o", "u", "y" ); + $unroundFrontVowels = array( "е", "и", "э", "e", "i" ); + $roundFrontVowels = array( "ө", "ү", "ö", "ü" ); + $unroundBackVowels = array( "а", "ы", "я", "a", "y" ); + $roundBackVowels = array( "ё", "о", "у", "ю", "o", "u" ); + $voicedPhonemes = array( "д", "б", "з", "ж", "г", "d", "b", "z", "g" ); + $unvoicedPhonemes = array( "т", "п", "с", "ш", "к", "ч", "х", "t", "p", "s", "k", "x" ); + $directiveUnvoicedStems = array( "т", "п", "с", "ш", "к", "ч", "х", "л", "м", "н", "ң", "t", "p", "s", "k", "x", "l", "m", "n", "ŋ" ); + $directiveVoicedStems = array( "д", "б", "з", "ж", "г", "р", "й", "d", "b", "z", "g", "r", "j" ); -// $allSonants = array("л", "м", "н", "ң", "р", "й"); -// $allNasals = array("м", "н", "ң"); + //$allSonants = array("л", "м", "н", "ң", "р", "й"); + //$allNasals = array("м", "н", "ң"); - // Put the word in a form we can play with since we're using UTF-8 + //Put the word in a form we can play with since we're using UTF-8 preg_match_all( '/./us', $word, $ar ); - - $wordEnding = $ar[0][count($ar[0]) - 1]; //Here's the last letter in the word - $wordReversed = array_reverse($ar[0]); //Here's an array with the order of the letters in the word reversed so we can find a match quicker *shrug* - // Find the last vowel in the word + $wordEnding = $ar[0][count( $ar[0] ) - 1]; // Here's the last letter in the word + $wordReversed = array_reverse( $ar[0] ); // Here's an array with the order of the letters in the word reversed so we can find a match quicker *shrug* + + // Find the last vowel in the word $wordLastVowel = NULL; foreach ( $wordReversed as $xvalue ) { foreach ( $allVowels as $yvalue ) { - if ( strcmp($xvalue, $yvalue) == 0 ) { + if ( strcmp( $xvalue, $yvalue ) == 0 ) { $wordLastVowel = $xvalue; break; } else { @@ -60,160 +60,160 @@ class LanguageTyv extends Language { } } - // Now convert the word + // Now convert the word switch ( $case ) { case "genitive": - if ( in_array($wordEnding, $unvoicedPhonemes) ) { - if ( in_array($wordLastVowel, $roundFrontVowels) ) { - $word = implode("",$ar[0]) . "түң"; - } elseif ( in_array($wordLastVowel, $unroundFrontVowels) ) { - $word = implode("",$ar[0]) . "тиң"; - } elseif ( in_array($wordLastVowel, $roundBackVowels) ) { - $word = implode("",$ar[0]) . "туң"; - } elseif ( in_array($wordLastVowel, $unroundBackVowels) ) { - $word = implode("",$ar[0]) . "тың"; + if ( in_array( $wordEnding, $unvoicedPhonemes ) ) { + if ( in_array( $wordLastVowel, $roundFrontVowels ) ) { + $word = implode( "", $ar[0] ) . "түң"; + } elseif ( in_array( $wordLastVowel, $unroundFrontVowels ) ) { + $word = implode( "", $ar[0] ) . "тиң"; + } elseif ( in_array( $wordLastVowel, $roundBackVowels ) ) { + $word = implode( "", $ar[0] ) . "туң"; + } elseif ( in_array( $wordLastVowel, $unroundBackVowels ) ) { + $word = implode( "", $ar[0] ) . "тың"; } else { } - } elseif ( $wordEnding === "л" || $wordEnding === "l") { - if ( in_array($wordLastVowel, $roundFrontVowels) ) { - $word = implode("",$ar[0]) . "дүң"; - } elseif ( in_array($wordLastVowel, $unroundFrontVowels) ) { - $word = implode("",$ar[0]) . "диң"; - } elseif ( in_array($wordLastVowel, $roundBackVowels) ) { - $word = implode("",$ar[0]) . "дуң"; - } elseif ( in_array($wordLastVowel, $unroundBackVowels) ) { - $word = implode("",$ar[0]) . "дың"; + } elseif ( $wordEnding === "л" || $wordEnding === "l" ) { + if ( in_array( $wordLastVowel, $roundFrontVowels ) ) { + $word = implode( "", $ar[0] ) . "дүң"; + } elseif ( in_array( $wordLastVowel, $unroundFrontVowels ) ) { + $word = implode( "", $ar[0] ) . "диң"; + } elseif ( in_array( $wordLastVowel, $roundBackVowels ) ) { + $word = implode( "", $ar[0] ) . "дуң"; + } elseif ( in_array( $wordLastVowel, $unroundBackVowels ) ) { + $word = implode( "", $ar[0] ) . "дың"; } else { } } else { - if ( in_array($wordLastVowel, $roundFrontVowels) ) { - $word = implode("",$ar[0]) . "нүң"; - } elseif ( in_array($wordLastVowel, $unroundFrontVowels) ) { - $word = implode("",$ar[0]) . "ниң"; - } elseif ( in_array($wordLastVowel, $roundBackVowels) ) { - $word = implode("",$ar[0]) . "нуң"; - } elseif ( in_array($wordLastVowel, $unroundBackVowels) ) { - $word = implode("",$ar[0]) . "ның"; + if ( in_array( $wordLastVowel, $roundFrontVowels ) ) { + $word = implode( "", $ar[0] ) . "нүң"; + } elseif ( in_array( $wordLastVowel, $unroundFrontVowels ) ) { + $word = implode( "", $ar[0] ) . "ниң"; + } elseif ( in_array( $wordLastVowel, $roundBackVowels ) ) { + $word = implode( "", $ar[0] ) . "нуң"; + } elseif ( in_array( $wordLastVowel, $unroundBackVowels ) ) { + $word = implode( "", $ar[0] ) . "ның"; } else { } } break; case "dative": - if ( in_array($wordEnding, $unvoicedPhonemes) ) { - if ( in_array($wordLastVowel, $frontVowels) ) { - $word = implode("",$ar[0]) . "ке"; - } elseif ( in_array($wordLastVowel, $backVowels) ) { - $word = implode("",$ar[0]) . "ка"; + if ( in_array( $wordEnding, $unvoicedPhonemes ) ) { + if ( in_array( $wordLastVowel, $frontVowels ) ) { + $word = implode( "", $ar[0] ) . "ке"; + } elseif ( in_array( $wordLastVowel, $backVowels ) ) { + $word = implode( "", $ar[0] ) . "ка"; } else { } } else { - if ( in_array($wordLastVowel, $frontVowels) ) { - $word = implode("",$ar[0]) . "ге"; - } elseif ( in_array($wordLastVowel, $backVowels) ) { - $word = implode("",$ar[0]) . "га"; + if ( in_array( $wordLastVowel, $frontVowels ) ) { + $word = implode( "", $ar[0] ) . "ге"; + } elseif ( in_array( $wordLastVowel, $backVowels ) ) { + $word = implode( "", $ar[0] ) . "га"; } else { } } break; case "accusative": - if ( in_array($wordEnding, $unvoicedPhonemes) ) { - if ( in_array($wordLastVowel, $roundFrontVowels) ) { - $word = implode("",$ar[0]) . "тү"; - } elseif ( in_array($wordLastVowel, $unroundFrontVowels) ) { - $word = implode("",$ar[0]) . "ти"; - } elseif ( in_array($wordLastVowel, $roundBackVowels) ) { - $word = implode("",$ar[0]) . "ту"; - } elseif ( in_array($wordLastVowel, $unroundBackVowels) ) { - $word = implode("",$ar[0]) . "ты"; + if ( in_array( $wordEnding, $unvoicedPhonemes ) ) { + if ( in_array( $wordLastVowel, $roundFrontVowels ) ) { + $word = implode( "", $ar[0] ) . "тү"; + } elseif ( in_array( $wordLastVowel, $unroundFrontVowels ) ) { + $word = implode( "", $ar[0] ) . "ти"; + } elseif ( in_array( $wordLastVowel, $roundBackVowels ) ) { + $word = implode( "", $ar[0] ) . "ту"; + } elseif ( in_array( $wordLastVowel, $unroundBackVowels ) ) { + $word = implode( "", $ar[0] ) . "ты"; } else { } - } elseif ( $wordEnding === "л" || $wordEnding === "l") { - if ( in_array($wordLastVowel, $roundFrontVowels) ) { - $word = implode("",$ar[0]) . "дү"; - } elseif ( in_array($wordLastVowel, $unroundFrontVowels) ) { - $word = implode("",$ar[0]) . "ди"; - } elseif ( in_array($wordLastVowel, $roundBackVowels) ) { - $word = implode("",$ar[0]) . "ду"; - } elseif ( in_array($wordLastVowel, $unroundBackVowels) ) { - $word = implode("",$ar[0]) . "ды"; + } elseif ( $wordEnding === "л" || $wordEnding === "l" ) { + if ( in_array( $wordLastVowel, $roundFrontVowels ) ) { + $word = implode( "", $ar[0] ) . "дү"; + } elseif ( in_array( $wordLastVowel, $unroundFrontVowels ) ) { + $word = implode( "", $ar[0] ) . "ди"; + } elseif ( in_array( $wordLastVowel, $roundBackVowels ) ) { + $word = implode( "", $ar[0] ) . "ду"; + } elseif ( in_array( $wordLastVowel, $unroundBackVowels ) ) { + $word = implode( "", $ar[0] ) . "ды"; } else { } } else { - if ( in_array($wordLastVowel, $roundFrontVowels) ) { - $word = implode("",$ar[0]) . "нү"; - } elseif ( in_array($wordLastVowel, $unroundFrontVowels) ) { - $word = implode("",$ar[0]) . "ни"; - } elseif ( in_array($wordLastVowel, $roundBackVowels) ) { - $word = implode("",$ar[0]) . "ну"; - } elseif ( in_array($wordLastVowel, $unroundBackVowels) ) { - $word = implode("",$ar[0]) . "ны"; + if ( in_array( $wordLastVowel, $roundFrontVowels ) ) { + $word = implode( "", $ar[0] ) . "нү"; + } elseif ( in_array( $wordLastVowel, $unroundFrontVowels ) ) { + $word = implode( "", $ar[0] ) . "ни"; + } elseif ( in_array( $wordLastVowel, $roundBackVowels ) ) { + $word = implode( "", $ar[0] ) . "ну"; + } elseif ( in_array( $wordLastVowel, $unroundBackVowels ) ) { + $word = implode( "", $ar[0] ) . "ны"; } else { } } break; case "locative": - if ( in_array($wordEnding, $unvoicedPhonemes) ) { - if ( in_array($wordLastVowel, $frontVowels) ) { - $word = implode("",$ar[0]) . "те"; - } elseif ( in_array($wordLastVowel, $backVowels) ) { - $word = implode("",$ar[0]) . "та"; + if ( in_array( $wordEnding, $unvoicedPhonemes ) ) { + if ( in_array( $wordLastVowel, $frontVowels ) ) { + $word = implode( "", $ar[0] ) . "те"; + } elseif ( in_array( $wordLastVowel, $backVowels ) ) { + $word = implode( "", $ar[0] ) . "та"; } else { } } else { - if ( in_array($wordLastVowel, $frontVowels) ) { - $word = implode("",$ar[0]) . "де"; - } elseif ( in_array($wordLastVowel, $backVowels) ) { - $word = implode("",$ar[0]) . "да"; + if ( in_array( $wordLastVowel, $frontVowels ) ) { + $word = implode( "", $ar[0] ) . "де"; + } elseif ( in_array( $wordLastVowel, $backVowels ) ) { + $word = implode( "", $ar[0] ) . "да"; } else { } } break; case "ablative": - if ( in_array($wordEnding, $unvoicedPhonemes) ) { - if ( in_array($wordLastVowel, $frontVowels) ) { - $word = implode("",$ar[0]) . "тен"; - } elseif ( in_array($wordLastVowel, $backVowels) ) { - $word = implode("",$ar[0]) . "тан"; + if ( in_array( $wordEnding, $unvoicedPhonemes ) ) { + if ( in_array( $wordLastVowel, $frontVowels ) ) { + $word = implode( "", $ar[0] ) . "тен"; + } elseif ( in_array( $wordLastVowel, $backVowels ) ) { + $word = implode( "", $ar[0] ) . "тан"; } else { } } else { - if ( in_array($wordLastVowel, $frontVowels) ) { - $word = implode("",$ar[0]) . "ден"; - } elseif ( in_array($wordLastVowel, $backVowels) ) { - $word = implode("",$ar[0]) . "дан"; + if ( in_array( $wordLastVowel, $frontVowels ) ) { + $word = implode( "", $ar[0] ) . "ден"; + } elseif ( in_array( $wordLastVowel, $backVowels ) ) { + $word = implode( "", $ar[0] ) . "дан"; } else { } } break; case "directive1": - if ( in_array($wordEnding, $directiveVoicedStems) ) { - $word = implode("",$ar[0]) . "же"; - } elseif ( in_array($wordEnding, $directiveUnvoicedStems) ) { - $word = implode("",$ar[0]) . "че"; + if ( in_array( $wordEnding, $directiveVoicedStems ) ) { + $word = implode( "", $ar[0] ) . "же"; + } elseif ( in_array( $wordEnding, $directiveUnvoicedStems ) ) { + $word = implode( "", $ar[0] ) . "че"; } else { } break; case "directive2": - if ( in_array($wordEnding, $unvoicedPhonemes) ) { - if ( in_array($wordLastVowel, $roundFrontVowels) ) { - $word = implode("",$ar[0]) . "түве"; - } elseif ( in_array($wordLastVowel, $unroundFrontVowels) ) { - $word = implode("",$ar[0]) . "тиве"; - } elseif ( in_array($wordLastVowel, $roundBackVowels) ) { - $word = implode("",$ar[0]) . "туве"; - } elseif ( in_array($wordLastVowel, $unroundBackVowels) ) { - $word = implode("",$ar[0]) . "тыве"; + if ( in_array( $wordEnding, $unvoicedPhonemes ) ) { + if ( in_array( $wordLastVowel, $roundFrontVowels ) ) { + $word = implode( "", $ar[0] ) . "түве"; + } elseif ( in_array( $wordLastVowel, $unroundFrontVowels ) ) { + $word = implode( "", $ar[0] ) . "тиве"; + } elseif ( in_array( $wordLastVowel, $roundBackVowels ) ) { + $word = implode( "", $ar[0] ) . "туве"; + } elseif ( in_array( $wordLastVowel, $unroundBackVowels ) ) { + $word = implode( "", $ar[0] ) . "тыве"; } else { } } else { - if ( in_array($wordLastVowel, $roundFrontVowels) ) { - $word = implode("",$ar[0]) . "дүве"; - } elseif ( in_array($wordLastVowel, $unroundFrontVowels) ) { - $word = implode("",$ar[0]) . "диве"; - } elseif ( in_array($wordLastVowel, $roundBackVowels) ) { - $word = implode("",$ar[0]) . "дуве"; - } elseif ( in_array($wordLastVowel, $unroundBackVowels) ) { - $word = implode("",$ar[0]) . "дыве"; + if ( in_array( $wordLastVowel, $roundFrontVowels ) ) { + $word = implode( "", $ar[0] ) . "дүве"; + } elseif ( in_array( $wordLastVowel, $unroundFrontVowels ) ) { + $word = implode( "", $ar[0] ) . "диве"; + } elseif ( in_array( $wordLastVowel, $roundBackVowels ) ) { + $word = implode( "", $ar[0] ) . "дуве"; + } elseif ( in_array( $wordLastVowel, $unroundBackVowels ) ) { + $word = implode( "", $ar[0] ) . "дыве"; } else { } } diff --git a/languages/classes/LanguageUk.php b/languages/classes/LanguageUk.php index 4b1dfde5..6c0cf8da 100644 --- a/languages/classes/LanguageUk.php +++ b/languages/classes/LanguageUk.php @@ -9,67 +9,67 @@ class LanguageUk extends Language { # Invoked with {{grammar:case|word}} function convertGrammar( $word, $case ) { global $wgGrammarForms; - if ( isset($wgGrammarForms['uk'][$case][$word]) ) { + if ( isset( $wgGrammarForms['uk'][$case][$word] ) ) { return $wgGrammarForms['uk'][$case][$word]; } # These rules are not perfect, but they are currently only used for site names so it doesn't # matter if they are wrong sometimes. Just add a special case for your site name if necessary. - #join and array_slice instead mb_substr + # join and array_slice instead mb_substr $ar = array(); preg_match_all( '/./us', $word, $ar ); - if (!preg_match("/[a-zA-Z_]/us", $word)) + if ( !preg_match( "/[a-zA-Z_]/us", $word ) ) switch ( $case ) { - case 'genitive': #родовий відмінок - if ((join('',array_slice($ar[0],-4))=='вікі') || (join('',array_slice($ar[0],-4))=='Вікі')) - {} - elseif (join('',array_slice($ar[0],-1))=='ь') - $word = join('',array_slice($ar[0],0,-1)).'я'; - elseif (join('',array_slice($ar[0],-2))=='ія') - $word=join('',array_slice($ar[0],0,-2)).'ії'; - elseif (join('',array_slice($ar[0],-2))=='ка') - $word=join('',array_slice($ar[0],0,-2)).'ки'; - elseif (join('',array_slice($ar[0],-2))=='ти') - $word=join('',array_slice($ar[0],0,-2)).'тей'; - elseif (join('',array_slice($ar[0],-2))=='ди') - $word=join('',array_slice($ar[0],0,-2)).'дів'; - elseif (join('',array_slice($ar[0],-3))=='ник') - $word=join('',array_slice($ar[0],0,-3)).'ника'; + case 'genitive': # родовий відмінок + if ( ( join( '', array_slice( $ar[0], -4 ) ) == 'вікі' ) || ( join( '', array_slice( $ar[0], -4 ) ) == 'Вікі' ) ) + { } + elseif ( join( '', array_slice( $ar[0], -1 ) ) == 'ь' ) + $word = join( '', array_slice( $ar[0], 0, -1 ) ) . 'я'; + elseif ( join( '', array_slice( $ar[0], -2 ) ) == 'ія' ) + $word = join( '', array_slice( $ar[0], 0, -2 ) ) . 'ії'; + elseif ( join( '', array_slice( $ar[0], -2 ) ) == 'ка' ) + $word = join( '', array_slice( $ar[0], 0, -2 ) ) . 'ки'; + elseif ( join( '', array_slice( $ar[0], -2 ) ) == 'ти' ) + $word = join( '', array_slice( $ar[0], 0, -2 ) ) . 'тей'; + elseif ( join( '', array_slice( $ar[0], -2 ) ) == 'ди' ) + $word = join( '', array_slice( $ar[0], 0, -2 ) ) . 'дів'; + elseif ( join( '', array_slice( $ar[0], -3 ) ) == 'ник' ) + $word = join( '', array_slice( $ar[0], 0, -3 ) ) . 'ника'; break; - case 'dative': #давальний відмінок - #stub + case 'dative': # давальний відмінок + # stub break; - case 'accusative': #знахідний відмінок - if ((join('',array_slice($ar[0],-4))=='вікі') || (join('',array_slice($ar[0],-4))=='Вікі')) - {} - elseif (join('',array_slice($ar[0],-2))=='ія') - $word=join('',array_slice($ar[0],0,-2)).'ію'; + case 'accusative': # знахідний відмінок + if ( ( join( '', array_slice( $ar[0], -4 ) ) == 'вікі' ) || ( join( '', array_slice( $ar[0], -4 ) ) == 'Вікі' ) ) + { } + elseif ( join( '', array_slice( $ar[0], -2 ) ) == 'ія' ) + $word = join( '', array_slice( $ar[0], 0, -2 ) ) . 'ію'; break; - case 'instrumental': #орудний відмінок - #stub + case 'instrumental': # орудний відмінок + # stub break; - case 'prepositional': #місцевий відмінок - #stub + case 'prepositional': # місцевий відмінок + # stub break; } return $word; } function convertPlural( $count, $forms ) { - if ( !count($forms) ) { return ''; } + if ( !count( $forms ) ) { return ''; } - //if no number with word, then use $form[0] for singular and $form[1] for plural or zero - if( count($forms) === 2 ) return $count == 1 ? $forms[0] : $forms[1]; + // if no number with word, then use $form[0] for singular and $form[1] for plural or zero + if ( count( $forms ) === 2 ) return $count == 1 ? $forms[0] : $forms[1]; // FIXME: CLDR defines 4 plural forms. Form for decimals is missing/ // See http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/language_plural_rules.html#uk $forms = $this->preConvertPlural( $forms, 3 ); - if ($count > 10 && floor(($count % 100) / 10) == 1) { + if ( $count > 10 && floor( ( $count % 100 ) / 10 ) == 1 ) { return $forms[2]; } else { - switch ($count % 10) { + switch ( $count % 10 ) { case 1: return $forms[0]; case 2: case 3: @@ -82,10 +82,9 @@ class LanguageUk extends Language { /* * Ukrainian numeric format is "12 345,67" but "1234,56" */ - - function commafy($_) { - if (!preg_match('/^\d{1,4}$/',$_)) { - return strrev((string)preg_replace('/(\d{3})(?=\d)(?!\d*\.)/','$1,',strrev($_))); + function commafy( $_ ) { + if ( !preg_match( '/^\-?\d{1,4}(\.\d+)?$/', $_ ) ) { + return strrev( (string)preg_replace( '/(\d{3})(?=\d)(?!\d*\.)/', '$1,', strrev( $_ ) ) ); } else { return $_; } diff --git a/languages/classes/LanguageWa.php b/languages/classes/LanguageWa.php index 4a4296ca..0cb439d0 100644 --- a/languages/classes/LanguageWa.php +++ b/languages/classes/LanguageWa.php @@ -13,18 +13,19 @@ class LanguageWa extends Language { * Use singular form for zero */ function convertPlural( $count, $forms ) { - if ( !count($forms) ) { return ''; } + if ( !count( $forms ) ) { return ''; } $forms = $this->preConvertPlural( $forms, 2 ); - return ($count <= 1) ? $forms[0] : $forms[1]; + return ( $count <= 1 ) ? $forms[0] : $forms[1]; } - ### - ### Dates in Walloon are "1î d' " for 1st of the month, - ### " di " for months starting by a consoun, and - ### " d' " for months starting with a vowel - ### + ## # + ## # Dates in Walloon are "1î d' " for 1st of the month, + ## # " di " for months starting by a consoun, and + ## # " d' " for months starting with a vowel + ## # function date( $ts, $adj = false, $format = true, $tc = false ) { + $ts = wfTimestamp( TS_MW, $ts ); if ( $adj ) { $ts = $this->userAdjust( $ts, $tc ); } $datePreference = $this->dateFormat( $format ); @@ -32,13 +33,13 @@ class LanguageWa extends Language { # # we also output this format for YMD (eg: 2001 January 15) if ( $datePreference == 'ISO 8601' ) { - $d = substr($ts, 0, 4). '-' . substr($ts, 4, 2). '-' .substr($ts, 6, 2); + $d = substr( $ts, 0, 4 ) . '-' . substr( $ts, 4, 2 ) . '-' . substr( $ts, 6, 2 ); return $d; } # dd/mm/YYYY format if ( $datePreference == 'walloon short' ) { - $d = substr($ts, 6, 2). '/' . substr($ts, 4, 2). '/' .substr($ts, 0, 4); + $d = substr( $ts, 6, 2 ) . '/' . substr( $ts, 4, 2 ) . '/' . substr( $ts, 0, 4 ); return $d; } @@ -47,17 +48,17 @@ class LanguageWa extends Language { # we output this in all other cases $m = substr( $ts, 4, 2 ); $n = substr( $ts, 6, 2 ); - if ($n == 1) { + if ( $n == 1 ) { $d = "1î d' " . $this->getMonthName( $m ) . " " . substr( $ts, 0, 4 ); - } else if ($n == 2 || $n == 3 || $n == 20 || $n == 22 || $n == 23) { - $d = (0 + $n) . " d' " . $this->getMonthName( $m ) . + } else if ( $n == 2 || $n == 3 || $n == 20 || $n == 22 || $n == 23 ) { + $d = ( 0 + $n ) . " d' " . $this->getMonthName( $m ) . " " . substr( $ts, 0, 4 ); - } else if ($m == 4 || $m == 8 || $m == 10) { - $d = (0 + $n) . " d' " . $this->getMonthName( $m ) . + } else if ( $m == 4 || $m == 8 || $m == 10 ) { + $d = ( 0 + $n ) . " d' " . $this->getMonthName( $m ) . " " . substr( $ts, 0, 4 ); } else { - $d = (0 + $n) . " di " . $this->getMonthName( $m ) . + $d = ( 0 + $n ) . " di " . $this->getMonthName( $m ) . " " . substr( $ts, 0, 4 ); } return $d; diff --git a/languages/classes/LanguageYue.php b/languages/classes/LanguageYue.php index 6581d788..aff3d29e 100644 --- a/languages/classes/LanguageYue.php +++ b/languages/classes/LanguageYue.php @@ -1,5 +1,7 @@ mDescCodeSep = ':'; $this->mDescVarSep = ';'; - parent::__construct($langobj, $maincode, + parent::__construct( $langobj, $maincode, $variants, $variantfallbacks, $flags, - $manualLevel); + $manualLevel ); $names = array( 'zh' => '原文', 'zh-hans' => '简体', @@ -31,20 +31,20 @@ class ZhConverter extends LanguageConverter { 'zh-sg' => '新加坡', 'zh-my' => '大马', ); - $this->mVariantNames = array_merge($this->mVariantNames,$names); + $this->mVariantNames = array_merge( $this->mVariantNames, $names ); } function loadDefaultTables() { - require( dirname(__FILE__)."/../../includes/ZhConversion.php" ); + require( dirname( __FILE__ ) . "/../../includes/ZhConversion.php" ); $this->mTables = array( 'zh-hans' => new ReplacementArray( $zh2Hans ), 'zh-hant' => new ReplacementArray( $zh2Hant ), - 'zh-cn' => new ReplacementArray( array_merge($zh2Hans, $zh2CN) ), - 'zh-hk' => new ReplacementArray( array_merge($zh2Hant, $zh2HK) ), - 'zh-mo' => new ReplacementArray( array_merge($zh2Hant, $zh2HK) ), - 'zh-my' => new ReplacementArray( array_merge($zh2Hans, $zh2SG) ), - 'zh-sg' => new ReplacementArray( array_merge($zh2Hans, $zh2SG) ), - 'zh-tw' => new ReplacementArray( array_merge($zh2Hant, $zh2TW) ), + 'zh-cn' => new ReplacementArray( array_merge( $zh2Hans, $zh2CN ) ), + 'zh-hk' => new ReplacementArray( array_merge( $zh2Hant, $zh2HK ) ), + 'zh-mo' => new ReplacementArray( array_merge( $zh2Hant, $zh2HK ) ), + 'zh-my' => new ReplacementArray( array_merge( $zh2Hans, $zh2SG ) ), + 'zh-sg' => new ReplacementArray( array_merge( $zh2Hans, $zh2SG ) ), + 'zh-tw' => new ReplacementArray( array_merge( $zh2Hant, $zh2TW ) ), 'zh' => new ReplacementArray ); } @@ -62,7 +62,7 @@ class ZhConverter extends LanguageConverter { to mark anything. $noParse is there for compatibility with LanguageConvert::markNoConversion */ - function markNoConversion($text, $noParse = false) { + function markNoConversion( $text, $noParse = false ) { return $text; } @@ -83,20 +83,20 @@ class LanguageZh extends LanguageZh_hans { global $wgHooks; parent::__construct(); - $variants = array('zh','zh-hans','zh-hant','zh-cn','zh-hk','zh-mo','zh-my','zh-sg','zh-tw'); - + $variants = array( 'zh', 'zh-hans', 'zh-hant', 'zh-cn', 'zh-hk', 'zh-mo', 'zh-my', 'zh-sg', 'zh-tw' ); + $variantfallbacks = array( - 'zh' => array('zh-hans','zh-hant','zh-cn','zh-tw','zh-hk','zh-sg','zh-mo','zh-my'), - 'zh-hans' => array('zh-cn','zh-sg','zh-my'), - 'zh-hant' => array('zh-tw','zh-hk','zh-mo'), - 'zh-cn' => array('zh-hans','zh-sg','zh-my'), - 'zh-sg' => array('zh-hans','zh-cn','zh-my'), - 'zh-my' => array('zh-hans','zh-sg','zh-cn'), - 'zh-tw' => array('zh-hant','zh-hk','zh-mo'), - 'zh-hk' => array('zh-hant','zh-mo','zh-tw'), - 'zh-mo' => array('zh-hant','zh-hk','zh-tw'), + 'zh' => array( 'zh-hans', 'zh-hant', 'zh-cn', 'zh-tw', 'zh-hk', 'zh-sg', 'zh-mo', 'zh-my' ), + 'zh-hans' => array( 'zh-cn', 'zh-sg', 'zh-my' ), + 'zh-hant' => array( 'zh-tw', 'zh-hk', 'zh-mo' ), + 'zh-cn' => array( 'zh-hans', 'zh-sg', 'zh-my' ), + 'zh-sg' => array( 'zh-hans', 'zh-cn', 'zh-my' ), + 'zh-my' => array( 'zh-hans', 'zh-sg', 'zh-cn' ), + 'zh-tw' => array( 'zh-hant', 'zh-hk', 'zh-mo' ), + 'zh-hk' => array( 'zh-hant', 'zh-mo', 'zh-tw' ), + 'zh-mo' => array( 'zh-hant', 'zh-hk', 'zh-tw' ), ); - $ml=array( + $ml = array( 'zh' => 'disable', 'zh-hans' => 'unidirectional', 'zh-hant' => 'unidirectional', @@ -105,7 +105,7 @@ class LanguageZh extends LanguageZh_hans { $this->mConverter = new ZhConverter( $this, 'zh', $variants, $variantfallbacks, array(), - $ml); + $ml ); $wgHooks['ArticleSaveComplete'][] = $this->mConverter; } @@ -114,13 +114,13 @@ class LanguageZh extends LanguageZh_hans { function segmentForDiff( $text ) { return preg_replace( "/([\\xc0-\\xff][\\x80-\\xbf]*)/e", - "' ' .\"$1\"", $text); + "' ' .\"$1\"", $text ); } function unsegmentForDiff( $text ) { return preg_replace( "/ ([\\xc0-\\xff][\\x80-\\xbf]*)/e", - "\"$1\"", $text); + "\"$1\"", $text ); } /** @@ -149,7 +149,7 @@ class LanguageZh extends LanguageZh_hans { $terms = implode( '|', $termsArray ); $terms = self::convertDoubleWidth( $terms ); $terms = implode( '|', $this->mConverter->autoConvertToAllVariants( $terms ) ); - $ret = array_unique( explode('|', $terms) ); + $ret = array_unique( explode( '|', $terms ) ); return $ret; } } diff --git a/languages/classes/LanguageZh_hans.php b/languages/classes/LanguageZh_hans.php index 5b03d731..a65162bc 100644 --- a/languages/classes/LanguageZh_hans.php +++ b/languages/classes/LanguageZh_hans.php @@ -1,6 +1,8 @@ segmentByWord( $s ); wfProfileOut( __METHOD__ ); return $s; } -} \ No newline at end of file +} -- cgit v1.2.3-54-g00ecf