summaryrefslogtreecommitdiff
path: root/languages/classes
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2008-03-21 11:49:34 +0100
committerPierre Schmitz <pierre@archlinux.de>2008-03-21 11:49:34 +0100
commit086ae52d12011746a75f5588e877347bc0457352 (patch)
treee73263c7a29d0f94fafb874562610e16eb292ba8 /languages/classes
parent749e7fb2bae7bbda855de3c9e319435b9f698ff7 (diff)
Update auf MediaWiki 1.12.0
Diffstat (limited to 'languages/classes')
-rw-r--r--languages/classes/LanguageAr.php6
-rw-r--r--languages/classes/LanguageBat_smg.php26
-rw-r--r--languages/classes/LanguageBe.php15
-rw-r--r--languages/classes/LanguageBe_tarask.php29
-rw-r--r--languages/classes/LanguageBs.php14
-rw-r--r--languages/classes/LanguageCs.php50
-rw-r--r--languages/classes/LanguageCu.php15
-rw-r--r--languages/classes/LanguageCy.php21
-rw-r--r--languages/classes/LanguageDsb.php115
-rw-r--r--languages/classes/LanguageFi.php6
-rw-r--r--languages/classes/LanguageFr.php10
-rw-r--r--languages/classes/LanguageHe.php13
-rw-r--r--languages/classes/LanguageHr.php15
-rw-r--r--languages/classes/LanguageHsb.php17
-rw-r--r--languages/classes/LanguageHy.php12
-rw-r--r--languages/classes/LanguageKaa.php43
-rw-r--r--languages/classes/LanguageKk.deps.php3
-rw-r--r--languages/classes/LanguageKk.php498
-rw-r--r--languages/classes/LanguageKk_cyrl.php722
-rw-r--r--languages/classes/LanguageKsh.php16
-rw-r--r--languages/classes/LanguageKu.php32
-rw-r--r--languages/classes/LanguageLt.php16
-rw-r--r--languages/classes/LanguageLv.php7
-rw-r--r--languages/classes/LanguagePl.php24
-rw-r--r--languages/classes/LanguagePt_br.php9
-rw-r--r--languages/classes/LanguageRu.php34
-rw-r--r--languages/classes/LanguageSk.php7
-rw-r--r--languages/classes/LanguageSl.php7
-rw-r--r--languages/classes/LanguageSr_ec.php14
-rw-r--r--languages/classes/LanguageSr_el.php14
-rw-r--r--languages/classes/LanguageUk.php14
-rw-r--r--languages/classes/LanguageYue.php23
-rw-r--r--languages/classes/LanguageZh.deps.php3
-rw-r--r--languages/classes/LanguageZh.php56
-rw-r--r--languages/classes/LanguageZh_hans.php23
35 files changed, 1627 insertions, 302 deletions
diff --git a/languages/classes/LanguageAr.php b/languages/classes/LanguageAr.php
index 514ff028..1b9ae7bf 100644
--- a/languages/classes/LanguageAr.php
+++ b/languages/classes/LanguageAr.php
@@ -7,8 +7,10 @@
*/
class LanguageAr extends Language {
- function convertPlural( $count, $w1, $w2, $w3, $w4, $w5) {
- $forms = array($w1, $w2, $w3, $w4, $w5);
+ function convertPlural( $count, $forms ) {
+ if ( !count($forms) ) { return ''; }
+ $forms = $this->preConvertPlural( $forms, 5 );
+
if ( $count == 1 ) {
$index = 0;
} elseif( $count == 2 ) {
diff --git a/languages/classes/LanguageBat_smg.php b/languages/classes/LanguageBat_smg.php
new file mode 100644
index 00000000..fc830cf5
--- /dev/null
+++ b/languages/classes/LanguageBat_smg.php
@@ -0,0 +1,26 @@
+<?php
+/** Samogitian (Žemaitėška)
+ *
+ * @addtogroup Language
+ *
+ * @author Niklas Laxström
+ */
+class LanguageBat_smg extends Language {
+
+ function convertPlural( $count, $forms ) {
+ if ( !count($forms) ) { return ''; }
+ $forms = $this->preConvertPlural( $forms, 4 );
+
+ $count = abs( $count );
+ if ( $count === 0 || ($count%100 === 0 || ($count%100 >= 10 && $count%100 < 20)) ) {
+ return $forms[2];
+ } elseif ( $count%10 === 1 ) {
+ return $forms[0];
+ } elseif ( $count%10 === 2 ) {
+ return $forms[1];
+ } else {
+ return $forms[3];
+ }
+ }
+
+} \ No newline at end of file
diff --git a/languages/classes/LanguageBe.php b/languages/classes/LanguageBe.php
index e0665e68..cc3e4e37 100644
--- a/languages/classes/LanguageBe.php
+++ b/languages/classes/LanguageBe.php
@@ -14,17 +14,20 @@
*/
class LanguageBe extends Language {
- function convertPlural( $count, $wordform1, $wordform2, $wordform3, $w4, $w5) {
- $count = str_replace ('.', '', $count);
+
+ function convertPlural( $count, $forms ) {
+ if ( !count($forms) ) { return ''; }
+ $forms = $this->preConvertPlural( $forms, 3 );
+
if ($count > 10 && floor(($count % 100) / 10) == 1) {
- return $wordform3;
+ return $forms[2];
} else {
switch ($count % 10) {
- case 1: return $wordform1;
+ case 1: return $forms[0];
case 2:
case 3:
- case 4: return $wordform2;
- default: return $wordform3;
+ case 4: return $forms[1];
+ default: return $forms[2];
}
}
}
diff --git a/languages/classes/LanguageBe_tarask.php b/languages/classes/LanguageBe_tarask.php
index 5e168b7e..d2dd4825 100644
--- a/languages/classes/LanguageBe_tarask.php
+++ b/languages/classes/LanguageBe_tarask.php
@@ -1,5 +1,5 @@
<?php
-/** Belarusian in Taraskievica orthography (Беларуская тарашкевіца)
+/** Belarusian in Taraškievica orthography (Беларуская тарашкевіца)
*
* @addtogroup Language
*
@@ -11,17 +11,32 @@
*/
class LanguageBe_tarask extends Language {
- function convertPlural( $count, $wordform1, $wordform2, $wordform3, $w4, $w5) {
- $count = str_replace ('.', '', $count);
+ /**
+ * Plural form transformations
+ *
+ * $wordform1 - singular form (for 1, 21, 31, 41...)
+ * $wordform2 - plural form (for 2, 3, 4, 22, 23, 24, 32, 33, 34...)
+ * $wordform3 - plural form (for 0, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 25, 26...)
+ * $wordform4 - plural form for messages without number
+ */
+
+ function convertPlural( $count, $forms ) {
+ if ( !count($forms) ) { return ''; }
+ $forms = $this->preConvertPlural( $forms, 3 );
+
+ $count = abs( $count );
+ if ( isset($forms[3]) && $count != 1 )
+ return $forms[3];
+
if ($count > 10 && floor(($count % 100) / 10) == 1) {
- return $wordform3;
+ return $forms[2];
} else {
switch ($count % 10) {
- case 1: return $wordform1;
+ case 1: return $forms[0];
case 2:
case 3:
- case 4: return $wordform2;
- default: return $wordform3;
+ case 4: return $forms[1];
+ default: return $forms[2];
}
}
}
diff --git a/languages/classes/LanguageBs.php b/languages/classes/LanguageBs.php
index 119280e6..410c3d62 100644
--- a/languages/classes/LanguageBs.php
+++ b/languages/classes/LanguageBs.php
@@ -6,17 +6,19 @@
class LanguageBs extends Language {
- function convertPlural( $count, $wordform1, $wordform2, $wordform3, $w4, $w5) {
- $count = str_replace ('.', '', $count);
+ function convertPlural( $count, $forms ) {
+ if ( !count($forms) ) { return ''; }
+ $forms = $this->preConvertPlural( $forms, 3 );
+
if ($count > 10 && floor(($count % 100) / 10) == 1) {
- return $wordform3;
+ return $forms[2];
} else {
switch ($count % 10) {
- case 1: return $wordform1;
+ case 1: return $forms[0];
case 2:
case 3:
- case 4: return $wordform2;
- default: return $wordform3;
+ case 4: return $forms[1];
+ default: return $forms[2];
}
}
}
diff --git a/languages/classes/LanguageCs.php b/languages/classes/LanguageCs.php
index ac80f296..4a52368e 100644
--- a/languages/classes/LanguageCs.php
+++ b/languages/classes/LanguageCs.php
@@ -19,6 +19,20 @@ class LanguageCs extends Language {
# allowed values for $case:
# 1sg, 2sg, ..., 7sg -- nominative, genitive, ... (in singular)
switch ( $word ) {
+ case 'Wikibooks':
+ case 'Wikiknihy':
+ switch ( $case ) {
+ case '2sg':
+ return 'Wikiknih';
+ case '3sg':
+ return 'Wikiknihám';
+ case '6sg';
+ return 'Wikiknihách';
+ case '7sg':
+ return 'Wikiknihami';
+ default:
+ return 'Wikiknihy';
+ }
case 'Wikipedia':
case 'Wikipedie':
switch ( $case ) {
@@ -34,17 +48,17 @@ class LanguageCs extends Language {
case 'Wiktionary':
case 'Wikcionář':
+ case 'Wikislovník':
switch ( $case ) {
case '2sg':
- return 'Wikcionáře';
case '3sg':
case '5sg';
case '6sg';
- return 'Wikcionáři';
+ return 'Wikislovníku';
case '7sg':
- return 'Wikcionářem';
+ return 'Wikislovníkem';
default:
- return 'Wikcionář';
+ return 'Wikislovník';
}
case 'Wikiquote':
@@ -64,23 +78,17 @@ class LanguageCs extends Language {
return $word;
}
- # Plural form transformations, needed for some languages.
- # Invoked by {{plural:count|wordform1|wordform2|wordform3}}
- function convertPlural( $count, $wordform1, $wordform2, $wordform3, $w4, $w5) {
- $count = str_replace( '\xc2\xa0', '', $count );
- switch ( $count ) {
- case 1:
- return $wordform1;
+ function convertPlural( $count, $forms ) {
+ if ( !count($forms) ) { return ''; }
+ $forms = $this->preConvertPlural( $forms, 3 );
- case 2:
- case 3:
- case 4:
- return $wordform2;
+ switch ( $count ) {
+ case 1: return $forms[0];
+ case 2:
+ case 3:
+ case 4: return $forms[1];
+ default: return $forms[2];
+ }
+ }
- default:
- return $wordform3;
- };
- }
}
-
-
diff --git a/languages/classes/LanguageCu.php b/languages/classes/LanguageCu.php
index 61128f24..fba895ec 100644
--- a/languages/classes/LanguageCu.php
+++ b/languages/classes/LanguageCu.php
@@ -35,13 +35,16 @@ class LanguageCu extends Language {
return $word;
}
- function convertPlural( $count, $wordform1, $wordform2, $wordform3, $wordform4, $w5) {
+ function convertPlural( $count, $forms ) {
+ if ( !count($forms) ) { return ''; }
+ $forms = $this->preConvertPlural( $forms, 4 );
+
switch ($count % 10) {
- case 1: return $wordform1;
- case 2: return $wordform2;
- case 3: return $wordform3;
- case 4: return $wordform3;
- default: return $wordform4;
+ case 1: return $forms[0];
+ case 2: return $forms[1];
+ case 3:
+ case 4: return $forms[2];
+ default: return $forms[3];
}
}
diff --git a/languages/classes/LanguageCy.php b/languages/classes/LanguageCy.php
new file mode 100644
index 00000000..aea24019
--- /dev/null
+++ b/languages/classes/LanguageCy.php
@@ -0,0 +1,21 @@
+<?php
+/** Welsh (Cymraeg)
+ *
+ * @addtogroup Language
+ *
+ * @author Niklas Laxström
+ */
+class LanguageCy extends Language {
+ function convertPlural( $count, $forms ) {
+ if ( !count($forms) ) { return ''; }
+ $forms = $this->preConvertPlural( $forms, 6 );
+ $count = abs( $count );
+ if ( $count >= 0 && $count <= 3 ) {
+ return $forms[$count];
+ } elseif ( $count == 6 ) {
+ return $forms[4];
+ } else {
+ return $forms[5];
+ }
+ }
+}
diff --git a/languages/classes/LanguageDsb.php b/languages/classes/LanguageDsb.php
new file mode 100644
index 00000000..7408217e
--- /dev/null
+++ b/languages/classes/LanguageDsb.php
@@ -0,0 +1,115 @@
+<?php
+/** Lower Sorbian (Dolnoserbski)
+ *
+ * @addtogroup Language
+ */
+
+class LanguageDsb extends Language {
+
+ # Convert from the nominative form of a noun to some other case
+ # Invoked with {{GRAMMAR:case|word}}
+
+ function convertGrammar( $word, $case ) {
+ global $wgGrammarForms;
+ if ( isset( $wgGrammarForms['hsb'][$case][$word] ) ) {
+ return $wgGrammarForms['hsb'][$case][$word];
+ }
+
+ switch ( $case ) {
+ case 'genitiw': # genitive
+ if ( $word == 'Wikipedija' ) {
+ $word = 'Wikipedije';
+ } elseif ( $word == 'Wikiknihi' ) {
+ $word = 'Wikiknih';
+ } elseif ( $word == 'Wikinowiny' ) {
+ $word = 'Wikinowin';
+ } elseif ( $word == 'Wikižórło' ) {
+ $word = 'Wikižórła';
+ } elseif ( $word == 'Wikicitaty' ) {
+ $word = 'Wikicitatow';
+ } elseif ( $word == 'Wikisłownik' ) {
+ $word = 'Wikisłownika';
+ }
+ break;
+ case 'datiw': # dativ
+ if ( $word == 'Wikipedija' ) {
+ $word = 'Wikipediji';
+ } elseif ( $word == 'Wikiknihi' ) {
+ $word = 'Wikikniham';
+ } elseif ( $word == 'Wikinowiny' ) {
+ $word = 'Wikinowinam';
+ } elseif ( $word == 'Wikižórło' ) {
+ $word = 'Wikižórłu';
+ } elseif ( $word == 'Wikicitaty' ) {
+ $word = 'Wikicitatam';
+ } elseif ( $word == 'Wikisłownik' ) {
+ $word = 'Wikisłownikej';
+ }
+ break;
+ case 'akuzativ': # akuzativ
+ if ( $word == 'Wikipedija' ) {
+ $word = 'Wikipediju';
+ } elseif ( $word == 'Wikiknihi' ) {
+ $word = 'Wikiknknihi';
+ } elseif ( $word == 'Wikinowiny' ) {
+ $word = 'Wikinowiny';
+ } elseif ( $word == 'Wikižórło' ) {
+ $word = 'Wikižórło';
+ } elseif ( $word == 'Wikicitaty' ) {
+ $word = 'Wikicitaty';
+ } elseif ( $word == 'Wikisłownik' ) {
+ $word = 'Wikisłownik';
+ }
+ break;
+ case 'instrumental': # instrumental
+ if ( $word == 'Wikipedija' ) {
+ $word = 'Wikipediju';
+ } elseif ( $word == 'Wikiknihi' ) {
+ $word = 'Wikiknihami';
+ } elseif ( $word == 'Wikinowiny' ) {
+ $word = 'Wikinowinami';
+ } elseif ( $word == 'Wikižórło' ) {
+ $word = 'Wikižórłom';
+ } elseif ( $word == 'Wikicitaty' ) {
+ $word = 'Wikicitatami';
+ } elseif ( $word == 'Wikisłownik' ) {
+ $word = 'Wikisłownikom';
+ } else {
+ $word = 'z ' . $word;
+ }
+ break;
+ case 'lokatiw': # lokatiw
+ if ( $word == 'Wikipedija' ) {
+ $word = 'Wikipediji';
+ } elseif ( $word == 'Wikiknihi' ) {
+ $word = 'Wikiknihach';
+ } elseif ( $word == 'Wikinowiny' ) {
+ $word = 'Wikinowinach';
+ } elseif ( $word == 'Wikižórło' ) {
+ $word = 'Wikižórłu';
+ } elseif ( $word == 'Wikicitaty' ) {
+ $word = 'Wikicitatach';
+ } elseif ( $word == 'Wikisłownik' ) {
+ $word = 'Wikisłowniku';
+ } else {
+ $word = 'wo ' . $word;
+ }
+ break;
+ }
+
+ return $word; # this will return the original value for 'nominatiw' (nominativ) and all undefined case values
+ }
+
+ function convertPlural( $count, $forms ) {
+ if ( !count($forms) ) { return ''; }
+ $forms = $this->preConvertPlural( $forms, 4 );
+
+ switch ( abs( $count ) % 100 ) {
+ case 1: return $forms[0]; // singular
+ case 2: return $forms[1]; // dual
+ case 3:
+ case 4: return $forms[2]; // plural
+ default: return $forms[3]; // pluralgen
+ }
+ }
+}
diff --git a/languages/classes/LanguageFi.php b/languages/classes/LanguageFi.php
index 0d02dfe7..7c1778cc 100644
--- a/languages/classes/LanguageFi.php
+++ b/languages/classes/LanguageFi.php
@@ -139,11 +139,7 @@ class LanguageFi extends Language {
$final .= ' ' . $item;
}
- if ( $forContent ) {
- return htmlspecialchars( trim( $final ) );
- } else {
- return '<span class="blockexpiry" title="' . htmlspecialchars($str). '">”' . trim( $final ) . '”</span>';
- }
+ return htmlspecialchars( trim( $final ) );
}
}
diff --git a/languages/classes/LanguageFr.php b/languages/classes/LanguageFr.php
index 87d28b22..dfd8af4b 100644
--- a/languages/classes/LanguageFr.php
+++ b/languages/classes/LanguageFr.php
@@ -9,8 +9,12 @@ class LanguageFr extends Language {
/**
* Use singular form for zero (see bug 7309)
*/
- function convertPlural( $count, $w1, $w2, $w3, $w4, $w5) {
- return $count <= '1' ? $w1 : $w2;
- }
+ function convertPlural( $count, $forms ) {
+ if ( !count($forms) ) { return ''; }
+ $forms = $this->preConvertPlural( $forms, 2 );
+
+ return ($count <= 1) ? $forms[0] : $forms[1];
+ }
+
}
diff --git a/languages/classes/LanguageHe.php b/languages/classes/LanguageHe.php
index ca760c1a..59b76333 100644
--- a/languages/classes/LanguageHe.php
+++ b/languages/classes/LanguageHe.php
@@ -57,13 +57,16 @@ class LanguageHe extends Language {
*
* @return string of the suited form of word
*/
- public function convertPlural( $count, $w1, $w2, $w3, $w4, $w5) {
+ function convertPlural( $count, $forms ) {
+ if ( !count($forms) ) { return ''; }
+ $forms = $this->preConvertPlural( $forms, 3 );
+
if ( $count == '1' ) {
- return $w1;
- } elseif ( $count == '2' && $w3 ) {
- return $w3;
+ return $forms[0];
+ } elseif ( $count == '2' && isset($forms[2]) ) {
+ return $forms[2];
} else {
- return $w2;
+ return $forms[1];
}
}
}
diff --git a/languages/classes/LanguageHr.php b/languages/classes/LanguageHr.php
index 5a875a71..4a64f879 100644
--- a/languages/classes/LanguageHr.php
+++ b/languages/classes/LanguageHr.php
@@ -5,17 +5,20 @@
*/
class LanguageHr extends Language {
- function convertPlural( $count, $wordform1, $wordform2, $wordform3, $w4, $w5) {
- $count = str_replace ('.', '', $count);
+
+ function convertPlural( $count, $forms ) {
+ if ( !count($forms) ) { return ''; }
+ $forms = $this->preConvertPlural( $forms, 3 );
+
if ($count > 10 && floor(($count % 100) / 10) == 1) {
- return $wordform3;
+ return $forms[2];
} else {
switch ($count % 10) {
- case 1: return $wordform1;
+ case 1: return $forms[0];
case 2:
case 3:
- case 4: return $wordform2;
- default: return $wordform3;
+ case 4: return $forms[1];
+ default: return $forms[2];
}
}
}
diff --git a/languages/classes/LanguageHsb.php b/languages/classes/LanguageHsb.php
index 7cbc17de..68df96be 100644
--- a/languages/classes/LanguageHsb.php
+++ b/languages/classes/LanguageHsb.php
@@ -100,17 +100,16 @@ class LanguageHsb extends Language {
return $word; # this will return the original value for 'nominatiw' (nominativ) and all undefined case values
}
- function convertPlural( $count, $singular, $dual, $plural, $pluralgen, $w5 ) {
+ function convertPlural( $count, $forms ) {
+ if ( !count($forms) ) { return ''; }
+ $forms = $this->preConvertPlural( $forms, 4 );
+
switch ( abs( $count ) % 100 ) {
- case 1:
- return $singular;
- case 2:
- return $dual;
+ case 1: return $forms[0]; // singular
+ case 2: return $forms[1]; // dual
case 3:
- case 4:
- return $plural;
- default:
- return $pluralgen;
+ case 4: return $forms[2]; // plural
+ default: return $forms[3]; // pluralgen
}
}
}
diff --git a/languages/classes/LanguageHy.php b/languages/classes/LanguageHy.php
index 34fb6c74..cc3492be 100644
--- a/languages/classes/LanguageHy.php
+++ b/languages/classes/LanguageHy.php
@@ -49,13 +49,11 @@ class LanguageHy extends Language {
return $word;
}
- function convertPlural( $count, $wordform1, $wordform2) {
- $count = str_replace (' ', '', $count);
- if (abs($count) <= 1) {
- return $wordform1;
- } else {
- return $wordform2;
- }
+ function convertPlural( $count, $forms ) {
+ if ( !count($forms) ) { return ''; }
+ $forms = $this->preConvertPlural( $forms, 2 );
+
+ return (abs($count) <= 1) ? $forms[0] : $forms[1];
}
/*
diff --git a/languages/classes/LanguageKaa.php b/languages/classes/LanguageKaa.php
new file mode 100644
index 00000000..4a451dcc
--- /dev/null
+++ b/languages/classes/LanguageKaa.php
@@ -0,0 +1,43 @@
+<?php
+/** Karakalpak (Qaraqalpaqsha)
+ *
+ *
+ * @addtogroup Language
+ */
+
+class LanguageKaa extends Language {
+
+ # Convert from the nominative form of a noun to some other case
+ # Invoked with {{GRAMMAR:case|word}}
+ /**
+ * Cases: genitive, dative, accusative, locative, ablative, comitative + possessive forms
+ */
+ function convertGrammar( $word, $case ) {
+ global $wgGrammarForms;
+ if ( isset( $wgGrammarForms['kaa'][$case][$word] ) ) {
+ return $wgGrammarForms['kaa'][$case][$word];
+ }
+ /* Full code of function convertGrammar() is in development. Updates coming soon. */
+ return $word;
+ }
+
+ function ucfirst ( $string ) {
+ if ( $string[0] == 'i' ) {
+ return 'İ' . substr( $string, 1 );
+ } else {
+ return parent::ucfirst( $string );
+ }
+ }
+
+ /**
+ * Avoid grouping whole numbers between 0 to 9999
+ */
+ function commafy( $_ ) {
+ if ( !preg_match( '/^\d{1,4}$/', $_ ) ) {
+ return strrev( (string)preg_replace( '/(\d{3})(?=\d)(?!\d*\.)/', '$1,', strrev($_) ) );
+ } else {
+ return $_;
+ }
+ }
+
+} \ No newline at end of file
diff --git a/languages/classes/LanguageKk.deps.php b/languages/classes/LanguageKk.deps.php
index 336692a2..2b96de96 100644
--- a/languages/classes/LanguageKk.deps.php
+++ b/languages/classes/LanguageKk.deps.php
@@ -7,6 +7,5 @@
require_once( dirname(__FILE__).'/../LanguageConverter.php' );
-require_once( dirname(__FILE__).'/LanguageKk_kz.php' );
-
+require_once( dirname(__FILE__).'/LanguageKk_cyrl.php' );
diff --git a/languages/classes/LanguageKk.php b/languages/classes/LanguageKk.php
index 68775b3a..cf90e96e 100644
--- a/languages/classes/LanguageKk.php
+++ b/languages/classes/LanguageKk.php
@@ -6,105 +6,196 @@
*/
require_once( dirname(__FILE__).'/../LanguageConverter.php' );
-require_once( dirname(__FILE__).'/LanguageKk_kz.php' );
+require_once( dirname(__FILE__).'/LanguageKk_cyrl.php' );
+
+define( 'KK_C_UC', 'АӘБВГҒДЕЁЖЗИЙКҚЛМНҢОӨПРСТУҰҮФХҺЦЧШЩЪЫІЬЭЮЯ' ); # Kazakh Cyrillic uppercase
+define( 'KK_C_LC', 'аәбвгғдеёжзийкқлмнңоөпрстуұүфхһцчшщъыіьэюя' ); # Kazakh Cyrillic lowercase
+define( 'KK_L_UC', 'AÄBCÇDEÉFGĞHIİÏJKLMNÑOÖPQRSŞTUÜVWXYÝZ' ); # Kazakh Latin uppercase
+define( 'KK_L_LC', 'aäbcçdeéfgğhıiïjklmnñoöpqrsştuüvwxyýz' ); # Kazakh Latin lowercase
+//define( 'KK_A', 'ٴابپتجحدرزسشعفقكلمنڭەوۇۋۆىيچھ' ); # Kazakh Arabic
+define( 'H_HAMZA', 'ٴ' ); # U+0674 ARABIC LETTER HIGH HAMZA
+//define( 'ZWNJ', '‌' ); # U+200C ZERO WIDTH NON-JOINER
class KkConverter extends LanguageConverter {
- var $mLatinToCyrillic = array(
- 'YA' => 'Я', 'Ya' => 'Я', 'ya' => 'я', 'YE' => 'Е', 'Ye' => 'У', 'ye' => 'е',
- 'YO' => 'Ё', 'Yo' => 'Ё', 'yo' => 'ё', 'YU' => 'Ю', 'Yu' => 'Ю', 'yu' => 'ю',
- 'YW' => 'Ю', 'Yw' => 'Ю', 'yw' => 'ю',
-
- 'bʺ' => 'бъ', 'dʺ' => 'дъ', 'fʺ' => 'фъ', 'gʺ' => 'гъ', 'kʺ' => 'къ', 'lʺ' => 'лъ',
- 'mʺ' => 'мъ', 'nʺ' => 'нъ', 'pʺ' => 'пъ', 'rʺ' => 'ръ', 'sʺ' => 'съ', 'tʺ' => 'тъ',
- 'vʺ' => 'въ', 'zʺ' => 'зъ',
- /* 'jʺ' => 'жъ', 'cʺ' => 'цъ', 'çʺ' => 'чъ', 'şʺ' => 'шъ', */
-
- 'ŞÇʹ'=> 'ЩЬ', 'Şçʹ'=> 'Щь', 'Bʺ' => 'БЪ', 'Dʺ' => 'ДЪ', 'Fʺ' => 'ФЪ', 'Gʺ' => 'ГЪ', 'Kʺ' => 'КЪ', 'Lʺ' => 'ЛЪ',
- 'Mʺ' => 'МЪ', 'Nʺ' => 'НЪ', 'Pʺ' => 'ПЪ', 'Rʺ' => 'РЪ', 'Sʺ' => 'СЪ', 'Tʺ' => 'ТЪ',
- 'Vʺ' => 'ВЪ', 'Zʺ' => 'ЗЪ',
- /* 'Jʺ' => 'ЖЪ', 'Cʺ' => 'ЦЪ', 'Çʺ' => 'ЧЪ', 'Şʺ' => 'ШЪ', */
-
- 'şçʹ'=> 'щь', 'bʹ' => 'бь', 'dʹ' => 'дь', 'fʹ' => 'фь', 'gʹ' => 'гь', 'kʹ' => 'кь', 'lʹ' => 'ль',
- 'mʹ' => 'мь', 'nʹ' => 'нь', 'pʹ' => 'пь', 'rʹ' => 'рь', 'sʹ' => 'сь', 'tʹ' => 'ть',
- 'vʹ' => 'вь', 'zʹ' => 'зь', 'jʹ' => 'жь', 'cʹ' => 'ць', 'çʹ' => 'чь', 'şʹ' => 'шь',
-
- 'Bʹ' => 'БЬ', 'Dʹ' => 'ДЬ', 'Fʹ' => 'ФЬ', 'Gʹ' => 'ГЬ', 'Kʹ' => 'КЬ', 'Lʹ' => 'ЛЬ',
- 'Mʹ' => 'МЬ', 'Nʹ' => 'НЬ', 'Pʹ' => 'ПЬ', 'Rʹ' => 'РЬ', 'Sʹ' => 'СЬ', 'Tʹ' => 'ТЬ',
- 'Vʹ' => 'ВЬ', 'Zʹ' => 'ЗЬ', 'Jʹ' => 'ЖЬ', 'Cʹ' => 'ЦЬ', 'Çʹ' => 'ЧЬ', 'Şʹ' => 'ШЬ',
-
- 'ŞÇ' => 'Щ', 'Şç' => 'Щ', 'şç' => 'щ',
-
- 'a' => 'а', 'ä' => 'ә', 'b' => 'б', 'c' => 'ц', 'ç' => 'ч', 'd' => 'д', 'e' => 'е',
- 'é' => 'э', 'f' => 'ф', 'g' => 'г', 'ğ' => 'ғ', 'h' => 'һ', 'i' => 'і', 'ı' => 'ы',
- 'ï' => 'и', 'j' => 'ж', 'k' => 'к', 'l' => 'л', 'm' => 'м', 'n' => 'н', 'ñ' => 'ң',
- 'o' => 'о', 'ö' => 'ө', 'p' => 'п', 'q' => 'қ', 'r' => 'р', 's' => 'с', 'ş' => 'ш',
- 't' => 'т', 'u' => 'ұ', 'ü' => 'ү', 'v' => 'в', 'w' => 'у', 'x' => 'х', 'ý' => 'й',
- 'z' => 'з',
-
- 'A' => 'А', 'Ä' => 'Ә', 'B' => 'Б', 'C' => 'Ц', 'Ç' => 'Ч', 'D' => 'Д', 'E' => 'Е',
- 'É' => 'Э', 'F' => 'Ф', 'G' => 'Г', 'Ğ' => 'Ғ', 'H' => 'Һ', 'İ' => 'І', 'I' => 'Ы',
- 'Ï' => 'И', 'J' => 'Ж', 'K' => 'К', 'L' => 'Л', 'M' => 'М', 'N' => 'Н', 'Ñ' => 'Ң',
- 'O' => 'О', 'Ö' => 'Ө', 'P' => 'П', 'Q' => 'Қ', 'R' => 'Р', 'S' => 'С', 'Ş' => 'Ш',
- 'T' => 'Т', 'U' => 'Ұ', 'Ü' => 'Ү', 'V' => 'В', 'W' => 'У', 'Ý' => 'Й', 'X' => 'Х',
- 'Z' => 'З'
- );
-
- var $mCyrillicToLatin = array(
- 'а' => 'a', 'ә' => 'ä', 'б' => 'b', 'в' => 'v', 'г' => 'g', 'ғ' => 'ğ',
- 'д' => 'd', 'е' => 'e', 'ё' => 'yo', 'ж' => 'j', 'з' => 'z', 'и' => 'ï',
- 'й' => 'ý', 'к' => 'k', 'қ' => 'q', 'л' => 'l', 'м' => 'm', 'н' => 'n',
- 'ң' => 'ñ', 'о' => 'o', 'ө' => 'ö', 'п' => 'p', 'р' => 'r', 'с' => 's',
- 'т' => 't', 'у' => 'w', 'ұ' => 'u', 'ү' => 'ü', 'ф' => 'f', 'х' => 'x',
- 'һ' => 'h', 'ц' => 'c', 'ч' => 'ç', 'ш' => 'ş', 'щ' => 'şç', 'ъ' => 'ʺ',
- 'ы' => 'ı', 'ь' => 'ʹ', 'і' => 'i', 'э' => 'é', 'ю' => 'yw', 'я' => 'ya',
-
- 'А' => 'A', 'Ә' => 'Ä', 'Б' => 'B', 'В' => 'V', 'Г' => 'G', 'Ғ' => 'Ğ',
- 'Д' => 'D', 'Е' => 'E', 'Ё' => 'Yo', 'Ж' => 'J', 'З' => 'Z', 'И' => 'Ï',
- 'Й' => 'Ý', 'К' => 'K', 'Қ' => 'Q', 'Л' => 'L', 'М' => 'M', 'Н' => 'N',
- 'Ң' => 'Ñ', 'О' => 'O', 'Ө' => 'Ö', 'П' => 'P', 'Р' => 'R', 'С' => 'S',
- 'Т' => 'T', 'У' => 'W', 'Ұ' => 'U', 'Ү' => 'Ü', 'Ф' => 'F', 'Х' => 'X',
- 'Һ' => 'H', 'Ц' => 'C', 'Ч' => 'Ç', 'Ш' => 'Ş', 'Щ' => 'Şç', 'Ъ' => 'ʺ',
- 'Ы' => 'I', 'Ь' => 'ʹ', 'І' => 'İ', 'Э' => 'É', 'Ю' => 'Yw', 'Я' => 'Ya'
- );
-
- var $mCyrillicToArabic = array(
- 'ла' => 'لا', 'лА' => 'لا', 'ЛА' => 'لا', 'Ла' => 'لا',
-
- 'а' => 'ا', 'ә' => 'ٵ', 'б' => 'ب', 'в' => 'ۆ', 'г' => 'گ', 'ғ' => 'ع',
- 'д' => 'د', 'е' => 'ە', 'ё' => 'يو', 'ж' => 'ج', 'з' => 'ز', 'и' => 'ي',
- 'й' => 'ي', 'к' => 'ك', 'қ' => 'ق', 'л' => 'ل', 'м' => 'م', 'н' => 'ن',
- 'ң' => 'ڭ', 'о' => 'و', 'ө' => 'ٶ', 'п' => 'پ', 'р' => 'ر', 'с' => 'س',
- 'т' => 'ت', 'у' => 'ۋ', 'ұ' => 'ۇ', 'ү' => 'ٷ', 'ф' => 'ف', 'х' => 'ح',
- 'һ' => 'ھ', 'ц' => 'تس', 'ч' => 'چ', 'ш' => 'ش', 'щ' => 'شش', 'ъ' => 'ي',
- 'ы' => 'ى', 'ь' => 'ي', 'і' => 'ٸ', 'э' => 'ە', 'ю' => 'يۋ', 'я' => 'يا',
-
- 'А' => 'ا', 'Ә' => 'ٵ', 'Б' => 'ب', 'В' => 'ۆ', 'Г' => 'گ', 'Ғ' => 'ع',
- 'Д' => 'د', 'Е' => 'ە', 'Ё' => 'يو', 'Ж' => 'ج', 'З' => 'ز', 'И' => 'ي',
- 'Й' => 'ي', 'К' => 'ك', 'Қ' => 'ق', 'Л' => 'ل', 'М' => 'م', 'Н' => 'ن',
- 'Ң' => 'ڭ', 'О' => 'و', 'Ө' => 'ٶ', 'П' => 'پ', 'Р' => 'ر', 'С' => 'س',
- 'Т' => 'ت', 'У' => 'ۋ', 'Ұ' => 'ۇ', 'Ү' => 'ٷ', 'Ф' => 'ف', 'Х' => 'ح',
- 'Һ' => 'ھ', 'Ц' => 'تس', 'Ч' => 'چ', 'Ш' => 'ش', 'Щ' => 'شش', 'Ъ' => 'ي',
- 'Ы' => 'ى', 'Ь' => 'ي', 'І' => 'ٸ', 'Э' => 'ە', 'Ю' => 'يۋ', 'Я' => 'يا',
-
- '?' => '؟',
- '%' => '٪',
- ',' => '،',
- ';' => '؛'
- );
+
+ function __construct($langobj, $maincode,
+ $variants=array(),
+ $variantfallbacks=array(),
+ $markup=array(),
+ $flags = array()) {
+ parent::__construct( $langobj, $maincode,
+ $variants, $variantfallbacks, $markup, $flags );
+
+ // No point delaying this since they're in code.
+ // Waiting until loadDefaultTables() means they never get loaded
+ // when the tables themselves are loaded from cache.
+ $this->loadRegs();
+ }
function loadDefaultTables() {
+ // require( dirname(__FILE__)."/../../includes/KkConversion.php" );
+ // Placeholder for future implementing. Remove variables declarations
+ // after generating KkConversion.php
+ $kk2Cyrl = array();
+ $kk2Latn = array();
+ $kk2Arab = array();
+ $kk2KZ = array();
+ $kk2TR = array();
+ $kk2CN = array();
+
$this->mTables = array(
- 'kk-kz' => new ReplacementArray( $this->mLatinToCyrillic ),
- 'kk-tr' => new ReplacementArray( $this->mCyrillicToLatin ),
- 'kk-cn' => new ReplacementArray( $this->mCyrillicToArabic ),
- 'kk' => new ReplacementArray()
+ 'kk-cyrl' => 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' => new ReplacementArray()
);
}
+ function postLoadTables() {
+ $this->mTables['kk-kz']->merge( $this->mTables['kk-cyrl'] );
+ $this->mTables['kk-tr']->merge( $this->mTables['kk-latn'] );
+ $this->mTables['kk-cn']->merge( $this->mTables['kk-arab'] );
+ }
+
+ function loadRegs() {
+
+ $this->mCyrl2Latn = array(
+ ## Punctuation
+ '/№/u' => 'No.',
+ ## Е 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 ЁЮЯ
+ '/Ё/u' => 'YO', '/ё/u' => 'yo',
+ '/Ю/u' => 'YU', '/ю/u' => 'yu',
+ '/Я/u' => 'YA', '/я/u' => 'ya',
+ '/Щ/u' => 'ŞÇ', '/щ/u' => 'şç',
+ ## soft and hard signs
+ '/[ъЪ]/u' => 'ʺ', '/[ьЬ]/u' => 'ʹ',
+ ## other characters
+ '/А/u' => 'A', '/а/u' => 'a', '/Ә/u' => 'Ä', '/ә/u' => 'ä',
+ '/Б/u' => 'B', '/б/u' => 'b', '/В/u' => 'V', '/в/u' => 'v',
+ '/Г/u' => 'G', '/г/u' => 'g', '/Ғ/u' => 'Ğ', '/ғ/u' => 'ğ',
+ '/Д/u' => 'D', '/д/u' => 'd', '/Е/u' => 'E', '/е/u' => 'e',
+ '/Ж/u' => 'J', '/ж/u' => 'j', '/З/u' => 'Z', '/з/u' => 'z',
+ '/И/u' => 'Ï', '/и/u' => 'ï', '/Й/u' => 'Ý', '/й/u' => 'ý',
+ '/К/u' => 'K', '/к/u' => 'k', '/Қ/u' => 'Q', '/қ/u' => 'q',
+ '/Л/u' => 'L', '/л/u' => 'l', '/М/u' => 'M', '/м/u' => 'm',
+ '/Н/u' => 'N', '/н/u' => 'n', '/Ң/u' => 'Ñ', '/ң/u' => 'ñ',
+ '/О/u' => 'O', '/о/u' => 'o', '/Ө/u' => 'Ö', '/ө/u' => 'ö',
+ '/П/u' => 'P', '/п/u' => 'p', '/Р/u' => 'R', '/р/u' => 'r',
+ '/С/u' => 'S', '/с/u' => 's', '/Т/u' => 'T', '/т/u' => 't',
+ '/У/u' => 'W', '/у/u' => 'w', '/Ұ/u' => 'U', '/ұ/u' => 'u',
+ '/Ү/u' => 'Ü', '/ү/u' => 'ü', '/Ф/u' => 'F', '/ф/u' => 'f',
+ '/Х/u' => 'X', '/х/u' => 'x', '/Һ/u' => 'H', '/һ/u' => 'h',
+ '/Ц/u' => 'C', '/ц/u' => 'c', '/Ч/u' => 'Ç', '/ч/u' => 'ç',
+ '/Ш/u' => 'Ş', '/ш/u' => 'ş', '/Ы/u' => 'I', '/ы/u' => 'ı',
+ '/І/u' => 'İ', '/і/u' => 'i', '/Э/u' => 'É', '/э/u' => 'é',
+ );
+
+ $this->mLatn2Cyrl = array(
+ ## Punctuation
+ '/#|No\./' => '№',
+ ## Şç
+ '/ŞÇʹ/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',
+ '/ʺ/u' => 'ъ',
+ '/ʹ/u' => 'ь',
+ ## Ye Yo Yu Ya.
+ '/Y[Ee]/u' => 'Е', '/ye/u' => 'е',
+ '/Y[Oo]/u' => 'Ё', '/yo/u' => 'ё',
+ '/Y[UWuw]/u' => 'Ю', '/y[uw]/u' => 'ю',
+ '/Y[Aa]/u' => 'Я', '/ya/u' => 'я',
+ ## other characters
+ '/A/u' => 'А', '/a/u' => 'а', '/Ä/u' => 'Ә', '/ä/u' => 'ә',
+ '/B/u' => 'Б', '/b/u' => 'б', '/C/u' => 'Ц', '/c/u' => 'ц',
+ '/Ç/u' => 'Ч', '/ç/u' => 'ч', '/D/u' => 'Д', '/d/u' => 'д',
+ '/E/u' => 'Е', '/e/u' => 'е', '/É/u' => 'Э', '/é/u' => 'э',
+ '/F/u' => 'Ф', '/f/u' => 'ф', '/G/u' => 'Г', '/g/u' => 'г',
+ '/Ğ/u' => 'Ғ', '/ğ/u' => 'ғ', '/H/u' => 'Һ', '/h/u' => 'һ',
+ '/I/u' => 'Ы', '/ı/u' => 'ы', '/İ/u' => 'І', '/i/u' => 'і',
+ '/Ï/u' => 'И', '/ï/u' => 'и', '/J/u' => 'Ж', '/j/u' => 'ж',
+ '/K/u' => 'К', '/k/u' => 'к', '/L/u' => 'Л', '/l/u' => 'л',
+ '/M/u' => 'М', '/m/u' => 'м', '/N/u' => 'Н', '/n/u' => 'н',
+ '/Ñ/u' => 'Ң', '/ñ/u' => 'ң', '/O/u' => 'О', '/o/u' => 'о',
+ '/Ö/u' => 'Ө', '/ö/u' => 'ө', '/P/u' => 'П', '/p/u' => 'п',
+ '/Q/u' => 'Қ', '/q/u' => 'қ', '/R/u' => 'Р', '/r/u' => 'р',
+ '/S/u' => 'С', '/s/u' => 'с', '/Ş/u' => 'Ш', '/ş/u' => 'ш',
+ '/T/u' => 'Т', '/t/u' => 'т', '/U/u' => 'Ұ', '/u/u' => 'ұ',
+ '/Ü/u' => 'Ү', '/ü/u' => 'ү', '/V/u' => 'В', '/v/u' => 'в',
+ '/W/u' => 'У', '/w/u' => 'у', '/Ý/u' => 'Й', '/ý/u' => 'й',
+ '/X/u' => 'Х', '/x/u' => 'х', '/Z/u' => 'З', '/z/u' => 'з',
+ );
+
+ $this->mCyLa2Arab = array(
+ ## Punctuation -> Arabic
+ '/#|№|No\./u' => '؀', # &#x0600;
+ '/\,/' => '،', # &#x060C;
+ '/;/' => '؛', # &#x061B;
+ '/\?/' => '؟', # &#x061F;
+ '/%/' => '٪', # &#x066A;
+ '/\*/' => '٭', # &#x066D;
+ ## Digits -> Arabic
+ '/0/' => '۰', # &#x06F0;
+ '/1/' => '۱', # &#x06F1;
+ '/2/' => '۲', # &#x06F2;
+ '/3/' => '۳', # &#x06F3;
+ '/4/' => '۴', # &#x06F4;
+ '/5/' => '۵', # &#x06F5;
+ '/6/' => '۶', # &#x06F6;
+ '/7/' => '۷', # &#x06F7;
+ '/8/' => '۸', # &#x06F8;
+ '/9/' => '۹', # &#x06F9;
+ ## Cyrillic -> Arabic
+ '/Аллаһ/ui' => 'ﷲ',
+ '/([АӘЕЁИОӨҰҮЭЮЯЪЬ])е/ui' => '$1يە',
+ '/[еэ]/ui' => 'ە', '/[ъь]/ui' => '',
+ '/[аә]/ui' => 'ا', '/[оө]/ui' => 'و', '/[ұү]/ui' => 'ۇ', '/[ыі]/ui' => 'ى',
+ '/[и]/ui' => 'ىي', '/ё/ui' => 'يو', '/ю/ui' => 'يۋ', '/я/ui' => 'يا', '/[й]/ui' => 'ي',
+ '/ц/ui' => 'تس', '/щ/ui' => 'شش',
+ '/һ/ui' => 'ح', '/ч/ui' => 'تش',
+ #'/һ/ui' => 'ھ', '/ч/ui' => 'چ',
+ '/б/ui' => 'ب', '/в/ui' => 'ۆ', '/г/ui' => 'گ', '/ғ/ui' => 'ع',
+ '/д/ui' => 'د', '/ж/ui' => 'ج', '/з/ui' => 'ز', '/к/ui' => 'ك',
+ '/қ/ui' => 'ق', '/л/ui' => 'ل', '/м/ui' => 'م', '/н/ui' => 'ن',
+ '/ң/ui' => 'ڭ', '/п/ui' => 'پ', '/р/ui' => 'ر', '/с/ui' => 'س',
+ '/т/ui' => 'ت', '/у/ui' => 'ۋ', '/ф/ui' => 'ف', '/х/ui' => 'ح',
+ '/ш/ui' => 'ش',
+ ## Latin -> Arabic // commented for now...
+ /*'/Allah/ui' => 'ﷲ',
+ '/[eé]/ui' => 'ە', '/[yý]/ui' => 'ي', '/[ʺʹ]/ui' => '',
+ '/[aä]/ui' => 'ا', '/[oö]/ui' => 'و', '/[uü]/ui' => 'ۇ',
+ '/[ï]/ui' => 'ىي', '/[ıIiİ]/u' => 'ى',
+ '/c/ui' => 'تس',
+ '/ç/ui' => 'تش', '/h/ui' => 'ح',
+ #'/ç/ui' => 'چ', '/h/ui' => 'ھ',
+ '/b/ui' => 'ب','/d/ui' => 'د',
+ '/f/ui' => 'ف', '/g/ui' => 'گ', '/ğ/ui' => 'ع',
+ '/j/ui' => 'ج', '/k/ui' => 'ك', '/l/ui' => 'ل', '/m/ui' => 'م',
+ '/n/ui' => 'ن', '/ñ/ui' => 'ڭ', '/p/ui' => 'پ', '/q/ui' => 'ق',
+ '/r/ui' => 'ر', '/s/ui' => 'س', '/ş/ui' => 'ش', '/t/ui' => 'ت',
+ '/v/ui' => 'ۆ', '/w/ui' => 'ۋ', '/x/ui' => 'ح', '/z/ui' => 'ز',*/
+ );
+
+ }
+
/* rules should be defined as -{ekavian | iyekavian-} -or-
-{code:text | code:text | ...}-
update: delete all rule parsing because it's not used
- currently, and just produces a couple of bugs
+ currently, and just produces a couple of bugs
*/
function parseManualRule($rule, $flags=array()) {
if(in_array('T',$flags)){
@@ -131,9 +222,9 @@ class KkConverter extends LanguageConverter {
/*
* A function wrapper:
- * - if there is no selected variant, leave the link
- * names as they were
- * - do not try to find variants for usernames
+ * - if there is no selected variant, leave the link
+ * names as they were
+ * - do not try to find variants for usernames
*/
function findVariantLink( &$link, &$nt ) {
// check for user namespace
@@ -150,16 +241,6 @@ 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))
- return parent::markNoConversion($text);
- return $text;
- }
-
- /*
* An ugly function wrapper for parsing Image titles
* (to prevent image name conversion)
*/
@@ -173,71 +254,204 @@ class KkConverter extends LanguageConverter {
}
/**
- * It translates text into variant, specials:
- * - ommiting roman numbers
+ * It translates text into variant
*/
- 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.'/';
-
- $matches = preg_split($reg, $text, -1, PREG_SPLIT_OFFSET_CAPTURE);
-
- $m = array_shift($matches);
- if( !isset( $this->mTables[$toVariant] ) ) {
- throw new MWException( "Broken variant table: " . implode( ',', array_keys( $this->mTables ) ) );
+ function translate( $text, $toVariant ){
+ global $wgContLanguageCode;
+ $text = parent::translate( $text, $toVariant );
+
+ $letters = '';
+ switch( $toVariant ) {
+ case 'kk-cyrl':
+ case 'kk-kz':
+ $letters = KK_L_UC . KK_L_LC . 'ʺʹ#0123456789';
+ $wgContLanguageCode = 'kk';
+ break;
+ case 'kk-latn':
+ case 'kk-tr':
+ $letters = KK_C_UC . KK_C_LC . '№0123456789';
+ $wgContLanguageCode = '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';
+ break;
+ default:
+ $wgContLanguageCode = 'kk';
+ return $text;
}
- $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);
+ // disable conversion variables like $1, $2...
+ $varsfix = '\$[0-9]';
+
+ $matches = preg_split( '/' . $varsfix . '[^' . $letters . ']+/u', $text, -1, PREG_SPLIT_OFFSET_CAPTURE);
+ $mstart = 0;
+ $ret = '';
+ foreach( $matches as $m ) {
+ $ret .= substr( $text, $mstart, $m[1]-$mstart );
+ $ret .= $this->regsConverter( $m[0], $toVariant );
$mstart = $m[1] + strlen($m[0]);
}
-
return $ret;
}
+ function regsConverter( $text, $toVariant ) {
+ if ($text == '') return $text;
+
+ $pat = array();
+ $rep = array();
+ switch( $toVariant ) {
+ case 'kk-arab':
+ case 'kk-cn':
+ $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);
+ $mstart = 0;
+ $ret = '';
+ foreach( $matches as $m ) {
+ $ret .= substr( $text, $mstart, $m[1] - $mstart );
+ // is matched the word to front vowels?
+ // exclude a words matched to е, э, г, к, к, қ,
+ // them should be without hamza
+ if ( preg_match('/['.$front.']/u', $m[0]) && !preg_match('/['.$excludes.']/u', $m[0]) ) {
+ $ret .= preg_replace('/['.$letters.']+/u', H_HAMZA.'$0', $m[0]);
+ } else {
+ $ret .= $m[0];
+ }
+ $mstart = $m[1] + strlen($m[0]);
+ }
+ $text =& $ret;
+ foreach( $this->mCyLa2Arab as $pat => $rep ) {
+ $text = preg_replace( $pat, $rep, $text );
+ }
+ return $text;
+ break;
+ case 'kk-latn':
+ case 'kk-tr':
+ 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 ) {
+ $text = preg_replace( $pat, $rep, $text );
+ }
+ return $text;
+ break;
+ default:
+ return $text;
+ }
+ }
+
+ /*
+ * We want our external link captions to be converted in variants,
+ * so we return the original text instead -{$text}-, except for URLs
+ */
+ function markNoConversion( $text, $noParse=false ) {
+ if( $noParse || preg_match( "/^https?:\/\/|ftp:\/\/|irc:\/\//", $text ) )
+ return parent::markNoConversion( $text );
+ return $text;
+ }
+
+ function convertCategoryKey( $key ) {
+ return $this->autoConvert( $key, 'kk' );
+ }
+
}
-class LanguageKk extends LanguageKk_kz {
+/* class that handles Cyrillic, Latin and Arabic scripts for Kazakh
+ right now it only distinguish kk_cyrl, kk_latn, kk_arab and kk_kz, kk_tr, kk_cn.
+*/
+class LanguageKk extends LanguageKk_cyrl {
function __construct() {
global $wgHooks;
parent::__construct();
- $variants = array( 'kk', 'kk-kz', 'kk-tr', 'kk-cn' );
+ $variants = array( 'kk', 'kk-cyrl', 'kk-latn', 'kk-arab', 'kk-kz', 'kk-tr', 'kk-cn' );
$variantfallbacks = array(
- 'kk' => 'kk-kz',
- 'kk-kz' => 'kk',
- 'kk-tr' => 'kk',
- 'kk-cn' => 'kk'
+ 'kk' => 'kk-kz',
+ 'kk-cyrl' => 'kk',
+ 'kk-latn' => 'kk',
+ 'kk-arab' => 'kk',
+ 'kk-kz' => 'kk-cyrl',
+ 'kk-tr' => 'kk-latn',
+ 'kk-cn' => 'kk-arab'
);
$this->mConverter = new KkConverter( $this, 'kk', $variants, $variantfallbacks );
+
$wgHooks['ArticleSaveComplete'][] = $this->mConverter;
}
+ /**
+ * Work around for right-to-left direction support in kk-arab and kk-cn
+ *
+ * @return bool
+ */
+ function isRTL() {
+ $variant = $this->getPreferredVariant();
+ if ( $variant == 'kk-arab' || $variant == 'kk-cn' ) {
+ return true;
+ } else {
+ return parent::isRTL();
+ }
+ }
+
+ /*
+ * It fixes issue with ucfirst for transforming 'i' to 'İ'
+ *
+ */
+ function ucfirst ( $string ) {
+ $variant = $this->getPreferredVariant();
+ if ( ($variant == 'kk-latn' || $variant == 'kk-tr') && $string[0] == 'i' ) {
+ $string = 'İ' . substr( $string, 1 );
+ } else {
+ $string = parent::ucfirst( $string );
+ }
+ return $string;
+ }
+
+ /*
+ * It fixes issue with lcfirst for transforming 'I' to 'ı'
+ *
+ */
+ function lcfirst ( $string ) {
+ $variant = $this->getPreferredVariant();
+ if ( ($variant == 'kk-latn' || $variant == 'kk-tr') && $string[0] == 'I' ) {
+ $string = 'ı' . substr( $string, 1 );
+ } else {
+ $string = parent::lcfirst( $string );
+ }
+ return $string;
+ }
+
function convertGrammar( $word, $case ) {
- $fname="LanguageKk::convertGrammar";
- wfProfileIn( $fname );
-
- //always convert to kk-kz before convertGrammar
- $w1 = $word;
- $word = $this->mConverter->autoConvert( $word, 'kk-kz' );
- $w2 = $word;
- $word = parent::convertGrammar( $word, $case );
- //restore encoding
- if( $w1 != $w2 ) {
- $word = $this->mConverter->translate( $word, 'kk-tr' );
+ wfProfileIn( __METHOD__ );
+
+ $variant = $this->getPreferredVariant();
+ switch ( $variant ) {
+ case 'kk-arab':
+ case 'kk-cn':
+ $word = parent::convertGrammarKk_arab( $word, $case );
+ break;
+ case 'kk-latn':
+ case 'kk-tr':
+ $word = parent::convertGrammarKk_latn( $word, $case );
+ break;
+ case 'kk-cyrl':
+ case 'kk-kz':
+ case 'kk':
+ default:
+ $word = parent::convertGrammarKk_cyrl( $word, $case );
}
- wfProfileOut( $fname );
+
+ wfProfileOut( __METHOD__ );
return $word;
}
}
-
-
diff --git a/languages/classes/LanguageKk_cyrl.php b/languages/classes/LanguageKk_cyrl.php
new file mode 100644
index 00000000..a7f07573
--- /dev/null
+++ b/languages/classes/LanguageKk_cyrl.php
@@ -0,0 +1,722 @@
+<?php
+/** Kazakh (Қазақша)
+ *
+ *
+ * @addtogroup Language
+ */
+
+
+class LanguageKk_cyrl extends Language {
+
+ # Convert from the nominative form of a noun to some other case
+ # Invoked with {{GRAMMAR:case|word}}
+ /**
+ * Cases: genitive, dative, accusative, locative, ablative, comitative + possessive forms
+ */
+
+ function convertGrammarKk_cyrl( $word, $case ) {
+ global $wgGrammarForms;
+ if ( isset( $wgGrammarForms['kk-kz'][$case][$word] ) ) {
+ return $wgGrammarForms['kk-kz'][$case][$word];
+ }
+ if ( isset( $wgGrammarForms['kk-cyrl'][$case][$word] ) ) {
+ return $wgGrammarForms['kk-cyrl'][$case][$word];
+ }
+ // Set up some constants...
+ // Vowels in last syllable
+ $frontVowels = array( "е", "ө", "ү", "і", "ә", "э", "я", "ё", "и" );
+ $backVowels = array( "а", "о", "ұ", "ы" );
+ $allVowels = array( "е", "ө", "ү", "і", "ә", "э", "а", "о", "ұ", "ы", "я", "ё", "и" );
+ // Preceding letters
+ $Nasals = array( "м", "н", "ң" );
+ $Sonants = array( "и", "й", "л", "р", "у", "ю");
+ $Consonants = array( "п", "ф", "к", "қ", "т", "ш", "с", "х", "ц", "ч", "щ", "б", "в", "г", "д" );
+ $Sibilants = array( "ж", "з" );
+ $Sonorants = array( "и", "й", "л", "р", "у", "ю", "м", "н", "ң", "ж", "з");
+
+ // Possessives
+ $firstPerson = array( "м", "ң" ); // 1st singular, 2nd unformal
+ $secondPerson = array( "з" ); // 1st plural, 2nd formal
+ $thirdPerson = array( "ы", "і" ); // 3rd
+
+ $lastLetter = self::lastLetter( $word, $allVowels );
+ $wordEnding =& $lastLetter[0];
+ $wordLastVowel =& $lastLetter[1];
+
+ // Now convert the word
+ switch ( $case ) {
+ case "dc1":
+ case "genitive": #ilik
+ if ( in_array( $wordEnding, $Consonants ) ) {
+ if ( in_array( $wordLastVowel, $frontVowels ) ) {
+ $word = $word . "тің";
+ } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
+ $word = $word . "тың";
+ }
+ } elseif ( in_array( $wordEnding, $allVowels ) || in_array( $wordEnding, $Nasals ) ) {
+ if ( in_array( $wordLastVowel, $frontVowels ) ) {
+ $word = $word . "нің";
+ } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
+ $word = $word . "ның";
+ }
+ } elseif ( in_array( $wordEnding, $Sonants ) || in_array( $wordEnding, $Sibilants )) {
+ if ( in_array( $wordLastVowel, $frontVowels ) ) {
+ $word = $word . "дің";
+ } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
+ $word = $word . "дың";
+ }
+ }
+ break;
+ case "dc2":
+ case "dative": #barıs
+ if ( in_array( $wordEnding, $Consonants ) ) {
+ if ( in_array( $wordLastVowel, $frontVowels ) ) {
+ $word = $word . "ке";
+ } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
+ $word = $word . "қа";
+ }
+ } elseif ( in_array( $wordEnding, $allVowels ) || in_array( $wordEnding, $Sonorants ) ) {
+ if ( in_array( $wordLastVowel, $frontVowels ) ) {
+ $word = $word . "ге";
+ } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
+ $word = $word . "ға";
+ }
+ }
+ break;
+ case "dc21":
+ case "possessive dative": #täweldık + barıs
+ if ( in_array( $wordEnding, $firstPerson ) ) {
+ if ( in_array( $wordLastVowel, $frontVowels ) ) {
+ $word = $word . "е";
+ } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
+ $word = $word . "а";
+ }
+ } elseif ( in_array( $wordEnding, $secondPerson ) ) {
+ if ( in_array( $wordLastVowel, $frontVowels ) ) {
+ $word = $word . "ге";
+ } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
+ $word = $word . "ға";
+ }
+ } elseif ( in_array( $wordEnding, $thirdPerson ) ) {
+ if ( in_array( $wordLastVowel, $frontVowels ) ) {
+ $word = $word . "не";
+ } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
+ $word = $word . "на";
+ }
+ }
+ break;
+ case "dc3":
+ case "accusative": #tabıs
+ if ( in_array( $wordEnding, $Consonants ) ) {
+ if ( in_array( $wordLastVowel, $frontVowels ) ) {
+ $word = $word . "ті";
+ } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
+ $word = $word . "ты";
+ }
+ } elseif ( in_array( $wordEnding, $allVowels ) ) {
+ if ( in_array($wordLastVowel, $frontVowels ) ) {
+ $word = $word . "ні";
+ } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
+ $word = $word . "ны";
+ }
+ } elseif ( in_array( $wordEnding, $Sonorants) ) {
+ if ( in_array( $wordLastVowel, $frontVowels) ) {
+ $word = $word . "ді";
+ } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
+ $word = $word . "ды";
+ }
+ }
+ break;
+ case "dc31":
+ case "possessive accusative": #täweldık + tabıs
+ if ( in_array( $wordEnding, $firstPerson ) || in_array( $wordEnding, $secondPerson ) ) {
+ if ( in_array( $wordLastVowel, $frontVowels ) ) {
+ $word = $word . "ді";
+ } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
+ $word = $word . "ды";
+ }
+ } elseif ( in_array( $wordEnding, $thirdPerson ) ) {
+ $word = $word . "н";
+ }
+ break;
+ case "dc4":
+ case "locative": #jatıs
+ if ( in_array( $wordEnding, $Consonants ) ) {
+ if ( in_array( $wordLastVowel, $frontVowels ) ) {
+ $word = $word . "те";
+ } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
+ $word = $word . "та";
+ }
+ } elseif ( in_array( $wordEnding, $allVowels ) || in_array( $wordEnding, $Sonorants ) ) {
+ if ( in_array( $wordLastVowel, $frontVowels) ) {
+ $word = $word . "де";
+ } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
+ $word = $word . "да";
+ }
+ }
+ break;
+ case "dc41":
+ case "possessive locative": #täweldık + jatıs
+ if ( in_array( $wordEnding, $firstPerson ) || in_array( $wordEnding, $secondPerson ) ) {
+ if ( in_array( $wordLastVowel, $frontVowels ) ) {
+ $word = $word . "де";
+ } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
+ $word = $word . "да";
+ }
+ } elseif ( in_array( $wordEnding, $thirdPerson ) ) {
+ if ( in_array( $wordLastVowel, $frontVowels) ) {
+ $word = $word . "нде";
+ } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
+ $word = $word . "нда";
+ }
+ }
+ break;
+ case "dc5":
+ case "ablative": #şığıs
+ if ( in_array( $wordEnding, $Consonants ) ) {
+ if ( in_array( $wordLastVowel, $frontVowels ) ) {
+ $word = $word . "тен";
+ } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
+ $word = $word . "тан";
+ }
+ } elseif ( in_array($wordEnding, $allVowels ) || in_array($wordEnding, $Sonants ) || in_array($wordEnding, $Sibilants ) ) {
+ if ( in_array( $wordLastVowel, $frontVowels ) ) {
+ $word = $word . "ден";
+ } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
+ $word = $word . "дан";
+ }
+ } elseif ( in_array($wordEnding, $Nasals ) ) {
+ if ( in_array( $wordLastVowel, $frontVowels ) ) {
+ $word = $word . "нен";
+ } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
+ $word = $word . "нан";
+ }
+ }
+ break;
+ case "dc51":
+ case "possessive ablative": #täweldık + şığıs
+ if ( in_array( $wordEnding, $firstPerson ) || in_array( $wordEnding, $thirdPerson ) ) {
+ if ( in_array( $wordLastVowel, $frontVowels ) ) {
+ $word = $word . "нен";
+ } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
+ $word = $word . "нан";
+ }
+ } elseif ( in_array($wordEnding, $secondPerson ) ) {
+ if ( in_array( $wordLastVowel, $frontVowels ) ) {
+ $word = $word . "ден";
+ } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
+ $word = $word . "дан";
+ }
+ }
+ break;
+ case "dc6":
+ case "comitative": #kömektes
+ if ( in_array( $wordEnding, $Consonants ) ) {
+ $word = $word . "пен";
+ } elseif ( in_array( $wordEnding, $allVowels ) || in_array( $wordEnding, $Nasals ) || in_array( $wordEnding, $Sonants ) ) {
+ $word = $word . "мен";
+ } elseif ( in_array( $wordEnding, $Sibilants ) ) {
+ $word = $word . "бен";
+ }
+ break;
+ case "dc61":
+ case "possessive comitative": #täweldık + kömektes
+ if ( in_array( $wordEnding, $Consonants ) ) {
+ $word = $word . "пенен";
+ } elseif ( in_array( $wordEnding, $allVowels ) || in_array( $wordEnding, $Nasals ) || in_array( $wordEnding, $Sonants ) ) {
+ $word = $word . "менен";
+ } elseif ( in_array( $wordEnding, $Sibilants ) ) {
+ $word = $word . "бенен";
+ }
+ break;
+ default: #dc0 #nominative #ataw
+ }
+ return $word;
+ }
+
+ function convertGrammarKk_latn( $word, $case ) {
+ global $wgGrammarForms;
+ if ( isset( $wgGrammarForms['kk-tr'][$case][$word] ) ) {
+ return $wgGrammarForms['kk-tr'][$case][$word];
+ }
+ if ( isset( $wgGrammarForms['kk-latn'][$case][$word] ) ) {
+ return $wgGrammarForms['kk-latn'][$case][$word];
+ }
+ // Set up some constants...
+ // Vowels in last syllable
+ $frontVowels = array( "e", "ö", "ü", "i", "ä", "é" );
+ $backVowels = array( "a", "o", "u", "ı" );
+ $allVowels = array( "e", "ö", "ü", "i", "ä", "é", "a", "o", "u", "ı" );
+ // Preceding letters
+ $Nasals = array( "m", "n", "ñ" );
+ $Sonants = array( "ï", "y", "ý", "l", "r", "w");
+ $Consonants = array( "p", "f", "k", "q", "t", "ş", "s", "x", "c", "ç", "b", "v", "g", "d" );
+ $Sibilants = array( "j", "z" );
+ $Sonorants = array( "ï", "y", "ý", "l", "r", "w", "m", "n", "ñ", "j", "z");
+
+ // Possessives
+ $firstPerson = array( "m", "ñ" ); // 1st singular, 2nd unformal
+ $secondPerson = array( "z" ); // 1st plural, 2nd formal
+ $thirdPerson = array( "ı", "i" ); // 3rd
+
+ $lastLetter = self::lastLetter( $word, $allVowels );
+ $wordEnding =& $lastLetter[0];
+ $wordLastVowel =& $lastLetter[1];
+
+ // Now convert the word
+ switch ( $case ) {
+ case "dc1":
+ case "genitive": #ilik
+ if ( in_array( $wordEnding, $Consonants ) ) {
+ if ( in_array( $wordLastVowel, $frontVowels ) ) {
+ $word = $word . "tiñ";
+ } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
+ $word = $word . "tıñ";
+ }
+ } elseif ( in_array( $wordEnding, $allVowels ) || in_array( $wordEnding, $Nasals ) ) {
+ if ( in_array( $wordLastVowel, $frontVowels ) ) {
+ $word = $word . "niñ";
+ } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
+ $word = $word . "nıñ";
+ }
+ } elseif ( in_array( $wordEnding, $Sonants ) || in_array( $wordEnding, $Sibilants )) {
+ if ( in_array( $wordLastVowel, $frontVowels ) ) {
+ $word = $word . "diñ";
+ } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
+ $word = $word . "dıñ";
+ }
+ }
+ break;
+ case "dc2":
+ case "dative": #barıs
+ if ( in_array( $wordEnding, $Consonants ) ) {
+ if ( in_array( $wordLastVowel, $frontVowels ) ) {
+ $word = $word . "ke";
+ } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
+ $word = $word . "qa";
+ }
+ } elseif ( in_array( $wordEnding, $allVowels ) || in_array( $wordEnding, $Sonorants ) ) {
+ if ( in_array( $wordLastVowel, $frontVowels ) ) {
+ $word = $word . "ge";
+ } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
+ $word = $word . "ğa";
+ }
+ }
+ break;
+ case "dc21":
+ case "possessive dative": #täweldık + barıs
+ if ( in_array( $wordEnding, $firstPerson ) ) {
+ if ( in_array( $wordLastVowel, $frontVowels ) ) {
+ $word = $word . "e";
+ } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
+ $word = $word . "a";
+ }
+ } elseif ( in_array( $wordEnding, $secondPerson ) ) {
+ if ( in_array( $wordLastVowel, $frontVowels ) ) {
+ $word = $word . "ge";
+ } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
+ $word = $word . "ğa";
+ }
+ } elseif ( in_array( $wordEnding, $thirdPerson ) ) {
+ if ( in_array( $wordLastVowel, $frontVowels ) ) {
+ $word = $word . "ne";
+ } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
+ $word = $word . "na";
+ }
+ }
+ break;
+ case "dc3":
+ case "accusative": #tabıs
+ if ( in_array( $wordEnding, $Consonants ) ) {
+ if ( in_array( $wordLastVowel, $frontVowels ) ) {
+ $word = $word . "ti";
+ } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
+ $word = $word . "tı";
+ }
+ } elseif ( in_array( $wordEnding, $allVowels ) ) {
+ if ( in_array($wordLastVowel, $frontVowels ) ) {
+ $word = $word . "ni";
+ } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
+ $word = $word . "nı";
+ }
+ } elseif ( in_array( $wordEnding, $Sonorants) ) {
+ if ( in_array( $wordLastVowel, $frontVowels) ) {
+ $word = $word . "di";
+ } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
+ $word = $word . "dı";
+ }
+ }
+ break;
+ case "dc31":
+ case "possessive accusative": #täweldık + tabıs
+ if ( in_array( $wordEnding, $firstPerson ) || in_array( $wordEnding, $secondPerson ) ) {
+ if ( in_array( $wordLastVowel, $frontVowels ) ) {
+ $word = $word . "di";
+ } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
+ $word = $word . "dı";
+ }
+ } elseif ( in_array( $wordEnding, $thirdPerson ) ) {
+ $word = $word . "n";
+ }
+ break;
+ case "dc4":
+ case "locative": #jatıs
+ if ( in_array( $wordEnding, $Consonants ) ) {
+ if ( in_array( $wordLastVowel, $frontVowels ) ) {
+ $word = $word . "te";
+ } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
+ $word = $word . "ta";
+ }
+ } elseif ( in_array( $wordEnding, $allVowels ) || in_array( $wordEnding, $Sonorants ) ) {
+ if ( in_array( $wordLastVowel, $frontVowels) ) {
+ $word = $word . "de";
+ } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
+ $word = $word . "da";
+ }
+ }
+ break;
+ case "dc41":
+ case "possessive locative": #täweldık + jatıs
+ if ( in_array( $wordEnding, $firstPerson ) || in_array( $wordEnding, $secondPerson ) ) {
+ if ( in_array( $wordLastVowel, $frontVowels ) ) {
+ $word = $word . "de";
+ } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
+ $word = $word . "da";
+ }
+ } elseif ( in_array( $wordEnding, $thirdPerson ) ) {
+ if ( in_array( $wordLastVowel, $frontVowels) ) {
+ $word = $word . "nde";
+ } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
+ $word = $word . "nda";
+ }
+ }
+ break;
+ case "dc5":
+ case "ablative": #şığıs
+ if ( in_array( $wordEnding, $Consonants ) ) {
+ if ( in_array( $wordLastVowel, $frontVowels ) ) {
+ $word = $word . "ten";
+ } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
+ $word = $word . "tan";
+ }
+ } elseif ( in_array($wordEnding, $allVowels ) || in_array($wordEnding, $Sonants ) || in_array($wordEnding, $Sibilants ) ) {
+ if ( in_array( $wordLastVowel, $frontVowels ) ) {
+ $word = $word . "den";
+ } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
+ $word = $word . "dan";
+ }
+ } elseif ( in_array($wordEnding, $Nasals ) ) {
+ if ( in_array( $wordLastVowel, $frontVowels ) ) {
+ $word = $word . "nen";
+ } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
+ $word = $word . "nan";
+ }
+ }
+ break;
+ case "dc51":
+ case "possessive ablative": #täweldık + şığıs
+ if ( in_array( $wordEnding, $firstPerson ) || in_array( $wordEnding, $thirdPerson ) ) {
+ if ( in_array( $wordLastVowel, $frontVowels ) ) {
+ $word = $word . "nen";
+ } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
+ $word = $word . "nan";
+ }
+ } elseif ( in_array($wordEnding, $secondPerson ) ) {
+ if ( in_array( $wordLastVowel, $frontVowels ) ) {
+ $word = $word . "den";
+ } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
+ $word = $word . "dan";
+ }
+ }
+ break;
+ case "dc6":
+ case "comitative": #kömektes
+ if ( in_array( $wordEnding, $Consonants ) ) {
+ $word = $word . "pen";
+ } elseif ( in_array( $wordEnding, $allVowels ) || in_array( $wordEnding, $Nasals ) || in_array( $wordEnding, $Sonants ) ) {
+ $word = $word . "men";
+ } elseif ( in_array( $wordEnding, $Sibilants ) ) {
+ $word = $word . "ben";
+ }
+ break;
+ case "dc61":
+ case "possessive comitative": #täweldık + kömektes
+ if ( in_array( $wordEnding, $Consonants ) ) {
+ $word = $word . "penen";
+ } elseif ( in_array( $wordEnding, $allVowels ) || in_array( $wordEnding, $Nasals ) || in_array( $wordEnding, $Sonants ) ) {
+ $word = $word . "menen";
+ } elseif ( in_array( $wordEnding, $Sibilants ) ) {
+ $word = $word . "benen";
+ }
+ break;
+ default: #dc0 #nominative #ataw
+ }
+ return $word;
+ }
+
+ function convertGrammarKk_arab( $word, $case ) {
+ global $wgGrammarForms;
+ if ( isset( $wgGrammarForms['kk-cn'][$case][$word] ) ) {
+ return $wgGrammarForms['kk-cn'][$case][$word];
+ }
+ if ( isset( $wgGrammarForms['kk-arab'][$case][$word] ) ) {
+ return $wgGrammarForms['kk-arab'][$case][$word];
+ }
+ // Set up some constants...
+ // Vowels in last syllable
+ $frontVowels = array( "ە", "ٶ", "ٷ", "ٸ", "ٵ", "ە" );
+ $backVowels = array( "ا", "و", "ۇ", "ى" );
+ $allVowels = array( "ە", "ٶ", "ٷ", "ٸ", "ٵ", "ە", "ا", "و", "ۇ", "ى" );
+ // Preceding letters
+ $Nasals = array( "م", "ن", "ڭ" );
+ $Sonants = array( "ي", "ي", "ل", "ر", "ۋ");
+ $Consonants = array( "پ", "ف", "ك", "ق", "ت", "ش", "س", "ح", "تس", "چ", "ب", "ۆ", "گ", "د" );
+ $Sibilants = array( "ج", "ز" );
+ $Sonorants = array( "ي", "ي", "ل", "ر", "ۋ", "م", "ن", "ڭ", "ج", "ز");
+
+ // Possessives
+ $firstPerson = array( "م", "ڭ" ); // 1st singular, 2nd unformal
+ $secondPerson = array( "ز" ); // 1st plural, 2nd formal
+ $thirdPerson = array( "ى", "ٸ" ); // 3rd
+
+ $lastLetter = self::lastLetter( $word, $allVowels );
+ $wordEnding =& $lastLetter[0];
+ $wordLastVowel =& $lastLetter[1];
+
+ // Now convert the word
+ switch ( $case ) {
+ case "dc1":
+ case "genitive": #ilik
+ if ( in_array( $wordEnding, $Consonants ) ) {
+ if ( in_array( $wordLastVowel, $frontVowels ) ) {
+ $word = $word . "تٸڭ";
+ } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
+ $word = $word . "تىڭ";
+ }
+ } elseif ( in_array( $wordEnding, $allVowels ) || in_array( $wordEnding, $Nasals ) ) {
+ if ( in_array( $wordLastVowel, $frontVowels ) ) {
+ $word = $word . "نٸڭ";
+ } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
+ $word = $word . "نىڭ";
+ }
+ } elseif ( in_array( $wordEnding, $Sonants ) || in_array( $wordEnding, $Sibilants )) {
+ if ( in_array( $wordLastVowel, $frontVowels ) ) {
+ $word = $word . "دٸڭ";
+ } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
+ $word = $word . "دىڭ";
+ }
+ }
+ break;
+ case "dc2":
+ case "dative": #barıs
+ if ( in_array( $wordEnding, $Consonants ) ) {
+ if ( in_array( $wordLastVowel, $frontVowels ) ) {
+ $word = $word . "كە";
+ } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
+ $word = $word . "قا";
+ }
+ } elseif ( in_array( $wordEnding, $allVowels ) || in_array( $wordEnding, $Sonorants ) ) {
+ if ( in_array( $wordLastVowel, $frontVowels ) ) {
+ $word = $word . "گە";
+ } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
+ $word = $word . "عا";
+ }
+ }
+ break;
+ case "dc21":
+ case "possessive dative": #täweldık + barıs
+ if ( in_array( $wordEnding, $firstPerson ) ) {
+ if ( in_array( $wordLastVowel, $frontVowels ) ) {
+ $word = $word . "ە";
+ } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
+ $word = $word . "ا";
+ }
+ } elseif ( in_array( $wordEnding, $secondPerson ) ) {
+ if ( in_array( $wordLastVowel, $frontVowels ) ) {
+ $word = $word . "گە";
+ } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
+ $word = $word . "عا";
+ }
+ } elseif ( in_array( $wordEnding, $thirdPerson ) ) {
+ if ( in_array( $wordLastVowel, $frontVowels ) ) {
+ $word = $word . "نە";
+ } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
+ $word = $word . "نا";
+ }
+ }
+ break;
+ case "dc3":
+ case "accusative": #tabıs
+ if ( in_array( $wordEnding, $Consonants ) ) {
+ if ( in_array( $wordLastVowel, $frontVowels ) ) {
+ $word = $word . "تٸ";
+ } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
+ $word = $word . "تى";
+ }
+ } elseif ( in_array( $wordEnding, $allVowels ) ) {
+ if ( in_array($wordLastVowel, $frontVowels ) ) {
+ $word = $word . "نٸ";
+ } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
+ $word = $word . "نى";
+ }
+ } elseif ( in_array( $wordEnding, $Sonorants) ) {
+ if ( in_array( $wordLastVowel, $frontVowels) ) {
+ $word = $word . "دٸ";
+ } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
+ $word = $word . "دى";
+ }
+ }
+ break;
+ case "dc31":
+ case "possessive accusative": #täweldık + tabıs
+ if ( in_array( $wordEnding, $firstPerson ) || in_array( $wordEnding, $secondPerson ) ) {
+ if ( in_array( $wordLastVowel, $frontVowels ) ) {
+ $word = $word . "دٸ";
+ } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
+ $word = $word . "دى";
+ }
+ } elseif ( in_array( $wordEnding, $thirdPerson ) ) {
+ $word = $word . "ن";
+ }
+ break;
+ case "dc4":
+ case "locative": #jatıs
+ if ( in_array( $wordEnding, $Consonants ) ) {
+ if ( in_array( $wordLastVowel, $frontVowels ) ) {
+ $word = $word . "تە";
+ } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
+ $word = $word . "تا";
+ }
+ } elseif ( in_array( $wordEnding, $allVowels ) || in_array( $wordEnding, $Sonorants ) ) {
+ if ( in_array( $wordLastVowel, $frontVowels) ) {
+ $word = $word . "دە";
+ } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
+ $word = $word . "دا";
+ }
+ }
+ break;
+ case "dc41":
+ case "possessive locative": #täweldık + jatıs
+ if ( in_array( $wordEnding, $firstPerson ) || in_array( $wordEnding, $secondPerson ) ) {
+ if ( in_array( $wordLastVowel, $frontVowels ) ) {
+ $word = $word . "دە";
+ } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
+ $word = $word . "دا";
+ }
+ } elseif ( in_array( $wordEnding, $thirdPerson ) ) {
+ if ( in_array( $wordLastVowel, $frontVowels) ) {
+ $word = $word . "ندە";
+ } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
+ $word = $word . "ندا";
+ }
+ }
+ break;
+ case "dc5":
+ case "ablative": #şığıs
+ if ( in_array( $wordEnding, $Consonants ) ) {
+ if ( in_array( $wordLastVowel, $frontVowels ) ) {
+ $word = $word . "تەن";
+ } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
+ $word = $word . "تان";
+ }
+ } elseif ( in_array($wordEnding, $allVowels ) || in_array($wordEnding, $Sonants ) || in_array($wordEnding, $Sibilants ) ) {
+ if ( in_array( $wordLastVowel, $frontVowels ) ) {
+ $word = $word . "دەن";
+ } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
+ $word = $word . "دان";
+ }
+ } elseif ( in_array($wordEnding, $Nasals ) ) {
+ if ( in_array( $wordLastVowel, $frontVowels ) ) {
+ $word = $word . "نەن";
+ } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
+ $word = $word . "نان";
+ }
+ }
+ break;
+ case "dc51":
+ case "possessive ablative": #täweldık + şığıs
+ if ( in_array( $wordEnding, $firstPerson ) || in_array( $wordEnding, $thirdPerson ) ) {
+ if ( in_array( $wordLastVowel, $frontVowels ) ) {
+ $word = $word . "نەن";
+ } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
+ $word = $word . "نان";
+ }
+ } elseif ( in_array($wordEnding, $secondPerson ) ) {
+ if ( in_array( $wordLastVowel, $frontVowels ) ) {
+ $word = $word . "دەن";
+ } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
+ $word = $word . "دان";
+ }
+ }
+ break;
+ case "dc6":
+ case "comitative": #kömektes
+ if ( in_array( $wordEnding, $Consonants ) ) {
+ $word = $word . "پەن";
+ } elseif ( in_array( $wordEnding, $allVowels ) || in_array( $wordEnding, $Nasals ) || in_array( $wordEnding, $Sonants ) ) {
+ $word = $word . "مەن";
+ } elseif ( in_array( $wordEnding, $Sibilants ) ) {
+ $word = $word . "بەن";
+ }
+ break;
+ case "dc61":
+ case "possessive comitative": #täweldık + kömektes
+ if ( in_array( $wordEnding, $Consonants ) ) {
+ $word = $word . "پەنەن";
+ } elseif ( in_array( $wordEnding, $allVowels ) || in_array( $wordEnding, $Nasals ) || in_array( $wordEnding, $Sonants ) ) {
+ $word = $word . "مەنەن";
+ } elseif ( in_array( $wordEnding, $Sibilants ) ) {
+ $word = $word . "بەنەن";
+ }
+ break;
+ default: #dc0 #nominative #ataw
+ }
+ return $word;
+ }
+
+ function lastLetter( $word, $allVowels ) {
+ $lastLetter = array();
+ $ar = array();
+
+ // Put the word in a form we can play with since we're using UTF-8
+ $ar = preg_split('//u', parent::lc($word), -1, PREG_SPLIT_NO_EMPTY);
+
+ // Here's an array with the order of the letters in the word reversed
+ // so we can find a match quicker *shrug*
+ $wordReversed = array_reverse( $ar );
+
+ // Here's the last letter in the word
+ $lastLetter[0] = $ar[count( $ar ) - 1];
+
+ // Find the last vowel in the word
+ $lastLetter[1] = NULL;
+ foreach ( $wordReversed as $xvalue ) {
+ foreach ( $allVowels as $yvalue ) {
+ if ( strcmp( $xvalue, $yvalue ) == 0 ) {
+ $lastLetter[1] = $xvalue;
+ break;
+ } else {
+ continue;
+ }
+ }
+ if ( $lastLetter[1] !== NULL ) {
+ break;
+ } else {
+ continue;
+ }
+ }
+
+ return $lastLetter;
+ }
+
+ /**
+ * Avoid grouping whole numbers between 0 to 9999
+ */
+ function commafy( $_ ) {
+ if ( !preg_match( '/^\d{1,4}$/', $_ ) ) {
+ return strrev( (string)preg_replace( '/(\d{3})(?=\d)(?!\d*\.)/', '$1,', strrev($_) ) );
+ } else {
+ return $_;
+ }
+ }
+}
diff --git a/languages/classes/LanguageKsh.php b/languages/classes/LanguageKsh.php
index c53667cf..f72046e7 100644
--- a/languages/classes/LanguageKsh.php
+++ b/languages/classes/LanguageKsh.php
@@ -21,14 +21,16 @@ class LanguageKsh extends Language {
/**
* Handle cases of (1, other, 0) or (1, other)
*/
- public function convertPlural( $count, $w1, $w2, $w3, $w4, $w5 ) {
- $count = str_replace (' ', '', $count);
- if ( $count == '1' ) {
- return $w1;
- } elseif ( $count == '0' && $w3 ) {
- return $w3;
+ function convertPlural( $count, $forms ) {
+ if ( !count($forms) ) { return ''; }
+ $forms = $this->preConvertPlural( $forms, 3 );
+
+ if ( $count == 1 ) {
+ return $forms[0];
+ } elseif ( $count == 0 ) {
+ return $forms[2];
} else {
- return $w2;
+ return $forms[1];
}
}
}
diff --git a/languages/classes/LanguageKu.php b/languages/classes/LanguageKu.php
index a08d3d73..d37d4287 100644
--- a/languages/classes/LanguageKu.php
+++ b/languages/classes/LanguageKu.php
@@ -15,6 +15,9 @@ class KuConverter extends LanguageConverter {
'م' => 'm', 'ن' => 'n', 'پ' => 'p', 'ق' => 'q', 'ر' => 'r', 'س' => 's', 'ش' => 'ş',
'ت' => 't', 'ڤ' => 'v', 'خ' => 'x', 'غ' => 'x', 'ز' => 'z',
+// ک و => ku -- ist richtig
+// و ك=> ku -- ist auch richtig
+
/* Doppel- und Halbvokale */
'ڵ' => 'll', #ll
'ڕ' => 'rr', #rr
@@ -34,6 +37,18 @@ class KuConverter extends LanguageConverter {
'،' => ',',
'ع' => '\'', # ayn
'؟' => '?',
+
+ # digits
+ '٠' => '0', # &#x0660;
+ '١' => '1', # &#x0661;
+ '٢' => '2', # &#x0662;
+ '٣' => '3', # &#x0663;
+ '٤' => '4', # &#x0664;
+ '٥' => '5', # &#x0665;
+ '٦' => '6', # &#x0666;
+ '٧' => '7', # &#x0667;
+ '٨' => '8', # &#x0668;
+ '٩' => '9', # &#x0669;
);
var $mLatinToArabic = array(
@@ -95,7 +110,20 @@ class KuConverter extends LanguageConverter {
# eyn erstmal deaktivieren, einfache Anführungsstriche sind einfach zu häufig, um sie als eyn zu interpretieren
# '\'' => 'ع',
- );
+/* # deactivated for now, breaks links i.e. in header of Special:Recentchanges :-(
+ # digits
+ '0' => '٠', # &#x0660;
+ '1' => '١', # &#x0661;
+ '2' => '٢', # &#x0662;
+ '3' => '٣', # &#x0663;
+ '4' => '٤', # &#x0664;
+ '5' => '٥', # &#x0665;
+ '6' => '٦', # &#x0666;
+ '7' => '٧', # &#x0667;
+ '8' => '٨', # &#x0668;
+ '9' => '٩', # &#x0669;
+*/
+ );
function loadDefaultTables() {
$this->mTables = array(
@@ -236,5 +264,3 @@ class LanguageKu extends LanguageKu_ku {
}
*/
}
-
-
diff --git a/languages/classes/LanguageLt.php b/languages/classes/LanguageLt.php
index f2b29cad..0e14cbf8 100644
--- a/languages/classes/LanguageLt.php
+++ b/languages/classes/LanguageLt.php
@@ -11,11 +11,17 @@ class LanguageLt extends Language {
2 - trys (3) lapai
3 - penkiolika (15) lapų
*/
- function convertPlural( $count, $wordform1, $wordform2, $wordform3, $w4, $w5) {
- if ($count%10==1 && $count%100!=11) return $wordform1;
- if ($count%10>=2 && ($count%100<10 || $count%100>=20)) return $wordform2;
- //if third form not specified, then use second form
- return empty($wordform3)?$wordform2:$wordform3;
+ function convertPlural( $count, $forms ) {
+ 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];
+
+ $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];
+ return $forms[2];
}
}
diff --git a/languages/classes/LanguageLv.php b/languages/classes/LanguageLv.php
index 8a46bb9d..a3f076e8 100644
--- a/languages/classes/LanguageLv.php
+++ b/languages/classes/LanguageLv.php
@@ -21,8 +21,11 @@ class LanguageLv extends Language {
* @param string $wordform3 (not used)
* @return string
*/
- function convertPlural( $count, $wordform1, $wordform2, $wordform3, $w4, $w5 ) {
- return ( ( $count % 10 == 1 ) && ( $count % 100 != 11 ) ) ? $wordform1 : $wordform2;
+ function convertPlural( $count, $forms ) {
+ if ( !count($forms) ) { return ''; }
+ $forms = $this->preConvertPlural( $forms, 2 );
+
+ return ( ( $count % 10 == 1 ) && ( $count % 100 != 11 ) ) ? $forms[0] : $forms[1];
}
# Convert from the nominative form of a noun to some other case
diff --git a/languages/classes/LanguagePl.php b/languages/classes/LanguagePl.php
new file mode 100644
index 00000000..35b2a9c0
--- /dev/null
+++ b/languages/classes/LanguagePl.php
@@ -0,0 +1,24 @@
+<?php
+/** Polish (polski)
+ *
+ * @addtogroup Language
+ */
+
+class LanguagePl extends Language {
+ function convertPlural( $count, $forms ) {
+ if ( !count($forms) ) { return ''; }
+ $forms = $this->preConvertPlural( $forms, 3 );
+ $count = abs( $count );
+ if ( $count == 1 )
+ return $forms[0]; // singular
+ switch ( $count % 10 ) {
+ case 2:
+ case 3:
+ case 4:
+ if ( $count / 10 % 10 != 1 )
+ return $forms[1]; // plural
+ default:
+ return $forms[2]; // plural genitive
+ }
+ }
+} \ No newline at end of file
diff --git a/languages/classes/LanguagePt_br.php b/languages/classes/LanguagePt_br.php
index 31574ed8..78965ae3 100644
--- a/languages/classes/LanguagePt_br.php
+++ b/languages/classes/LanguagePt_br.php
@@ -9,8 +9,11 @@ class LanguagePt_br extends Language {
/**
* Use singular form for zero (see bug 7309)
*/
- function convertPlural( $count, $w1, $w2, $w3, $w4, $w5) {
- return $count <= '1' ? $w1 : $w2;
- }
+ function convertPlural( $count, $forms ) {
+ if ( !count($forms) ) { return ''; }
+ $forms = $this->preConvertPlural( $forms, 2 );
+
+ return ($count <= 1) ? $forms[0] : $forms[1];
+ }
}
diff --git a/languages/classes/LanguageRu.php b/languages/classes/LanguageRu.php
index 7d088053..f6311b33 100644
--- a/languages/classes/LanguageRu.php
+++ b/languages/classes/LanguageRu.php
@@ -56,17 +56,38 @@ class LanguageRu extends Language {
return $word;
}
- function convertPlural( $count, $wordform1, $wordform2, $wordform3, $w4, $w5) {
- $count = str_replace (' ', '', $count);
+ /**
+ * Plural form transformations
+ *
+ * $forms[0] - singular form (for 1, 21, 31, 41...)
+ * $forms[1] - paucal form (for 2, 3, 4, 22, 23, 24, 32, 33, 34...)
+ * $forms[2] - plural form (for 0, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 25, 26...)
+ *
+ * Examples:
+ * message with number
+ * "Сделано $1 {{PLURAL:$1|изменение|изменения|изменений}}"
+ * message without number
+ * "Действие не может быть выполнено по {{PLURAL:$1|следующей причине|следующим причинам}}:"
+ *
+ */
+
+ function convertPlural( $count, $forms ) {
+ 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];
+
+ $forms = $this->preConvertPlural( $forms, 3 );
+
if ($count > 10 && floor(($count % 100) / 10) == 1) {
- return $wordform3;
+ return $forms[2];
} else {
switch ($count % 10) {
- case 1: return $wordform1;
+ case 1: return $forms[0];
case 2:
case 3:
- case 4: return $wordform2;
- default: return $wordform3;
+ case 4: return $forms[1];
+ default: return $forms[2];
}
}
}
@@ -84,3 +105,4 @@ class LanguageRu extends Language {
}
}
+
diff --git a/languages/classes/LanguageSk.php b/languages/classes/LanguageSk.php
index 1b9832cc..edbe011c 100644
--- a/languages/classes/LanguageSk.php
+++ b/languages/classes/LanguageSk.php
@@ -76,9 +76,10 @@ class LanguageSk extends Language {
return $word;
}
- function convertPlural( $count, $w1, $w2, $w3, $w4, $w5) {
- $count = str_replace ('.', '', $count);
- $forms = array( $w1, $w2, $w3);
+ function convertPlural( $count, $forms ) {
+ if ( !count($forms) ) { return ''; }
+ $forms = $this->preConvertPlural( $forms, 3 );
+
if ( $count == 1 ) {
$index = 0;
} elseif ( $count == 2 || $count == 3 || $count == 4 ) {
diff --git a/languages/classes/LanguageSl.php b/languages/classes/LanguageSl.php
index 2513d6bd..9b1e5c2b 100644
--- a/languages/classes/LanguageSl.php
+++ b/languages/classes/LanguageSl.php
@@ -71,9 +71,10 @@ class LanguageSl extends Language {
return $word; # this will return the original value for 'imenovalnik' (nominativ) and all undefined case values
}
- function convertPlural( $count, $w1, $w2, $w3, $w4, $w5) {
- $count = str_replace ('.', '', $count);
- $forms = array( $w1, $w2, $w3, $w4, $w5 );
+ function convertPlural( $count, $forms ) {
+ if ( !count($forms) ) { return ''; }
+ $forms = $this->preConvertPlural( $forms, 5 );
+
if ( $count % 100 == 1 ) {
$index = 0;
} elseif ( $count % 100 == 2 ) {
diff --git a/languages/classes/LanguageSr_ec.php b/languages/classes/LanguageSr_ec.php
index 42647ae6..1f9bb716 100644
--- a/languages/classes/LanguageSr_ec.php
+++ b/languages/classes/LanguageSr_ec.php
@@ -8,17 +8,19 @@
#--------------------------------------------------------------------------
class LanguageSr_ec extends Language {
- function convertPlural( $count, $wordform1, $wordform2, $wordform3, $w4, $w5) {
- $count = str_replace ('.', '', $count);
+ function convertPlural( $count, $forms ) {
+ if ( !count($forms) ) { return ''; }
+ $forms = $this->preConvertPlural( $forms, 3 );
+
if ($count > 10 && floor(($count % 100) / 10) == 1) {
- return $wordform3;
+ return $forms[2];
} else {
switch ($count % 10) {
- case 1: return $wordform1;
+ case 1: return $forms[0];
case 2:
case 3:
- case 4: return $wordform2;
- default: return $wordform3;
+ case 4: return $forms[1];
+ default: return $forms[2];
}
}
}
diff --git a/languages/classes/LanguageSr_el.php b/languages/classes/LanguageSr_el.php
index 66118cc9..a444e3b7 100644
--- a/languages/classes/LanguageSr_el.php
+++ b/languages/classes/LanguageSr_el.php
@@ -8,17 +8,19 @@
#--------------------------------------------------------------------------
class LanguageSr_el extends Language {
- function convertPlural( $count, $wordform1, $wordform2, $wordform3, $w4, $w5) {
- $count = str_replace ('.', '', $count);
+ function convertPlural( $count, $forms ) {
+ if ( !count($forms) ) { return ''; }
+ $forms = $this->preConvertPlural( $forms, 3 );
+
if ($count > 10 && floor(($count % 100) / 10) == 1) {
- return $wordform3;
+ return $forms[2];
} else {
switch ($count % 10) {
- case 1: return $wordform1;
+ case 1: return $forms[0];
case 2:
case 3:
- case 4: return $wordform2;
- default: return $wordform3;
+ case 4: return $forms[1];
+ default: return $forms[2];
}
}
}
diff --git a/languages/classes/LanguageUk.php b/languages/classes/LanguageUk.php
index d87b7f58..7d2f58bf 100644
--- a/languages/classes/LanguageUk.php
+++ b/languages/classes/LanguageUk.php
@@ -58,17 +58,19 @@ class LanguageUk extends Language {
return $word;
}
- function convertPlural( $count, $wordform1, $wordform2, $wordform3, $w4, $w5) {
- $count = str_replace (' ', '', $count);
+ function convertPlural( $count, $forms ) {
+ if ( !count($forms) ) { return ''; }
+ $forms = $this->preConvertPlural( $forms, 3 );
+
if ($count > 10 && floor(($count % 100) / 10) == 1) {
- return $wordform3;
+ return $forms[2];
} else {
switch ($count % 10) {
- case 1: return $wordform1;
+ case 1: return $forms[0];
case 2:
case 3:
- case 4: return $wordform2;
- default: return $wordform3;
+ case 4: return $forms[1];
+ default: return $forms[2];
}
}
}
diff --git a/languages/classes/LanguageYue.php b/languages/classes/LanguageYue.php
new file mode 100644
index 00000000..26e45984
--- /dev/null
+++ b/languages/classes/LanguageYue.php
@@ -0,0 +1,23 @@
+<?php
+/**
+ * @addtogroup Language
+ */
+class LanguageYue extends Language {
+ function stripForSearch( $string ) {
+ # MySQL fulltext index doesn't grok utf-8, so we
+ # need to fold cases and convert to hex
+ # we also separate characters as "words"
+ if( function_exists( 'mb_strtolower' ) ) {
+ return preg_replace(
+ "/([\\xc0-\\xff][\\x80-\\xbf]*)/e",
+ "' U8' . bin2hex( \"$1\" )",
+ mb_strtolower( $string ) );
+ } else {
+ list( , $wikiLowerChars ) = Language::getCaseMaps();
+ return preg_replace(
+ "/([\\xc0-\\xff][\\x80-\\xbf]*)/e",
+ "' U8' . bin2hex( strtr( \"\$1\", \$wikiLowerChars ) )",
+ $string );
+ }
+ }
+}
diff --git a/languages/classes/LanguageZh.deps.php b/languages/classes/LanguageZh.deps.php
index 9a9dacb1..05e51799 100644
--- a/languages/classes/LanguageZh.deps.php
+++ b/languages/classes/LanguageZh.deps.php
@@ -5,6 +5,5 @@
// changed on a subsequent page view.
// see http://mail.wikipedia.org/pipermail/wikitech-l/2006-January/033660.html
-require_once( dirname(__FILE__).'/LanguageZh_cn.php' );
+require_once( dirname(__FILE__).'/LanguageZh_hans.php' );
require_once( dirname(__FILE__).'/../LanguageConverter.php' );
-
diff --git a/languages/classes/LanguageZh.php b/languages/classes/LanguageZh.php
index bcdf7dd8..337783a6 100644
--- a/languages/classes/LanguageZh.php
+++ b/languages/classes/LanguageZh.php
@@ -3,24 +3,28 @@
* @addtogroup Language
*/
require_once( dirname(__FILE__).'/../LanguageConverter.php' );
-require_once( dirname(__FILE__).'/LanguageZh_cn.php' );
+require_once( dirname(__FILE__).'/LanguageZh_hans.php' );
class ZhConverter extends LanguageConverter {
function loadDefaultTables() {
require( dirname(__FILE__)."/../../includes/ZhConversion.php" );
$this->mTables = array(
- 'zh-cn' => new ReplacementArray( $zh2CN ),
- 'zh-tw' => new ReplacementArray( $zh2TW ),
- 'zh-sg' => new ReplacementArray( array_merge($zh2CN, $zh2SG) ),
- 'zh-hk' => new ReplacementArray( array_merge($zh2TW, $zh2HK) ),
- 'zh' => new ReplacementArray
+ 'zh-hans' => new ReplacementArray( $zh2Hans ),
+ 'zh-hant' => new ReplacementArray( $zh2Hant ),
+ 'zh-cn' => new ReplacementArray( array_merge($zh2Hans, $zh2CN) ),
+ 'zh-tw' => new ReplacementArray( array_merge($zh2Hant, $zh2TW) ),
+ 'zh-sg' => new ReplacementArray( array_merge($zh2Hans, $zh2SG) ),
+ 'zh-hk' => new ReplacementArray( array_merge($zh2Hant, $zh2HK) ),
+ 'zh' => new ReplacementArray
);
}
function postLoadTables() {
- $this->mTables['zh-sg']->merge( $this->mTables['zh-cn'] );
- $this->mTables['zh-hk']->merge( $this->mTables['zh-tw'] );
- }
+ $this->mTables['zh-cn']->merge( $this->mTables['zh-hans'] );
+ $this->mTables['zh-tw']->merge( $this->mTables['zh-hant'] );
+ $this->mTables['zh-sg']->merge( $this->mTables['zh-hans'] );
+ $this->mTables['zh-hk']->merge( $this->mTables['zh-hant'] );
+ }
/* there shouldn't be any latin text in Chinese conversion, so no need
to mark anything.
@@ -31,26 +35,33 @@ class ZhConverter extends LanguageConverter {
}
function convertCategoryKey( $key ) {
- return $this->autoConvert( $key, 'zh-cn' );
+ return $this->autoConvert( $key, 'zh' );
}
}
/* class that handles both Traditional and Simplified Chinese
- right now it only distinguish zh_cn, zh_tw, zh_sg and zh_hk.
+ right now it only distinguish zh_hans, zh_hant, zh_cn, zh_tw, zh_sg and zh_hk.
*/
-class LanguageZh extends LanguageZh_cn {
+class LanguageZh extends LanguageZh_hans {
function __construct() {
global $wgHooks;
parent::__construct();
- $this->mConverter = new ZhConverter($this, 'zh',
- array('zh', 'zh-cn', 'zh-tw', 'zh-sg', 'zh-hk'),
- array('zh'=>'zh-cn',
- 'zh-cn'=>'zh-sg',
- 'zh-sg'=>'zh-cn',
- 'zh-tw'=>'zh-hk',
- 'zh-hk'=>'zh-tw'));
+
+ $variants = array('zh', 'zh-hans', 'zh-hant', 'zh-cn', 'zh-tw', 'zh-sg', 'zh-hk');
+ $variantfallbacks = array(
+ 'zh' => 'zh-hans',
+ 'zh-hans' => 'zh',
+ 'zh-hant' => 'zh',
+ 'zh-cn' => 'zh-hans',
+ 'zh-sg' => 'zh-hans',
+ 'zh-tw' => 'zh-hant',
+ 'zh-hk' => 'zh-hant',
+ );
+
+ $this->mConverter = new ZhConverter( $this, 'zh', $variants, $variantfallbacks );
+
$wgHooks['ArticleSaveComplete'][] = $this->mConverter;
}
@@ -79,12 +90,12 @@ class LanguageZh extends LanguageZh_cn {
"/([\\xc0-\\xff][\\x80-\\xbf]*)/e",
"' ' .\"$1\"", $string);
- //always convert to zh-cn before indexing. it should be
- //better to use zh-cn for search, since conversion from
+ //always convert to zh-hans before indexing. it should be
+ //better to use zh-hans for search, since conversion from
//Traditional to Simplified is less ambiguous than the
//other way around
- $t = $this->mConverter->autoConvert($t, 'zh-cn');
+ $t = $this->mConverter->autoConvert($t, 'zh-hans');
$t = parent::stripForSearch( $t );
wfProfileOut( $fname );
return $t;
@@ -99,4 +110,3 @@ class LanguageZh extends LanguageZh_cn {
}
}
-
diff --git a/languages/classes/LanguageZh_hans.php b/languages/classes/LanguageZh_hans.php
new file mode 100644
index 00000000..ed7da2b9
--- /dev/null
+++ b/languages/classes/LanguageZh_hans.php
@@ -0,0 +1,23 @@
+<?php
+/**
+ * @addtogroup Language
+ */
+class LanguageZh_hans extends Language {
+ function stripForSearch( $string ) {
+ # MySQL fulltext index doesn't grok utf-8, so we
+ # need to fold cases and convert to hex
+ # we also separate characters as "words"
+ if( function_exists( 'mb_strtolower' ) ) {
+ return preg_replace(
+ "/([\\xc0-\\xff][\\x80-\\xbf]*)/e",
+ "' U8' . bin2hex( \"$1\" )",
+ mb_strtolower( $string ) );
+ } else {
+ list( , $wikiLowerChars ) = Language::getCaseMaps();
+ return preg_replace(
+ "/([\\xc0-\\xff][\\x80-\\xbf]*)/e",
+ "' U8' . bin2hex( strtr( \"\$1\", \$wikiLowerChars ) )",
+ $string );
+ }
+ }
+}