summaryrefslogtreecommitdiff
path: root/languages/classes
diff options
context:
space:
mode:
Diffstat (limited to 'languages/classes')
-rw-r--r--languages/classes/LanguageBe.php2
-rw-r--r--languages/classes/LanguageBe_tarask.php7
-rw-r--r--languages/classes/LanguageBs.php5
-rw-r--r--languages/classes/LanguageCy.php2
-rw-r--r--languages/classes/LanguageGd.php8
-rw-r--r--languages/classes/LanguageHe.php12
-rw-r--r--languages/classes/LanguageHu.php1
-rw-r--r--languages/classes/LanguageIu.php9
-rw-r--r--languages/classes/LanguageKk_cyrl.php2
-rw-r--r--languages/classes/LanguageLt.php6
-rw-r--r--languages/classes/LanguageMk.php2
-rw-r--r--languages/classes/LanguageMo.php3
-rw-r--r--languages/classes/LanguageMt.php4
-rw-r--r--languages/classes/LanguageQqx.php4
-rw-r--r--languages/classes/LanguageRo.php2
-rw-r--r--languages/classes/LanguageRu.php7
-rw-r--r--languages/classes/LanguageSgs.php2
-rw-r--r--languages/classes/LanguageShi.deps.php (renamed from languages/classes/LanguageSr_el.deps.php)4
-rw-r--r--languages/classes/LanguageShi.php202
-rw-r--r--languages/classes/LanguageSr.php31
-rw-r--r--languages/classes/LanguageTr.php4
-rw-r--r--languages/classes/LanguageUk.php5
22 files changed, 286 insertions, 38 deletions
diff --git a/languages/classes/LanguageBe.php b/languages/classes/LanguageBe.php
index bb0ba9e8..7d881ac9 100644
--- a/languages/classes/LanguageBe.php
+++ b/languages/classes/LanguageBe.php
@@ -7,7 +7,7 @@
* @ingroup Language
*
* @author Ævar Arnfjörð Bjarmason <avarab@gmail.com>
- * @link http://be.wikipedia.org/wiki/Talk:LanguageBe.php
+ * @see http://be.wikipedia.org/wiki/Talk:LanguageBe.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
*/
diff --git a/languages/classes/LanguageBe_tarask.php b/languages/classes/LanguageBe_tarask.php
index 25c3f700..0e07a71c 100644
--- a/languages/classes/LanguageBe_tarask.php
+++ b/languages/classes/LanguageBe_tarask.php
@@ -4,7 +4,7 @@
* @ingroup Language
*
* @author Ævar Arnfjörð Bjarmason <avarab@gmail.com>
- * @link http://be-x-old.wikipedia.org/wiki/Project_talk:LanguageBe_tarask.php
+ * @see 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
*/
@@ -27,7 +27,10 @@ class LanguageBe_tarask extends Language {
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 the actual number is not mentioned in the expression, then just two forms are enough:
+ // singular for $count == 1
+ // plural for $count != 1
+ // For example, "This user belongs to {{PLURAL:$1|one group|several groups}}."
if ( count( $forms ) === 2 ) return $count == 1 ? $forms[0] : $forms[1];
// @todo FIXME: CLDR defines 4 plural forms instead of 3
diff --git a/languages/classes/LanguageBs.php b/languages/classes/LanguageBs.php
index c501b35a..7c13037e 100644
--- a/languages/classes/LanguageBs.php
+++ b/languages/classes/LanguageBs.php
@@ -30,9 +30,10 @@ class LanguageBs extends Language {
}
}
- # Convert from the nominative form of a noun to some other case
- # Invoked with {{GRAMMAR:case|word}}
/**
+ * Convert from the nominative form of a noun to some other case
+ * Invoked with {{GRAMMAR:case|word}}
+ *
* Cases: genitiv, dativ, akuzativ, vokativ, instrumental, lokativ
*
* @param $word string
diff --git a/languages/classes/LanguageCy.php b/languages/classes/LanguageCy.php
index a3a28689..1b0863ac 100644
--- a/languages/classes/LanguageCy.php
+++ b/languages/classes/LanguageCy.php
@@ -15,8 +15,6 @@ class LanguageCy extends Language {
function convertPlural( $count, $forms ) {
if ( !count( $forms ) ) { return ''; }
- // @todo FIXME: CLDR defines 4 plural forms; very different, actually.
- // See http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/language_plural_rules.html#cy
$forms = $this->preConvertPlural( $forms, 6 );
$count = abs( $count );
if ( $count >= 0 && $count <= 3 ) {
diff --git a/languages/classes/LanguageGd.php b/languages/classes/LanguageGd.php
index 5fe3d058..737cddae 100644
--- a/languages/classes/LanguageGd.php
+++ b/languages/classes/LanguageGd.php
@@ -29,13 +29,13 @@ class LanguageGd extends Language {
$forms = $this->preConvertPlural( $forms, 6 );
$count = abs( $count );
- if ( $count === 1 ) {
+ if ( $count == 1 ) {
return $forms[0];
- } elseif ( $count === 2 ) {
+ } elseif ( $count == 2 ) {
return $forms[1];
- } elseif ( $count === 11 ) {
+ } elseif ( $count == 11 ) {
return $forms[2];
- } elseif ( $count === 12 ) {
+ } elseif ( $count == 12 ) {
return $forms[3];
} elseif ( ($count >= 3 && $count <= 10) || ($count >= 13 && $count <= 19) ) {
return $forms[4];
diff --git a/languages/classes/LanguageHe.php b/languages/classes/LanguageHe.php
index e65feee9..87483c65 100644
--- a/languages/classes/LanguageHe.php
+++ b/languages/classes/LanguageHe.php
@@ -39,7 +39,7 @@ class LanguageHe extends Language {
$word = substr( $word, 2 );
}
- # Add a hyphen if non-Hebrew letters
+ # Add a hyphen (maqaf) if non-Hebrew letters
if ( substr( $word, 0, 2 ) < "א" || substr( $word, 0, 2 ) > "ת" ) {
$word = "־" . $word;
}
@@ -59,12 +59,12 @@ class LanguageHe extends Language {
if ( !count( $forms ) ) { return ''; }
$forms = $this->preConvertPlural( $forms, 3 );
- if ( $count == '1' ) {
- return $forms[0];
- } elseif ( $count == '2' && isset( $forms[2] ) ) {
- return $forms[2];
+ if ( $count == 1 ) {
+ return $forms[0]; // Singular
+ } elseif ( $count == 2 ) {
+ return $forms[2]; // Dual or plural if dual is not provided (filled in preConvertPlural)
} else {
- return $forms[1];
+ return $forms[1]; // Plural
}
}
}
diff --git a/languages/classes/LanguageHu.php b/languages/classes/LanguageHu.php
index f82bab2f..dbb6f5bb 100644
--- a/languages/classes/LanguageHu.php
+++ b/languages/classes/LanguageHu.php
@@ -25,5 +25,6 @@ class LanguageHu extends Language {
case 'k':
return $word . 'k';
}
+ return '';
}
}
diff --git a/languages/classes/LanguageIu.php b/languages/classes/LanguageIu.php
index c6221dee..72f6af13 100644
--- a/languages/classes/LanguageIu.php
+++ b/languages/classes/LanguageIu.php
@@ -7,7 +7,7 @@
* Conversion script between Latin and Syllabics for Inuktitut.
* - Syllabics -> lowercase Latin
* - lowercase/uppercase Latin -> Syllabics
-*
+*
*
* Based on:
* - http://commons.wikimedia.org/wiki/Image:Inuktitut.png
@@ -21,6 +21,8 @@ require_once( dirname( __FILE__ ) . '/../LanguageConverter.php' );
*
*/
class IuConverter extends LanguageConverter {
+
+ protected $mDoContentConvert;
var $mToLatin = array(
'ᐦ' => 'h', 'ᐃ' => 'i', 'ᐄ' => 'ii', 'ᐅ' => 'u', 'ᐆ' => 'uu', 'ᐊ' => 'a', 'ᐋ' => 'aa',
'ᑉ' => 'p', 'ᐱ' => 'pi', 'ᐲ' => 'pii', 'ᐳ' => 'pu', 'ᐴ' => 'puu', 'ᐸ' => 'pa', 'ᐹ' => 'paa',
@@ -111,10 +113,7 @@ class IuConverter extends LanguageConverter {
* @return string
*/
function parserConvert( $text, &$parser ) {
- if ( is_object( $parser->getTitle() ) && $parser->getTitle()->isTalkPage() )
- $this->mDoContentConvert = false;
- else
- $this->mDoContentConvert = true;
+ $this->mDoContentConvert = !( is_object( $parser->getTitle() ) && $parser->getTitle()->isTalkPage() );
return parent::parserConvert( $text, $parser );
}
diff --git a/languages/classes/LanguageKk_cyrl.php b/languages/classes/LanguageKk_cyrl.php
index ba84bf93..30f74e6e 100644
--- a/languages/classes/LanguageKk_cyrl.php
+++ b/languages/classes/LanguageKk_cyrl.php
@@ -12,7 +12,7 @@ class LanguageKk_cyrl extends Language {
* Cases: genitive, dative, accusative, locative, ablative, comitative + possessive forms
*
* @param $word string
- * @param $case stirng
+ * @param $case string
*
* @return string
*/
diff --git a/languages/classes/LanguageLt.php b/languages/classes/LanguageLt.php
index 09cacae0..af38b6ae 100644
--- a/languages/classes/LanguageLt.php
+++ b/languages/classes/LanguageLt.php
@@ -12,6 +12,7 @@ class LanguageLt extends Language {
*/
/**
+ * Lithuanian plural forms as per http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/language_plural_rules.html#lt
* @param $count int
* @param $forms array
*
@@ -20,12 +21,13 @@ class LanguageLt extends Language {
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 the number is not mentioned in message, 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 );
-
+ // Form[0] if n mod 10 is 1 and n mod 100 not in 11..19;
if ( $count % 10 == 1 && $count % 100 != 11 ) return $forms[0];
+ // Forms[1] if n mod 10 in 2..9 and n mod 100 not in 11..19;
if ( $count % 10 >= 2 && ( $count % 100 < 10 || $count % 100 >= 20 ) ) return $forms[1];
return $forms[2];
}
diff --git a/languages/classes/LanguageMk.php b/languages/classes/LanguageMk.php
index 4ae7f412..4e3b576f 100644
--- a/languages/classes/LanguageMk.php
+++ b/languages/classes/LanguageMk.php
@@ -17,7 +17,7 @@ class LanguageMk extends Language {
function convertPlural( $count, $forms ) {
if ( !count( $forms ) ) { return ''; }
$forms = $this->preConvertPlural( $forms, 2 );
-
+ // TODO CLDR defines forms[0] for n != 11 and not for n%100 !== 11
if ( $count % 10 === 1 && $count % 100 !== 11 ) {
return $forms[0];
} else {
diff --git a/languages/classes/LanguageMo.php b/languages/classes/LanguageMo.php
index 5d78a502..2fa48e95 100644
--- a/languages/classes/LanguageMo.php
+++ b/languages/classes/LanguageMo.php
@@ -14,13 +14,14 @@ class LanguageMo extends Language {
function convertPlural( $count, $forms ) {
// Plural rules per
// http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/language_plural_rules.html#mo
+ // Identical to Romanian (ro).
if ( !count( $forms ) ) { return ''; }
$forms = $this->preConvertPlural( $forms, 3 );
if ( $count == 1 ) {
$index = 0;
- } elseif ( $count == 0 || $count % 100 < 20 ) {
+ } elseif ( $count == 0 || ( $count % 100 > 0 && $count % 100 < 20 ) ) {
$index = 1;
} else {
$index = 2;
diff --git a/languages/classes/LanguageMt.php b/languages/classes/LanguageMt.php
index ef143da5..5cf40ce5 100644
--- a/languages/classes/LanguageMt.php
+++ b/languages/classes/LanguageMt.php
@@ -19,8 +19,8 @@ class LanguageMt extends Language {
$forms = $this->preConvertPlural( $forms, 4 );
- if ( $count === 1 ) $index = 0;
- elseif ( $count === 0 || ( $count % 100 > 1 && $count % 100 < 11 ) ) $index = 1;
+ 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;
else $index = 3;
return $forms[$index];
diff --git a/languages/classes/LanguageQqx.php b/languages/classes/LanguageQqx.php
index 88d38f59..6798b24c 100644
--- a/languages/classes/LanguageQqx.php
+++ b/languages/classes/LanguageQqx.php
@@ -9,6 +9,10 @@
* @ingroup Language
*/
class LanguageQqx extends Language {
+ /**
+ * @param $key string
+ * @return string
+ */
function getMessage( $key ) {
return "($key)";
}
diff --git a/languages/classes/LanguageRo.php b/languages/classes/LanguageRo.php
index 9cfd8b57..ce3e5159 100644
--- a/languages/classes/LanguageRo.php
+++ b/languages/classes/LanguageRo.php
@@ -20,7 +20,7 @@ class LanguageRo extends Language {
if ( $count == 1 ) {
$index = 0;
- } elseif ( $count == 0 || $count % 100 < 20 ) {
+ } elseif ( $count == 0 || ( $count % 100 > 0 && $count % 100 < 20 ) ) {
$index = 1;
} else {
$index = 2;
diff --git a/languages/classes/LanguageRu.php b/languages/classes/LanguageRu.php
index e16761ad..b5371d2e 100644
--- a/languages/classes/LanguageRu.php
+++ b/languages/classes/LanguageRu.php
@@ -72,8 +72,10 @@ class LanguageRu extends Language {
* Examples:
* message with number
* "Сделано $1 {{PLURAL:$1|изменение|изменения|изменений}}"
+ * ("$1 change[s] were made)
* message without number
* "Действие не может быть выполнено по {{PLURAL:$1|следующей причине|следующим причинам}}:"
+ * ("The action cannot be performed for the following reason[s]")
* @param $count int
* @param $forms array
*
@@ -82,7 +84,10 @@ class LanguageRu extends Language {
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 the actual number is not mentioned in the expression, then just two forms are enough:
+ // singular for $count == 1
+ // plural for $count != 1
+ // For example, "This user belongs to {{PLURAL:$1|one group|several groups}}."
if ( count( $forms ) === 2 ) return $count == 1 ? $forms[0] : $forms[1];
// @todo FIXME: CLDR defines 4 plural forms. Form with decimals missing.
diff --git a/languages/classes/LanguageSgs.php b/languages/classes/LanguageSgs.php
index 8c10182d..d47863d0 100644
--- a/languages/classes/LanguageSgs.php
+++ b/languages/classes/LanguageSgs.php
@@ -17,7 +17,7 @@ class LanguageSgs extends Language {
$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 ) {
return $forms[0];
diff --git a/languages/classes/LanguageSr_el.deps.php b/languages/classes/LanguageShi.deps.php
index 67154c20..3b78d875 100644
--- a/languages/classes/LanguageSr_el.deps.php
+++ b/languages/classes/LanguageShi.deps.php
@@ -1,8 +1,8 @@
<?php
// This file exists to ensure that base classes are preloaded before
-// LanguageSr_el.php is compiled, working around a bug in the APC opcode
+// LanguageIu.php is compiled, working around a bug in the APC opcode
// cache on PHP 5, where cached code can break if the include order
// 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__).'/../LanguageConverter.php' );
diff --git a/languages/classes/LanguageShi.php b/languages/classes/LanguageShi.php
new file mode 100644
index 00000000..08a06d67
--- /dev/null
+++ b/languages/classes/LanguageShi.php
@@ -0,0 +1,202 @@
+<?php
+/**
+ * @addtogroup Language
+ */
+
+/*
+* Conversion script between Latin and Tifinagh for Tachelhit.
+* - Tifinagh -> lowercase Latin
+* - lowercase/uppercase Latin -> Tifinagh
+*
+*
+* Based on:
+* - http://en.wikipedia.org/wiki/Shilha_language
+* - LanguageSr.php
+*
+* @ingroup Language
+*/
+require_once( dirname( __FILE__ ) . '/../LanguageConverter.php' );
+
+/**
+ *
+ */
+class ShiConverter extends LanguageConverter {
+
+ protected $mDoContentConvert;
+
+ var $mToLatin = array(
+ 'ⴰ' => 'a', 'ⴱ' => 'b', 'ⴳ' => 'g', 'ⴷ' => 'd', 'ⴹ' => 'ḍ', 'ⴻ' => 'e',
+ 'ⴼ' => 'f', 'ⴽ' => 'k', 'ⵀ' => 'h', 'ⵃ' => 'ḥ', 'ⵄ' => 'ε', 'ⵅ' => 'x',
+ 'ⵇ' => 'q', 'ⵉ' => 'i', 'ⵊ' => 'j', 'ⵍ' => 'l', 'ⵎ' => 'm', 'ⵏ' => 'n',
+ 'ⵓ' => 'u', 'ⵔ' => 'r', 'ⵕ' => 'ṛ', 'ⵖ' => 'γ', 'ⵙ' => 's', 'ⵚ' => 'ṣ',
+ 'ⵛ' => 'š', 'ⵜ' => 't', 'ⵟ' => 'ṭ', 'ⵡ' => 'w', 'ⵢ' => 'y', 'ⵣ' => 'z',
+ 'ⵥ' => 'ẓ', 'ⵯ' => 'ʷ', 'ⵖ' => 'ɣ', 'ⵠ' => 'v', 'ⵒ' => 'p',
+ );
+
+ var $mUpperToLowerCaseLatin = array(
+ 'A' => 'a', 'B' => 'b', 'C' => 'c', 'D' => 'd', 'E' => 'e',
+ 'F' => 'f', 'G' => 'g', 'H' => 'h', 'I' => 'i', 'J' => 'j',
+ 'K' => 'k', 'L' => 'l', 'M' => 'm', 'N' => 'n', 'O' => 'o',
+ 'P' => 'p', 'Q' => 'q', 'R' => 'r', 'S' => 's', 'T' => 't',
+ 'U' => 'u', 'V' => 'v', 'W' => 'w', 'X' => 'x', 'Y' => 'y',
+ 'Z' => 'z', 'Ɣ' => 'ɣ',
+ );
+
+ var $mToTifinagh = array(
+ 'a' => 'ⴰ', 'b' => 'ⴱ', 'g' => 'ⴳ', 'd' => 'ⴷ', 'ḍ' => 'ⴹ', 'e' => 'ⴻ',
+ 'f' => 'ⴼ', 'k' => 'ⴽ', 'h' => 'ⵀ', 'ḥ' => 'ⵃ', 'ε' => 'ⵄ', 'x' => 'ⵅ',
+ 'q' => 'ⵇ', 'i' => 'ⵉ', 'j' => 'ⵊ', 'l' => 'ⵍ', 'm' => 'ⵎ', 'n' => 'ⵏ',
+ 'u' => 'ⵓ', 'r' => 'ⵔ', 'ṛ' => 'ⵕ', 'γ' => 'ⵖ', 's' => 'ⵙ', 'ṣ' => 'ⵚ',
+ 'š' => 'ⵛ', 't' => 'ⵜ', 'ṭ' => 'ⵟ', 'w' => 'ⵡ', 'y' => 'ⵢ', 'z' => 'ⵣ',
+ 'ẓ' => 'ⵥ', 'ʷ' => 'ⵯ', 'ɣ' => 'ⵖ', 'v' => 'ⵠ', 'p' => 'ⵒ',
+ );
+
+ function loadDefaultTables() {
+ $this->mTables = array(
+ 'lowercase' => new ReplacementArray( $this->mUpperToLowerCaseLatin ),
+ 'shi-tfng' => new ReplacementArray( $this->mToTifinagh ),
+ 'shi-latn' => new ReplacementArray( $this->mToLatin ),
+ 'shi' => new ReplacementArray()
+ );
+ }
+
+ /**
+ * rules should be defined as -{Tifinagh | Latin-} -or-
+ * -{code:text | code:text | ...}-
+ * update: delete all rule parsing because it's not used
+ * currently, and just produces a couple of bugs
+ *
+ * @param $rule string
+ * @param $flags array
+ * @return array
+ */
+ function parseManualRule( $rule, $flags = array() ) {
+ if ( in_array( 'T', $flags ) ) {
+ return parent::parseManualRule( $rule, $flags );
+ }
+
+ $carray = array();
+ // otherwise ignore all formatting
+ foreach ( $this->mVariants as $v ) {
+ $carray[$v] = $rule;
+ }
+
+ return $carray;
+ }
+
+ /**
+ * Do not convert content on talk pages
+ *
+ * @param $text string
+ * @param $parser Parser
+ * @return string
+ */
+ function parserConvert( $text, &$parser ) {
+ $this->mDoContentConvert = !( is_object( $parser->getTitle() ) && $parser->getTitle()->isTalkPage() );
+
+ return parent::parserConvert( $text, $parser );
+ }
+
+ /**
+ * A function wrapper:
+ * - if there is no selected variant, leave the link
+ * names as they were
+ * - do not try to find variants for usernames
+ *
+ * @param $link string
+ * @param $nt Title
+ * @param $ignoreOtherCond bool
+ */
+ function findVariantLink( &$link, &$nt, $ignoreOtherCond = false ) {
+ // check for user namespace
+ if ( is_object( $nt ) ) {
+ $ns = $nt->getNamespace();
+ if ( $ns == NS_USER || $ns == NS_USER_TALK )
+ return;
+ }
+
+ $oldlink = $link;
+ parent::findVariantLink( $link, $nt, $ignoreOtherCond );
+ 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
+ *
+ * @param $text string
+ * @param $noParse bool
+ *
+ * @return string
+ */
+ 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)
+ *
+ * @param $text string
+ * @param $toVariant bool
+ *
+ * @return string
+ */
+ function autoConvert( $text, $toVariant = false ) {
+ global $wgTitle;
+ if ( is_object( $wgTitle ) && $wgTitle->getNameSpace() == NS_FILE ) {
+ $imagename = $wgTitle->getNsText();
+ if ( preg_match( "/^$imagename:/", $text ) ) return $text;
+ }
+ return parent::autoConvert( $text, $toVariant );
+ }
+
+ /**
+ * It translates text into variant
+ *
+ * @param $text string
+ * @param $toVariant string
+ *
+ * @return string
+ */
+ function translate( $text, $toVariant ) {
+ // If $text is empty or only includes spaces, do nothing
+ // Otherwise translate it
+ if ( trim( $text ) ) {
+ $this->loadTables();
+ // To Tifinagh, first translate uppercase to lowercase Latin
+ if( $toVariant == 'shi-tfng' ) {
+ $text = $this->mTables['lowercase']->replace( $text );
+ }
+ $text = $this->mTables[$toVariant]->replace( $text );
+ }
+ return $text;
+ }
+}
+
+/**
+ * Tachelhit
+ *
+ * @ingroup Language
+ */
+class LanguageShi extends Language {
+ function __construct() {
+ global $wgHooks;
+
+ parent::__construct();
+
+ $variants = array( 'shi', 'shi-tfng', 'shi-latn' );
+ $variantfallbacks = array(
+ 'shi' => 'shi-tfng',
+ 'shi-tfng' => 'shi',
+ 'shi-latn' => 'shi',
+ );
+
+ $flags = array();
+ $this->mConverter = new ShiConverter( $this, 'shi', $variants, $variantfallbacks, $flags );
+ $wgHooks['ArticleSaveComplete'][] = $this->mConverter;
+ }
+}
diff --git a/languages/classes/LanguageSr.php b/languages/classes/LanguageSr.php
index b26a2543..2e1fb276 100644
--- a/languages/classes/LanguageSr.php
+++ b/languages/classes/LanguageSr.php
@@ -173,6 +173,32 @@ class SrConverter extends LanguageConverter {
return $ret;
}
+
+ /**
+ * Guess if a text is written in Cyrillic or Latin.
+ * Overrides LanguageConverter::guessVariant()
+ *
+ * @param string $text The text to be checked
+ * @param string $variant Language code of the variant to be checked for
+ * @return bool true if $text appears to be written in $variant
+ *
+ * @author Nikola Smolenski <smolensk@eunet.rs>
+ * @since 1.19
+ */
+ public function guessVariant( $text, $variant ) {
+ $numCyrillic = preg_match_all("/[шђчћжШЂЧЋЖ]/u", $text, $dummy);
+ $numLatin = preg_match_all("/[šđč枊ĐČĆŽ]/u", $text, $dummy);
+
+ if( $variant == 'sr-ec' ) {
+ return (boolean) ($numCyrillic > $numLatin);
+ } elseif( $variant == 'sr-el' ) {
+ return (boolean) ($numLatin > $numCyrillic);
+ } else {
+ return false;
+ }
+
+ }
+
}
/**
@@ -212,7 +238,10 @@ class LanguageSr extends LanguageSr_ec {
return '';
}
- // if no number with word, then use $form[0] for singular and $form[1] for plural or zero
+ // If the actual number is not mentioned in the expression, then just two forms are enough:
+ // singular for $count == 1
+ // plural for $count != 1
+ // For example, "This user belongs to {{PLURAL:$1|one group|several groups}}."
if ( count( $forms ) === 2 ) {
return $count == 1 ? $forms[0] : $forms[1];
}
diff --git a/languages/classes/LanguageTr.php b/languages/classes/LanguageTr.php
index cbc1b7e4..b6acea4b 100644
--- a/languages/classes/LanguageTr.php
+++ b/languages/classes/LanguageTr.php
@@ -17,7 +17,7 @@ class LanguageTr extends Language {
* @return string
*/
function ucfirst ( $string ) {
- if ( !empty( $string ) && $string[0] == 'i' ) {
+ if ( strlen( $string ) && $string[0] == 'i' ) {
return 'İ' . substr( $string, 1 );
} else {
return parent::ucfirst( $string );
@@ -29,7 +29,7 @@ class LanguageTr extends Language {
* @return mixed|string
*/
function lcfirst ( $string ) {
- if ( !empty( $string ) && $string[0] == 'I' ) {
+ if ( strlen( $string ) && $string[0] == 'I' ) {
return 'ı' . substr( $string, 1 );
} else {
return parent::lcfirst( $string );
diff --git a/languages/classes/LanguageUk.php b/languages/classes/LanguageUk.php
index 206c5aa3..14e5d272 100644
--- a/languages/classes/LanguageUk.php
+++ b/languages/classes/LanguageUk.php
@@ -71,7 +71,10 @@ class LanguageUk extends Language {
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 the actual number is not mentioned in the expression, then just two forms are enough:
+ // singular for $count == 1
+ // plural for $count != 1
+ // For example, "This user belongs to {{PLURAL:$1|one group|several groups}}."
if ( count( $forms ) === 2 ) return $count == 1 ? $forms[0] : $forms[1];
// @todo FIXME: CLDR defines 4 plural forms. Form for decimals is missing/