diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2006-10-11 20:21:25 +0000 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2006-10-11 20:21:25 +0000 |
commit | d81f562b712f2387fa02290bf2ca86392ab356f2 (patch) | |
tree | d666cdefbe6ac320827a2c6cb473581b46e22c4c /languages/classes | |
parent | 183851b06bd6c52f3cae5375f433da720d410447 (diff) |
Aktualisierung auf Version 1.8.1
Diffstat (limited to 'languages/classes')
38 files changed, 2363 insertions, 0 deletions
diff --git a/languages/classes/LanguageAz.php b/languages/classes/LanguageAz.php new file mode 100644 index 00000000..d5df3ecc --- /dev/null +++ b/languages/classes/LanguageAz.php @@ -0,0 +1,17 @@ +<?php +/** Azerbaijani (Azərbaycan) + * + * @package MediaWiki + * @subpackage Language + */ +class LanguageAz extends Language { + function ucfirst ( $string ) { + if ( $string[0] == 'i' ) { + return 'İ' . substr( $string, 1 ); + } else { + return parent::ucfirst( $string ); + } + } + +} +?> diff --git a/languages/classes/LanguageBe.php b/languages/classes/LanguageBe.php new file mode 100644 index 00000000..f2a52cca --- /dev/null +++ b/languages/classes/LanguageBe.php @@ -0,0 +1,89 @@ +<?php +/** Belarusian (Беларуская мова) + * + * @package MediaWiki + * @subpackage Language + * + * @author Ævar Arnfjörð Bjarmason <avarab@gmail.com> + * @bug 1638, 2135 + * @link 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 + */ + +class LanguageBe extends Language { + function convertPlural( $count, $wordform1, $wordform2, $wordform3) { + $count = str_replace ('.', '', $count); + if ($count > 10 && floor(($count % 100) / 10) == 1) { + return $wordform3; + } else { + switch ($count % 10) { + case 1: return $wordform1; + case 2: + case 3: + case 4: return $wordform2; + default: return $wordform3; + } + } + } + + # Convert from the nominative form of a noun to some other case + # Invoked with {{GRAMMAR:case|word}} + /** + * Cases: родны, вінавальны, месны + */ + function convertGrammar( $word, $case ) { + switch ( $case ) { + case 'родны': # genitive + if ( $word == 'Вікіпэдыя' ) { + $word = 'Вікіпэдыі'; + } elseif ( $word == 'ВікіСлоўнік' ) { + $word = 'ВікіСлоўніка'; + } elseif ( $word == 'ВікіКнігі' ) { + $word = 'ВікіКніг'; + } elseif ( $word == 'ВікіКрыніца' ) { + $word = 'ВікіКрыніцы'; + } elseif ( $word == 'ВікіНавіны' ) { + $word = 'ВікіНавін'; + } elseif ( $word == 'ВікіВіды' ) { + $word = 'ВікіВідаў'; + } + break; + case 'вінавальны': # akusative + if ( $word == 'Вікіпэдыя' ) { + $word = 'Вікіпэдыю'; + } elseif ( $word == 'ВікіСлоўнік' ) { + $word = 'ВікіСлоўнік'; + } elseif ( $word == 'ВікіКнігі' ) { + $word = 'ВікіКнігі'; + } elseif ( $word == 'ВікіКрыніца' ) { + $word = 'ВікіКрыніцу'; + } elseif ( $word == 'ВікіНавіны' ) { + $word = 'ВікіНавіны'; + } elseif ( $word == 'ВікіВіды' ) { + $word = 'ВікіВіды'; + } + break; + case 'месны': # prepositional + if ( $word == 'Вікіпэдыя' ) { + $word = 'Вікіпэдыі'; + } elseif ( $word == 'ВікіСлоўнік' ) { + $word = 'ВікіСлоўніку'; + } elseif ( $word == 'ВікіКнігі' ) { + $word = 'ВікіКнігах'; + } elseif ( $word == 'ВікіКрыніца' ) { + $word = 'ВікіКрыніцы'; + } elseif ( $word == 'ВікіНавіны' ) { + $word = 'ВікіНавінах'; + } elseif ( $word == 'ВікіВіды' ) { + $word = 'ВікіВідах'; + } + break; + } + + return $word; # this will return the original value for 'назоўны' (nominative) and all undefined case values + } + +} + +?> diff --git a/languages/classes/LanguageBg.php b/languages/classes/LanguageBg.php new file mode 100644 index 00000000..4884c2a8 --- /dev/null +++ b/languages/classes/LanguageBg.php @@ -0,0 +1,25 @@ +<?php +/** Bulgarian (Български) + * + * @package MediaWiki + * @subpackage Language + */ + +/** + * @package MediaWiki + * @subpackage Language + */ +class LanguageBg extends Language { + /** + * ISO number formatting: 123 456 789,99. + * Avoid tripple grouping by numbers with whole part up to 4 digits. + */ + function commafy($_) { + if (!preg_match('/^\d{1,4}$/',$_)) { + return strrev((string)preg_replace('/(\d{3})(?=\d)(?!\d*\.)/','$1,',strrev($_))); + } else { + return $_; + } + } +} +?> diff --git a/languages/classes/LanguageBs.php b/languages/classes/LanguageBs.php new file mode 100644 index 00000000..4734fdc1 --- /dev/null +++ b/languages/classes/LanguageBs.php @@ -0,0 +1,137 @@ +<?php +/** Bosnian (bosanski) + * + * @package MediaWiki + * @subpackage Language + */ + +class LanguageBs extends Language { + + function convertPlural( $count, $wordform1, $wordform2, $wordform3) { + $count = str_replace ('.', '', $count); + if ($count > 10 && floor(($count % 100) / 10) == 1) { + return $wordform3; + } else { + switch ($count % 10) { + case 1: return $wordform1; + case 2: + case 3: + case 4: return $wordform2; + default: return $wordform3; + } + } + } + + # Convert from the nominative form of a noun to some other case + # Invoked with {{GRAMMAR:case|word}} + /** + * Cases: genitiv, dativ, akuzativ, vokativ, instrumental, lokativ + */ + function convertGrammar( $word, $case ) { + global $wgGrammarForms; + if ( isset($wgGrammarForms['bs'][$case][$word]) ) { + return $wgGrammarForms['bs'][$case][$word]; + } + switch ( $case ) { + case 'genitiv': # genitive + if ( $word == 'Wikipedia' ) { + $word = 'Wikipedije'; + } elseif ( $word == 'Wikiknjige' ) { + $word = 'Wikiknjiga'; + } elseif ( $word == 'Wikivijesti' ) { + $word = 'Wikivijesti'; + } elseif ( $word == 'Wikicitati' ) { + $word = 'Wikicitata'; + } elseif ( $word == 'Wikiizvor' ) { + $word = 'Wikiizvora'; + } elseif ( $word == 'Vikirječnik' ) { + $word = 'Vikirječnika'; + } + break; + case 'dativ': # dative + if ( $word == 'Wikipedia' ) { + $word = 'Wikipediji'; + } elseif ( $word == 'Wikiknjige' ) { + $word = 'Wikiknjigama'; + } elseif ( $word == 'Wikicitati' ) { + $word = 'Wikicitatima'; + } elseif ( $word == 'Wikivijesti' ) { + $word = 'Wikivijestima'; + } elseif ( $word == 'Wikiizvor' ) { + $word = 'Wikiizvoru'; + } elseif ( $word == 'Vikirječnik' ) { + $word = 'Vikirječniku'; + } + break; + case 'akuzativ': # akusative + if ( $word == 'Wikipedia' ) { + $word = 'Wikipediju'; + } elseif ( $word == 'Wikiknjige' ) { + $word = 'Wikiknjige'; + } elseif ( $word == 'Wikicitati' ) { + $word = 'Wikicitate'; + } elseif ( $word == 'Wikivijesti' ) { + $word = 'Wikivijesti'; + } elseif ( $word == 'Wikiizvor' ) { + $word = 'Wikiizvora'; + } elseif ( $word == 'Vikirječnik' ) { + $word = 'Vikirječnika'; + } + break; + case 'vokativ': # vocative + if ( $word == 'Wikipedia' ) { + $word = 'Wikipedijo'; + } elseif ( $word == 'Wikiknjige' ) { + $word = 'Wikiknjige'; + } elseif ( $word == 'Wikicitati' ) { + $word = 'Wikicitati'; + } elseif ( $word == 'Wikivijesti' ) { + $word = 'Wikivijesti'; + } elseif ( $word == 'Wikiizvor' ) { + $word = 'Wikizivoru'; + } elseif ( $word == 'Vikirječnik' ) { + $word = 'Vikirječniče'; + } + break; + case 'instrumental': # instrumental + if ( $word == 'Wikipedia' ) { + $word = 's Wikipediom'; + } elseif ( $word == 'Wikiknjige' ) { + $word = 's Wikiknjigama'; + } elseif ( $word == 'Wikicitati' ) { + $word = 's Wikicitatima'; + } elseif ( $word == 'Wikivijesti' ) { + $word = 's Wikivijestima'; + } elseif ( $word == 'Wikiizvor' ) { + $word = 's Wikiizvorom'; + } elseif ( $word == 'Vikirječnik' ) { + $word = 's Vikirječnikom'; + } else { + $word = 's ' . $word; + } + break; + case 'lokativ': # locative + if ( $word == 'Wikipedia' ) { + $word = 'o Wikipediji'; + } elseif ( $word == 'Wikiknjige' ) { + $word = 'o Wikiknjigama'; + } elseif ( $word == 'Wikicitati' ) { + $word = 'o Wikicitatima'; + } elseif ( $word == 'Wikivijesti' ) { + $word = 'o Wikivijestima'; + } elseif ( $word == 'Wikiizvor' ) { + $word = 'o Wikiizvoru'; + } elseif ( $word == 'Vikirječnik' ) { + $word = 'o Vikirječniku'; + } else { + $word = 'o ' . $word; + } + break; + } + + return $word; # this will return the original value for 'nominativ' (nominative) and all undefined case values + } + +} + +?> diff --git a/languages/classes/LanguageCs.php b/languages/classes/LanguageCs.php new file mode 100644 index 00000000..6b8d3d61 --- /dev/null +++ b/languages/classes/LanguageCs.php @@ -0,0 +1,87 @@ +<?php +/** Czech (česky) + * + * @package MediaWiki + * @subpackage Language + */ + +#-------------------------------------------------------------------------- +# Internationalisation code +#-------------------------------------------------------------------------- + +class LanguageCs extends Language { + # Grammatical transformations, needed for inflected languages + # Invoked by putting {{grammar:case|word}} in a message + function convertGrammar( $word, $case ) { + global $wgGrammarForms; + if ( isset($wgGrammarForms['cs'][$case][$word]) ) { + return $wgGrammarForms['cs'][$case][$word]; + } + # allowed values for $case: + # 1sg, 2sg, ..., 7sg -- nominative, genitive, ... (in singular) + switch ( $word ) { + case 'Wikipedia': + case 'Wikipedie': + switch ( $case ) { + case '3sg': + case '4sg': + case '6sg': + return 'Wikipedii'; + case '7sg': + return 'Wikipedií'; + default: + return 'Wikipedie'; + } + + case 'Wiktionary': + case 'Wikcionář': + switch ( $case ) { + case '2sg': + return 'Wikcionáře'; + case '3sg': + case '5sg'; + case '6sg'; + return 'Wikcionáři'; + case '7sg': + return 'Wikcionářem'; + default: + return 'Wikcionář'; + } + + case 'Wikiquote': + case 'Wikicitáty': + switch ( $case ) { + case '2sg': + return 'Wikicitátů'; + case '3sg': + return 'Wikicitátům'; + case '6sg'; + return 'Wikicitátech'; + default: + return 'Wikicitáty'; + } + } + # unknown + return $word; + } + + # Plural form transformations, needed for some languages. + # Invoked by {{plural:count|wordform1|wordform2|wordform3}} + function convertPlural( $count, $wordform1, $wordform2, $wordform3) { + $count = str_replace( '\xc2\xa0', '', $count ); + switch ( $count ) { + case 1: + return $wordform1; + + case 2: + case 3: + case 4: + return $wordform2; + + default: + return $wordform3; + }; + } +} + +?> diff --git a/languages/classes/LanguageEo.php b/languages/classes/LanguageEo.php new file mode 100644 index 00000000..a62ccc9b --- /dev/null +++ b/languages/classes/LanguageEo.php @@ -0,0 +1,74 @@ +<?php +/** Esperanto (Esperanto) + * @package MediaWiki + * @subpackage Language + */ + +class LanguageEo extends Language { + function iconv( $in, $out, $string ) { + # For most languages, this is a wrapper for iconv + # Por multaj lingvoj, ĉi tiu nur voku la sisteman funkcion iconv() + # Ni ankaŭ konvertu X-sistemajn surogotajn + if( strcasecmp( $in, 'x' ) == 0 and strcasecmp( $out, 'utf-8' ) == 0) { + $xu = array ( + 'xx' => 'x' , 'xX' => 'x' , + 'Xx' => 'X' , 'XX' => 'X' , + "Cx" => "\xc4\x88" , "CX" => "\xc4\x88" , + "cx" => "\xc4\x89" , "cX" => "\xc4\x89" , + "Gx" => "\xc4\x9c" , "GX" => "\xc4\x9c" , + "gx" => "\xc4\x9d" , "gX" => "\xc4\x9d" , + "Hx" => "\xc4\xa4" , "HX" => "\xc4\xa4" , + "hx" => "\xc4\xa5" , "hX" => "\xc4\xa5" , + "Jx" => "\xc4\xb4" , "JX" => "\xc4\xb4" , + "jx" => "\xc4\xb5" , "jX" => "\xc4\xb5" , + "Sx" => "\xc5\x9c" , "SX" => "\xc5\x9c" , + "sx" => "\xc5\x9d" , "sX" => "\xc5\x9d" , + "Ux" => "\xc5\xac" , "UX" => "\xc5\xac" , + "ux" => "\xc5\xad" , "uX" => "\xc5\xad" + ) ; + return preg_replace ( '/([cghjsu]x?)((?:xx)*)(?!x)/ei', + 'strtr( "$1", $xu ) . strtr( "$2", $xu )', $string ); + } else if( strcasecmp( $in, 'UTF-8' ) == 0 and strcasecmp( $out, 'x' ) == 0 ) { + $ux = array ( + 'x' => 'xx' , 'X' => 'Xx' , + "\xc4\x88" => "Cx" , "\xc4\x89" => "cx" , + "\xc4\x9c" => "Gx" , "\xc4\x9d" => "gx" , + "\xc4\xa4" => "Hx" , "\xc4\xa5" => "hx" , + "\xc4\xb4" => "Jx" , "\xc4\xb5" => "jx" , + "\xc5\x9c" => "Sx" , "\xc5\x9d" => "sx" , + "\xc5\xac" => "Ux" , "\xc5\xad" => "ux" + ) ; + # Double Xs only if they follow cxapelutaj literoj. + return preg_replace( '/((?:[cghjsu]|\xc4[\x88\x89\x9c\x9d\xa4\xa5\xb4\xb5]'. + '|\xc5[\x9c\x9d\xac\xad])x*)/ei', 'strtr( "$1", $ux )', $string ); + } + return iconv( $in, $out, $string ); + } + + function checkTitleEncoding( $s ) { + # Check for X-system backwards-compatibility URLs + $ishigh = preg_match( '/[\x80-\xff]/', $s); + $isutf = preg_match( '/^([\x00-\x7f]|[\xc0-\xdf][\x80-\xbf]|' . + '[\xe0-\xef][\x80-\xbf]{2}|[\xf0-\xf7][\x80-\xbf]{3})+$/', $s ); + + if($ishigh and !$isutf) { + # Assume Latin1 + $s = utf8_encode( $s ); + } else { + if( preg_match( '/(\xc4[\x88\x89\x9c\x9d\xa4\xa5\xb4\xb5]'. + '|\xc5[\x9c\x9d\xac\xad])/', $s ) ) + return $s; + } + + //if( preg_match( '/[cghjsu]x/i', $s ) ) + // return $this->iconv( 'x', 'utf-8', $s ); + return $s; + } + + function initEncoding() { + global $wgEditEncoding; + $wgEditEncoding = 'x'; + } +} + +?> diff --git a/languages/classes/LanguageEt.php b/languages/classes/LanguageEt.php new file mode 100644 index 00000000..92843406 --- /dev/null +++ b/languages/classes/LanguageEt.php @@ -0,0 +1,21 @@ +<?php +/** Estonian (Eesti) + * + * @package MediaWiki + * @subpackage Language + * + */ + +class LanguageEt extends Language { + /** + * Avoid grouping whole numbers between 0 to 9999 + */ + function commafy($_) { + if (!preg_match('/^\d{1,4}$/',$_)) { + return strrev((string)preg_replace('/(\d{3})(?=\d)(?!\d*\.)/','$1,',strrev($_))); + } else { + return $_; + } + } +} +?> diff --git a/languages/classes/LanguageFi.php b/languages/classes/LanguageFi.php new file mode 100644 index 00000000..47dd0e65 --- /dev/null +++ b/languages/classes/LanguageFi.php @@ -0,0 +1,165 @@ +<?php +/** Finnish (Suomi) + * + * @package MediaWiki + * @subpackage Language + * + * @author Niklas Laxström + */ +class LanguageFi extends Language { + /** + * Avoid grouping whole numbers between 0 to 9999 + */ + function commafy($_) { + if (!preg_match('/^\d{1,4}$/',$_)) { + return strrev((string)preg_replace('/(\d{3})(?=\d)(?!\d*\.)/','$1,',strrev($_))); + } else { + return $_; + } + } + + # 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['fi'][$case][$word]) ) { + return $wgGrammarForms['fi'][$case][$word]; + } + + # These rules are not perfect, but they are currently only used for site names so it doesn't + # matter if they are wrong sometimes. Just add a special case for your site name if necessary. + switch ( $case ) { + case 'genitive': + if ( $word == 'Wikisitaatit' ) { + $word = 'Wikisitaattien'; + } else { + $word .= 'n'; + } + break; + case 'elative': + if ( $word == 'Wikisitaatit' ) { + $word = 'Wikisitaateista'; + } else { + if ( mb_substr($word, -1) == 'y' ) { + $word .= 'stä'; + } else { + $word .= 'sta'; + } + } + break; + case 'partitive': + if ( $word == 'Wikisitaatit' ) { + $word = 'Wikisitaatteja'; + } else { + if ( mb_substr($word, -1) == 'y' ) { + $word .= 'ä'; + } else { + $word .= 'a'; + } + } + break; + case 'illative': + # Double the last letter and add 'n' + # mb_substr has a compatibility function in GlobalFunctions.php + if ( $word == 'Wikisitaatit' ) { + $word = 'Wikisitaatteihin'; + } else { + $word = $word . mb_substr($word,-1) . 'n'; + } + break; + case 'inessive': + if ( $word == 'Wikisitaatit' ) { + $word = 'Wikisitaateissa'; + } else { + if ( mb_substr($word, -1) == 'y' ) { + $word .= 'ssä'; + } else { + $word .= 'ssa'; + } + } + break; + + } + return $word; + } + + function translateBlockExpiry( $str ) { + /* + 'ago', 'now', 'today', 'this', 'next', + 'first', 'third', 'fourth', 'fifth', 'sixth', 'seventh', 'eighth', 'ninth', 'tenth', 'eleventh', 'twelfth', + 'tomorrow', 'yesterday' + + $months = 'january:tammikuu,february:helmikuu,march:maaliskuu,april:huhtikuu,may:toukokuu,june:kesäkuu,' . + 'july:heinäkuu,august:elokuu,september:syyskuu,october:lokakuu,november:marraskuu,december:joulukuu,' . + 'jan:tammikuu,feb:helmikuu,mar:maaliskuu,apr:huhtikuu,jun:kesäkuu,jul:heinäkuu,aug:elokuu,sep:syyskuu,'. + 'oct:lokakuu,nov:marraskuu,dec:joulukuu,sept:syyskuu'; + */ + $weekds = array( + 'monday' => 'maanantai', + 'tuesday' => 'tiistai', + 'wednesday' => 'keskiviikko', + 'thursay' => 'torstai', + 'friday' => 'perjantai', + 'saturday' => 'lauantai', + 'sunday' => 'sunnuntai', + 'mon' => 'ma', + 'tue' => 'ti', + 'tues' => 'ti', + 'wed' => 'ke', + 'wednes' => 'ke', + 'thu' => 'to', + 'thur' => 'to', + 'thurs' => 'to', + 'fri' => 'pe', + 'sat' => 'la', + 'sun' => 'su', + 'next' => 'seuraava', + 'tomorrow' => 'huomenna', + 'ago' => 'sitten', + 'seconds' => 'sekuntia', + 'second' => 'sekunti', + 'secs' => 's', + 'sec' => 's', + 'minutes' => 'minuuttia', + 'minute' => 'minuutti', + 'mins' => 'min', + 'min' => 'min', + 'days' => 'päivää', + 'day' => 'päivä', + 'hours' => 'tuntia', + 'hour' => 'tunti', + 'weeks' => 'viikkoa', + 'week' => 'viikko', + 'fortnights' => 'tuplaviikkoa', + 'fortnight' => 'tuplaviikko', + 'months' => 'kuukautta', + 'month' => 'kuukausi', + 'years' => 'vuotta', + 'year' => 'vuosi', + 'infinite' => 'ikuisesti', + 'indefinite' => 'ikuisesti' + ); + + $final = ''; + $tokens = explode ( ' ', $str); + foreach( $tokens as $item ) { + if ( !is_numeric($item) ) { + if ( count ( explode( '-', $item ) ) == 3 && strlen($item) == 10 ) { + list( $yyyy, $mm, $dd ) = explode( '-', $item ); + $final .= ' ' . $this->date( "{$yyyy}{$mm}{$dd}00000000"); + continue; + } + if( isset( $weekds[$item] ) ) { + $final .= ' ' . $weekds[$item]; + continue; + } + } + + $final .= ' ' . $item; + } + return '<span class="blockexpiry" title="' . htmlspecialchars($str). '">”' . trim( $final ) . '”</span>'; + } + +} + +?> diff --git a/languages/classes/LanguageFr.php b/languages/classes/LanguageFr.php new file mode 100644 index 00000000..61cd91c6 --- /dev/null +++ b/languages/classes/LanguageFr.php @@ -0,0 +1,17 @@ +<?php +/** French (Français) + * + * @package MediaWiki + * @subpackage Language + * + */ + +class LanguageFr extends Language { + /** + * Use singular form for zero (see bug 7309) + */ + function convertPlural( $count, $w1, $w2, $w3) { + return $count <= '1' ? $w1 : $w2; + } +} +?> diff --git a/languages/classes/LanguageGa.php b/languages/classes/LanguageGa.php new file mode 100644 index 00000000..0779e42b --- /dev/null +++ b/languages/classes/LanguageGa.php @@ -0,0 +1,52 @@ +<?php +/** Irish (Gaeilge) + * + * @package MediaWiki + * @subpackage Language + */ + +class LanguageGa extends Language { + # Convert day names + # Invoked with {{GRAMMAR:transformation|word}} + function convertGrammar( $word, $case ) { + global $wgGrammarForms; + if ( isset($wgGrammarForms['ga'][$case][$word]) ) { + return $wgGrammarForms['ga'][$case][$word]; + } + + switch ( $case ) { + case 'genitive': + switch ($word) { + case 'Vicipéid': $word = 'Vicipéide'; break; + case 'Vicífhoclóir': $word = 'Vicífhoclóra'; break; + case 'Vicíleabhair': $word = 'Vicíleabhar'; break; + case 'Vicíshliocht': $word = 'Vicíshleachta'; break; + case 'Vicífhoinse': $word = 'Vicífhoinse'; break; + case 'Vicíghnéithe': $word = 'Vicíghnéithe'; break; + case 'Vicínuacht': $word = 'Vicínuachta'; break; + } + + case 'ainmlae': + switch ($word) { + case 'an Domhnach': + $word = 'Dé Domhnaigh'; break; + case 'an Luan': + $word = 'Dé Luain'; break; + case 'an Mháirt': + $word = 'Dé Mháirt'; break; + case 'an Chéadaoin': + $word = 'Dé Chéadaoin'; break; + case 'an Déardaoin': + $word = 'Déardaoin'; break; + case 'an Aoine': + $word = 'Dé hAoine'; break; + case 'an Satharn': + $word = 'Dé Sathairn'; break; + } + } + return $word; + } + +} + +?> diff --git a/languages/classes/LanguageGsw.php b/languages/classes/LanguageGsw.php new file mode 100644 index 00000000..ce4e0578 --- /dev/null +++ b/languages/classes/LanguageGsw.php @@ -0,0 +1,69 @@ +<?php +/** Alemannic (Alemannisch) + * + * @package MediaWiki + * @subpackage Language + */ + +class LanguageGsw extends Language { + # Convert from the nominative form of a noun to some other case + # Invoked with result + + function convertGrammar( $word, $case ) { + global $wgGrammarForms; + if ( isset($wgGrammarForms['gsw'][$case][$word]) ) { + return $wgGrammarForms['gsw'][$case][$word]; + } + switch ( $case ) { + case 'dativ': + if ( $word == 'Wikipedia' ) { + $word = 'vo de Wikipedia'; + } elseif ( $word == 'Wikinorchrichte' ) { + $word = 'vo de Wikinochrichte'; + } elseif ( $word == 'Wiktionaire' ) { + $word = 'vom Wiktionaire'; + } elseif ( $word == 'Wikibuecher' ) { + $word = 'vo de Wikibuecher'; + } elseif ( $word == 'Wikisprüch' ) { + $word = 'vo de Wikisprüch'; + } elseif ( $word == 'Wikiquälle' ) { + $word = 'vo de Wikiquälle'; + } + break; + case 'akkusativ': + if ( $word == 'Wikipedia' ) { + $word = 'd Wikipedia'; + } elseif ( $word == 'Wikinorchrichte' ) { + $word = 'd Wikinochrichte'; + } elseif ( $word == 'Wiktionaire' ) { + $word = 's Wiktionaire'; + } elseif ( $word == 'Wikibuecher' ) { + $word = 'd Wikibuecher'; + } elseif ( $word == 'Wikisprüch' ) { + $word = 'd Wikisprüch'; + } elseif ( $word == 'Wikiquälle' ) { + $word = 'd Wikiquälle'; + } + break; + case 'nominativ': + if ( $word == 'Wikipedia' ) { + $word = 'd Wikipedia'; + } elseif ( $word == 'Wikinorchrichte' ) { + $word = 'd Wikinochrichte'; + } elseif ( $word == 'Wiktionaire' ) { + $word = 's Wiktionaire'; + } elseif ( $word == 'Wikibuecher' ) { + $word = 'd Wikibuecher'; + } elseif ( $word == 'Wikisprüch' ) { + $word = 'd Wikisprüch'; + } elseif ( $word == 'Wikiquälle' ) { + $word = 'd Wikiquälle'; + } + break; + } + return $word; + } + +} + +?> diff --git a/languages/classes/LanguageHe.php b/languages/classes/LanguageHe.php new file mode 100644 index 00000000..70de3115 --- /dev/null +++ b/languages/classes/LanguageHe.php @@ -0,0 +1,70 @@ +<?php +/** + * Hebrew (עברית) + * + * @package MediaWiki + * @subpackage Language + * + * @author Rotem Liss + */ + +class LanguageHe extends Language { + /** + * Convert grammar forms of words. + * + * Available cases: + * "prefixed" (or "תחילית") - when the word has a prefix + * + * @param string the word to convert + * @param string the case + */ + public function convertGrammar( $word, $case ) { + global $wgGrammarForms; + if ( isset($wgGrammarForms['he'][$case][$word]) ) { + return $wgGrammarForms['he'][$case][$word]; + } + + switch ( $case ) { + case 'prefixed': + case 'תחילית': + # Duplicate the "Waw" if prefixed + if ( substr( $word, 0, 2 ) == "ו" && substr( $word, 0, 4 ) != "וו" ) { + $word = "ו".$word; + } + + # Remove the "He" if prefixed + if ( substr( $word, 0, 2 ) == "ה" ) { + $word = substr( $word, 2 ); + } + + # Add a hyphen if non-Hebrew letters + if ( substr( $word, 0, 2 ) < "א" || substr( $word, 0, 2 ) > "ת" ) { + $word = "־".$word; + } + } + + return $word; + } + + /** + * Gets a number and uses the suited form of the word. + * + * @param integer the number of items + * @param string the first form (singular) + * @param string the second form (plural) + * @param string the third form (2 items, plural is used if not applicable and not specified) + * + * @return string of the suited form of word + */ + public function convertPlural( $count, $w1, $w2, $w3) { + if ( $count == '1' ) { + return $w1; + } elseif ( $count == '2' && $w3 ) { + return $w3; + } else { + return $w2; + } + } +} + +?> diff --git a/languages/classes/LanguageHr.php b/languages/classes/LanguageHr.php new file mode 100644 index 00000000..b1f6b0fc --- /dev/null +++ b/languages/classes/LanguageHr.php @@ -0,0 +1,26 @@ +<?php +/** Croatian (hrvatski) + * + * @package MediaWiki + * @subpackage Language + */ + +class LanguageHr extends Language { + function convertPlural( $count, $wordform1, $wordform2, $wordform3) { + $count = str_replace ('.', '', $count); + if ($count > 10 && floor(($count % 100) / 10) == 1) { + return $wordform3; + } else { + switch ($count % 10) { + case 1: return $wordform1; + case 2: + case 3: + case 4: return $wordform2; + default: return $wordform3; + } + } + } + +} + +?> diff --git a/languages/classes/LanguageHu.php b/languages/classes/LanguageHu.php new file mode 100644 index 00000000..ac6555dc --- /dev/null +++ b/languages/classes/LanguageHu.php @@ -0,0 +1,53 @@ +<?php +/** + * @package MediaWiki + * @subpackage Language + */ +# +# Hungarian localisation for MediaWiki +# + +class LanguageHu extends Language { + function convertGrammar( $word, $case ) { + global $wgGrammarForms; + if ( isset($wgGrammarForms[$this->getCode()][$case][$word]) ) { + return $wgGrammarForms[$this->getCode()][$case][$word]; + } + + static $localForms = array( + 'rol' => array( + 'Wikipédia' => 'Wikipédiáról', + 'Wikidézet' => 'Wikidézetről', + 'Wikiszótár' => 'Wikiszótárról', + 'Wikikönyvek' => 'Wikikönyvekről', + ), + 'ba' => array( + 'Wikipédia' => 'Wikipédiába', + 'Wikidézet' => 'Wikidézetbe', + 'Wikiszótár' => 'Wikiszótárba', + 'Wikikönyvek' => 'Wikikönyvekbe', + ), + 'k' => array( + 'Wikipédia' => 'Wikipédiák', + 'Wikidézet' => 'Wikidézetek', + 'Wikiszótár' => 'Wikiszótárak', + 'Wikikönyvek' => 'Wikikönyvek', + ) + ); + + if ( isset( $localForms[$case][$word] ) ) { + return $localForms[$case][$word]; + } + + switch ( $case ) { + case 'rol': + return $word . 'ról'; + case 'ba': + return $word . 'ba'; + case 'k': + return $word . 'k'; + } + } +} + +?> diff --git a/languages/classes/LanguageJa.php b/languages/classes/LanguageJa.php new file mode 100644 index 00000000..800650b0 --- /dev/null +++ b/languages/classes/LanguageJa.php @@ -0,0 +1,42 @@ +<?php +/** + * Japanese (日本語) + * + * @package MediaWiki + * @subpackage Language + */ +class LanguageJa extends Language { + function stripForSearch( $string ) { + # MySQL fulltext index doesn't grok utf-8, so we + # need to fold cases and convert to hex + $s = $string; + + # Strip known punctuation ? + #$s = preg_replace( '/\xe3\x80[\x80-\xbf]/', '', $s ); # U3000-303f + + # Space strings of like hiragana/katakana/kanji + $hiragana = '(?:\xe3(?:\x81[\x80-\xbf]|\x82[\x80-\x9f]))'; # U3040-309f + $katakana = '(?:\xe3(?:\x82[\xa0-\xbf]|\x83[\x80-\xbf]))'; # U30a0-30ff + $kanji = '(?:\xe3[\x88-\xbf][\x80-\xbf]' + . '|[\xe4-\xe8][\x80-\xbf]{2}' + . '|\xe9[\x80-\xa5][\x80-\xbf]' + . '|\xe9\xa6[\x80-\x99])'; + # U3200-9999 = \xe3\x88\x80-\xe9\xa6\x99 + $s = preg_replace( "/({$hiragana}+|{$katakana}+|{$kanji}+)/", ' $1 ', $s ); + + # Double-width roman characters: ff00-ff5f ~= 0020-007f + $s = preg_replace( '/\xef\xbc([\x80-\xbf])/e', 'chr((ord("$1") & 0x3f) + 0x20)', $s ); + $s = preg_replace( '/\xef\xbd([\x80-\x99])/e', 'chr((ord("$1") & 0x3f) + 0x60)', $s ); + + # Do general case folding and UTF-8 armoring + return parent::stripForSearch( $s ); + } + + # Italic is not appropriate for Japanese script + # Unfortunately most browsers do not recognise this, and render <em> as italic + function emphasize( $text ) { + return $text; + } +} + +?> diff --git a/languages/classes/LanguageKo.php b/languages/classes/LanguageKo.php new file mode 100644 index 00000000..55d28117 --- /dev/null +++ b/languages/classes/LanguageKo.php @@ -0,0 +1,57 @@ +<?php +/** Korean (한국어) + * + * @package MediaWiki + * @subpackage Language + */ + +class LanguageKo extends Language { + function firstChar( $s ) { + preg_match( '/^([\x00-\x7f]|[\xc0-\xdf][\x80-\xbf]|' . + '[\xe0-\xef][\x80-\xbf]{2}|[\xf0-\xf7][\x80-\xbf]{3})/', $s, $matches); + + if ( isset( $matches[1] ) ) { + if ( strlen( $matches[1] ) != 3 ) { + return $matches[1]; + } + $code = (ord($matches[1]{0}) & 0x0f) << 12; + $code |= (ord($matches[1]{1}) & 0x3f) << 6; + $code |= (ord($matches[1]{2}) & 0x3f); + if ( $code < 0xac00 || 0xd7a4 <= $code) { + return $matches[1]; + } elseif ( $code < 0xb098 ) { + return "\xe3\x84\xb1"; + } elseif ( $code < 0xb2e4 ) { + return "\xe3\x84\xb4"; + } elseif ( $code < 0xb77c ) { + return "\xe3\x84\xb7"; + } elseif ( $code < 0xb9c8 ) { + return "\xe3\x84\xb9"; + } elseif ( $code < 0xbc14 ) { + return "\xe3\x85\x81"; + } elseif ( $code < 0xc0ac ) { + return "\xe3\x85\x82"; + } elseif ( $code < 0xc544 ) { + return "\xe3\x85\x85"; + } elseif ( $code < 0xc790 ) { + return "\xe3\x85\x87"; + } elseif ( $code < 0xcc28 ) { + return "\xe3\x85\x88"; + } elseif ( $code < 0xce74 ) { + return "\xe3\x85\x8a"; + } elseif ( $code < 0xd0c0 ) { + return "\xe3\x85\x8b"; + } elseif ( $code < 0xd30c ) { + return "\xe3\x85\x8c"; + } elseif ( $code < 0xd558 ) { + return "\xe3\x85\x8d"; + } else { + return "\xe3\x85\x8e"; + } + } else { + return ""; + } + } +} + +?> diff --git a/languages/classes/LanguageKsh.php b/languages/classes/LanguageKsh.php new file mode 100644 index 00000000..412a00f4 --- /dev/null +++ b/languages/classes/LanguageKsh.php @@ -0,0 +1,35 @@ +<?php +/** Ripuarian (Ripoarėsh) + * + * @package MediaWiki + * @subpackage Language + * + * @author Purodha Blissenbach + */ + +class LanguageKsh extends Language { + /** + * Avoid grouping whole numbers between 0 to 9999 + */ + public function commafy( $_ ) { + if ( !preg_match( '/^\d{1,4}$/', $_ ) ) { + return strrev( (string)preg_replace( '/(\d{3})(?=\d)(?!\d*\.)/', '$1 ', strrev( $_ ) ) ); + } else { + return $_; + } + } + /** + * Handle cases of (1, other, 0) or (1, other) + */ + public function convertPlural( $count, $w1, $w2, $w3 ) { + $count = str_replace (' ', '', $count); + if ( $count == '1' ) { + return $w1; + } elseif ( $count == '0' && $w3 ) { + return $w3; + } else { + return $w2; + } + } +} +?> diff --git a/languages/classes/LanguageLa.php b/languages/classes/LanguageLa.php new file mode 100644 index 00000000..b9f69925 --- /dev/null +++ b/languages/classes/LanguageLa.php @@ -0,0 +1,37 @@ +<?php +/** Latin (lingua Latina) + * + * @package MediaWiki + * @subpackage Language + */ + +class LanguageLa extends Language { + /** + * Convert from the nominative form of a noun to some other case + * + * Just used in a couple places for sitenames; special-case as necessary. + * Rules are far from complete. + * + * Cases: genitive + */ + function convertGrammar( $word, $case ) { + global $wgGrammarForms; + if ( isset($wgGrammarForms['la'][$case][$word]) ) { + return $wgGrammarForms['la'][$case][$word]; + } + + switch ( $case ) { + case 'genitive': + // 1st and 2nd declension singular only. + $in = array( '/a$/', '/u[ms]$/', '/tio$/' ); + $out = array( 'ae', 'i', 'tionis' ); + return preg_replace( $in, $out, $word ); + default: + return $word; + } + } + +} + + +?> diff --git a/languages/classes/LanguageLt.php b/languages/classes/LanguageLt.php new file mode 100644 index 00000000..53729006 --- /dev/null +++ b/languages/classes/LanguageLt.php @@ -0,0 +1,22 @@ +<?php +/** Lithuanian (Lietuvių) + * + * @package MediaWiki + * @subpackage Language + * + */ + +class LanguageLt extends Language { + /* Word forms (with examples): + 1 - vienas (1) lapas + 2 - trys (3) lapai + 3 - penkiolika (15) lapų + */ + function convertPlural( $count, $wordform1, $wordform2, $wordform3) { + $count = str_replace (' ', '', $count); + if ($count%10==1 && $count%100!=11) return $wordform1; + if ($count%10>=2 && ($count%100<10 || $count%100>=20)) return $wordform2; + return $wordform3; + } +} +?> diff --git a/languages/classes/LanguageLv.php b/languages/classes/LanguageLv.php new file mode 100644 index 00000000..54cae487 --- /dev/null +++ b/languages/classes/LanguageLv.php @@ -0,0 +1,57 @@ +<?php +/** Latvian (Latviešu) + * + * @package MediaWiki + * @subpackage Language + * + * @author Niklas Laxström + * + * @copyright Copyright © 2006, Niklas Laxström + * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later + */ + +class LanguageLv extends Language { + /** + * Plural form transformations. Using the first form for words with the last digit 1, but not for words with the last digits 11, and the second form for all the others. + * + * Example: {{plural:{{NUMBEROFARTICLES}}|article|articles}} + * + * @param integer $count + * @param string $wordform1 + * @param string $wordform2 + * @param string $wordform3 (not used) + * @return string + */ + function convertPlural( $count, $wordform1, $wordform2, $wordform3 ) { + return ( ( $count % 10 == 1 ) && ( $count % 100 != 11 ) ) ? $wordform1 : $wordform2; + } + + # Convert from the nominative form of a noun to some other case + # Invoked with {{GRAMMAR:case|word}} + # ģenitīvs - kā, datīvs - kam, akuzatīvs - ko, lokatīvs - kur. + /** + * Cases: ģenitīvs, datīvs, akuzatīvs, lokatīvs + */ + function convertGrammar( $word, $case ) { + global $wgGrammarForms; + + $wgGrammarForms['lv']['ģenitīvs' ]['Vikipēdija'] = 'Vikipēdijas'; + $wgGrammarForms['lv']['ģenitīvs' ]['Vikivārdnīca'] = 'Vikivārdnīcas'; + $wgGrammarForms['lv']['datīvs' ]['Vikipēdija'] = 'Vikipēdijai'; + $wgGrammarForms['lv']['datīvs' ]['Vikivārdnīca'] = 'Vikivārdnīcai'; + $wgGrammarForms['lv']['akuzatīvs']['Vikipēdija'] = 'Vikipēdiju'; + $wgGrammarForms['lv']['akuzatīvs']['Vikivārdnīca'] = 'Vikivārdnīcu'; + $wgGrammarForms['lv']['lokatīvs' ]['Vikipēdija'] = 'Vikipēdijā'; + $wgGrammarForms['lv']['lokatīvs' ]['Vikivārdnīca'] = 'Vikivārdnīcā'; + + if ( isset($wgGrammarForms['lv'][$case][$word]) ) { + return $wgGrammarForms['lv'][$case][$word]; + } + + return $word; + + } + +} + +?> diff --git a/languages/classes/LanguagePt_br.php b/languages/classes/LanguagePt_br.php new file mode 100644 index 00000000..6132aaa2 --- /dev/null +++ b/languages/classes/LanguagePt_br.php @@ -0,0 +1,17 @@ +<?php +/** Brazilian Portugese (Portuguêsi do Brasil) + * + * @package MediaWiki + * @subpackage Language + * + */ + +class LanguagePt_br extends Language { + /** + * Use singular form for zero (see bug 7309) + */ + function convertPlural( $count, $w1, $w2, $w3) { + return $count <= '1' ? $w1 : $w2; + } +} +?> diff --git a/languages/classes/LanguageRmy.php b/languages/classes/LanguageRmy.php new file mode 100644 index 00000000..bbf22d52 --- /dev/null +++ b/languages/classes/LanguageRmy.php @@ -0,0 +1,72 @@ +<?php + +class LanguageRmy extends Language { + /** + * Convert from the nominative form of a noun to some other case + * Invoked with {{GRAMMAR:case|word}} + * + * Cases: nominative, genitive-m-sg, genitive-f-sg, dative, locative, ablative, instrumental + */ + public function convertGrammar( $word, $case ) { + global $wgGrammarForms; + if ( isset($wgGrammarForms['rmy'][$case][$word]) ) { + return $wgGrammarForms['rmy'][$case][$word]; + } + + switch ( $case ) { + case 'genitive-m-sg': # genitive (m.sg.) + if ( $word == 'Vikipidiya' ) { + $word = 'Vikipidiyako'; + } elseif ( $word == 'Vikcyonaro' ) { + $word = 'Vikcyonaresko'; + } + break; + case 'genitive-f-sg': # genitive (f.sg.) + if ( $word == 'Vikipidiya' ) { + $word = 'Vikipidiyaki'; + } elseif ( $word == 'Vikcyonaro' ) { + $word = 'Vikcyonareski'; + } + break; + case 'genitive-pl': # genitive (pl.) + if ( $word == 'Vikipidiya' ) { + $word = 'Vikipidiyake'; + } elseif ( $word == 'Vikcyonaro' ) { + $word = 'Vikcyonareske'; + } + break; + case 'dativ': + if ( $word == 'Vikipidiyake' ) { + $word = 'Wikipediji'; + } elseif ( $word == 'Vikcyonaro' ) { + $word = 'Vikcyonareske'; + } + break; + case 'locative': + if ( $word == 'Vikipidiyate' ) { + $word = 'Wikipedijo'; + } elseif ( $word == 'Vikcyonaro' ) { + $word = 'Vikcyonareste'; + } + break; + case 'ablative': + if ( $word == 'Vikipidiyatar' ) { + $word = 'o Wikipediji'; + } elseif ( $word == 'Vikcyonaro' ) { + $word = 'Vikcyonarestar'; + } + break; + case 'instrumental': + if ( $word == 'Vikipidiyasa' ) { + $word = 'z Wikipedijo'; + } elseif ( $word == 'Vikcyonaro' ) { + $word = 'Vikcyonaresa'; + } + break; + } + + return $word; # this will return the original value for 'nominative' and all undefined case values + } +} + +?> diff --git a/languages/classes/LanguageRu.php b/languages/classes/LanguageRu.php new file mode 100644 index 00000000..b64a4144 --- /dev/null +++ b/languages/classes/LanguageRu.php @@ -0,0 +1,87 @@ +<?php +/** Russian (русский язык) + * + * You can contact Alexander Sigachov (alexander.sigachov at Googgle Mail) + * + * @package MediaWiki + * @subpackage Language + */ + +/* Please, see Language.php for general function comments */ +class LanguageRu 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['ru'][$case][$word]) ) { + return $wgGrammarForms['ru'][$case][$word]; + } + + # These rules are not perfect, but they are currently only used for site names so it doesn't + # matter if they are wrong sometimes. Just add a special case for your site name if necessary. + + #join and array_slice instead mb_substr + $ar = array(); + preg_match_all( '/./us', $word, $ar ); + if (!preg_match("/[a-zA-Z_]/us", $word)) + switch ( $case ) { + case 'genitive': #родительный падеж + if ((join('',array_slice($ar[0],-4))=='вики') || (join('',array_slice($ar[0],-4))=='Вики')) + {} + elseif (join('',array_slice($ar[0],-1))=='ь') + $word = join('',array_slice($ar[0],0,-1)).'я'; + elseif (join('',array_slice($ar[0],-2))=='ия') + $word=join('',array_slice($ar[0],0,-2)).'ии'; + elseif (join('',array_slice($ar[0],-2))=='ка') + $word=join('',array_slice($ar[0],0,-2)).'ки'; + elseif (join('',array_slice($ar[0],-2))=='ти') + $word=join('',array_slice($ar[0],0,-2)).'тей'; + elseif (join('',array_slice($ar[0],-2))=='ды') + $word=join('',array_slice($ar[0],0,-2)).'дов'; + elseif (join('',array_slice($ar[0],-3))=='ник') + $word=join('',array_slice($ar[0],0,-3)).'ника'; + break; + case 'dative': #дательный падеж + #stub + break; + case 'accusative': #винительный падеж + #stub + break; + case 'instrumental': #творительный падеж + #stub + break; + case 'prepositional': #предложный падеж + #stub + break; + } + return $word; + } + + function convertPlural( $count, $wordform1, $wordform2, $wordform3) { + $count = str_replace (' ', '', $count); + if ($count > 10 && floor(($count % 100) / 10) == 1) { + return $wordform3; + } else { + switch ($count % 10) { + case 1: return $wordform1; + case 2: + case 3: + case 4: return $wordform2; + default: return $wordform3; + } + } + } + + /* + * Russian numeric format is "12 345,67" but "1234,56" + */ + + function commafy($_) { + if (!preg_match('/^\d{1,4}$/',$_)) { + return strrev((string)preg_replace('/(\d{3})(?=\d)(?!\d*\.)/','$1,',strrev($_))); + } else { + return $_; + } + } +} +?> diff --git a/languages/classes/LanguageSk.php b/languages/classes/LanguageSk.php new file mode 100644 index 00000000..2fa8df0f --- /dev/null +++ b/languages/classes/LanguageSk.php @@ -0,0 +1,94 @@ +<?php +/** + * Slovak (Slovenčina) + * + * @package MediaWiki + * @subpackage Language + */ +class LanguageSk extends Language { + # Convert from the nominative form of a noun to some other case + # Invoked with {{GRAMMAR:case|word}} + /** + * Cases: genitív, datív, akuzatív, lokál, inštrumentál + */ + function convertGrammar( $word, $case ) { + global $wgGrammarForms; + if ( isset($wgGrammarForms['sk'][$case][$word]) ) { + return $wgGrammarForms['sk'][$case][$word]; + } + + switch ( $case ) { + case 'genitív': + if ( $word == 'Wikipédia' ) { + $word = 'Wikipédie'; + } elseif ( $word == 'Wikislovník' ) { + $word = 'Wikislovníku'; + } elseif ( $word == 'Wikicitáty' ) { + $word = 'Wikicitátov'; + } elseif ( $word == 'Wikiknihy' ) { + $word = 'Wikikníh'; + } + break; + case 'datív': + if ( $word == 'Wikipédia' ) { + $word = 'Wikipédii'; + } elseif ( $word == 'Wikislovník' ) { + $word = 'Wikislovníku'; + } elseif ( $word == 'Wikicitáty' ) { + $word = 'Wikicitátom'; + } elseif ( $word == 'Wikiknihy' ) { + $word = 'Wikiknihám'; + } + break; + case 'akuzatív': + if ( $word == 'Wikipédia' ) { + $word = 'Wikipédiu'; + } elseif ( $word == 'Wikislovník' ) { + $word = 'Wikislovník'; + } elseif ( $word == 'Wikicitáty' ) { + $word = 'Wikicitáty'; + } elseif ( $word == 'Wikiknihy' ) { + $word = 'Wikiknihy'; + } + break; + case 'lokál': + if ( $word == 'Wikipédia' ) { + $word = 'Wikipédii'; + } elseif ( $word == 'Wikislovník' ) { + $word = 'Wikislovníku'; + } elseif ( $word == 'Wikicitáty' ) { + $word = 'Wikicitátoch'; + } elseif ( $word == 'Wikiknihy' ) { + $word = 'Wikiknihách'; + } + break; + case 'inštrumentál': + if ( $word == 'Wikipédia' ) { + $word = 'Wikipédiou'; + } elseif ( $word == 'Wikislovník' ) { + $word = 'Wikislovníkom'; + } elseif ( $word == 'Wikicitáty' ) { + $word = 'Wikicitátmi'; + } elseif ( $word == 'Wikiknihy' ) { + $word = 'Wikiknihami'; + } + break; + } + return $word; + } + + function convertPlural( $count, $w1, $w2, $w3) { + $count = str_replace ('.', '', $count); + $forms = array( $w1, $w2, $w3); + if ( $count == 1 ) { + $index = 0; + } elseif ( $count == 2 || $count == 3 || $count == 4 ) { + $index = 1; + } else { + $index = 2; + } + return $forms[$index]; + } + +} +?> diff --git a/languages/classes/LanguageSl.php b/languages/classes/LanguageSl.php new file mode 100644 index 00000000..35991caa --- /dev/null +++ b/languages/classes/LanguageSl.php @@ -0,0 +1,124 @@ +<?php +/** Slovenian (Slovenščina) + * + * @package MediaWiki + * @subpackage Language + * + */ +class LanguageSl extends Language { + # Convert from the nominative form of a noun to some other case + # Invoked with {{GRAMMAR:case|word}} + /** + * Cases: rodilnik, dajalnik, tožilnik, mestnik, orodnik + */ + function convertGrammar( $word, $case ) { + global $wgGrammarForms; + if ( isset($wgGrammarForms['sl'][$case][$word]) ) { + return $wgGrammarForms['sl'][$case][$word]; + } + + switch ( $case ) { + case 'rodilnik': # genitive + if ( $word == 'Wikipedija' ) { + $word = 'Wikipedije'; + } elseif ( $word == 'Wikiknjige' ) { + $word = 'Wikiknjig'; + } elseif ( $word == 'Wikinovice' ) { + $word = 'Wikinovic'; + } elseif ( $word == 'Wikinavedek' ) { + $word = 'Wikinavedka'; + } elseif ( $word == 'Wikivir' ) { + $word = 'Wikivira'; + } elseif ( $word == 'Wikislovar' ) { + $word = 'Wikislovarja'; + } + break; + case 'dajalnik': # dativ + if ( $word == 'Wikipedija' ) { + $word = 'Wikipediji'; + } elseif ( $word == 'Wikiknjige' ) { + $word = 'Wikiknjigam'; + } elseif ( $word == 'Wikinovice' ) { + $word = 'Wikinovicam'; + } elseif ( $word == 'Wikinavedek' ) { + $word = 'Wikinavedku'; + } elseif ( $word == 'Wikivir' ) { + $word = 'Wikiviru'; + } elseif ( $word == 'Wikislovar' ) { + $word = 'Wikislovarju'; + } + break; + case 'tožilnik': # akuzatív + if ( $word == 'Wikipedija' ) { + $word = 'Wikipedijo'; + } elseif ( $word == 'Wikiknjige' ) { + $word = 'Wikiknjige'; + } elseif ( $word == 'Wikinovice' ) { + $word = 'Wikinovice'; + } elseif ( $word == 'Wikinavedek' ) { + $word = 'Wikinavedek'; + } elseif ( $word == 'Wikivir' ) { + $word = 'Wikivir'; + } elseif ( $word == 'Wikislovar' ) { + $word = 'Wikislovar'; + } + break; + case 'mestnik': # locative + if ( $word == 'Wikipedija' ) { + $word = 'o Wikipediji'; + } elseif ( $word == 'Wikiknjige' ) { + $word = 'o Wikiknjigah'; + } elseif ( $word == 'Wikinovice' ) { + $word = 'o Wikinovicah'; + } elseif ( $word == 'Wikinavedek' ) { + $word = 'o Wikinavedku'; + } elseif ( $word == 'Wikivir' ) { + $word = 'o Wikiviru'; + } elseif ( $word == 'Wikislovar' ) { + $word = 'o Wikislovarju'; + } else { + $word = 'o ' . $word; + } + break; + case 'orodnik': # instrumental + if ( $word == 'Wikipedija' ) { + $word = 'z Wikipedijo'; + } elseif ( $word == 'Wikiknjige' ) { + $word = 'z Wikiknjigami'; + } elseif ( $word == 'Wikinovice' ) { + $word = 'z Wikinovicami'; + } elseif ( $word == 'Wikinavedek' ) { + $word = 'z Wikinavedkom'; + } elseif ( $word == 'Wikivir' ) { + $word = 'z Wikivirom'; + } elseif ( $word == 'Wikislovar' ) { + $word = 'z Wikislovarjem'; + } else { + $word = 'z ' . $word; + } + break; + } + + 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 ); + if ( $count % 100 == 1 ) { + $index = 0; + } elseif ( $count % 100 == 2 ) { + $index = 1; + } elseif ( $count % 100 == 3 || $count % 100 == 4 ) { + $index = 2; + } elseif ( $count != 0 ) { + $index = 3; + } else { + $index = 4; + } + return $forms[$index]; + } + + +} +?> diff --git a/languages/classes/LanguageSr.deps.php b/languages/classes/LanguageSr.deps.php new file mode 100644 index 00000000..8fe354e0 --- /dev/null +++ b/languages/classes/LanguageSr.deps.php @@ -0,0 +1,10 @@ +<?php +// This file exists to ensure that base classes are preloaded before +// LanguageSr.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/LanguageSr.php b/languages/classes/LanguageSr.php new file mode 100644 index 00000000..412463f8 --- /dev/null +++ b/languages/classes/LanguageSr.php @@ -0,0 +1,181 @@ +<?php +/** + * @package MediaWiki + * @subpackage Language + */ + +/* + There are two levels of conversion for Serbian: the script level + (Cyrillics <-> Latin), and the variant level (ekavian + <->iyekavian). The two are orthogonal. So we really only need two + dictionaries: one for Cyrillics and Latin, and one for ekavian and + iyekavian. +*/ +require_once( dirname(__FILE__).'/../LanguageConverter.php' ); +require_once( dirname(__FILE__).'/LanguageSr_ec.php' ); +require_once( dirname(__FILE__).'/LanguageSr_el.php' ); + +class SrConverter extends LanguageConverter { + var $mToLatin = array( + 'а' => 'a', 'б' => 'b', 'в' => 'v', 'г' => 'g', 'д' => 'd', + 'ђ' => 'đ', 'е' => 'e', 'ж' => 'ž', 'з' => 'z', 'и' => 'i', + 'ј' => 'j', 'к' => 'k', 'л' => 'l', 'љ' => 'lj', 'м' => 'm', + 'н' => 'n', 'њ' => 'nj', 'о' => 'o', 'п' => 'p', 'р' => 'r', + 'с' => 's', 'т' => 't', 'ћ' => 'ć', 'у' => 'u', 'ф' => 'f', + 'х' => 'h', 'ц' => 'c', 'ч' => 'č', 'џ' => 'dž', 'ш' => 'š', + + 'А' => 'A', 'Б' => 'B', 'В' => 'V', 'Г' => 'G', 'Д' => 'D', + 'Ђ' => 'Đ', 'Е' => 'E', 'Ж' => 'Ž', 'З' => 'Z', 'И' => 'I', + 'Ј' => 'J', 'К' => 'K', 'Л' => 'L', 'Љ' => 'Lj', 'М' => 'M', + 'Н' => 'N', 'Њ' => 'Nj', 'О' => 'O', 'П' => 'P', 'Р' => 'R', + 'С' => 'S', 'Т' => 'T', 'Ћ' => 'Ć', 'У' => 'U', 'Ф' => 'F', + 'Х' => 'H', 'Ц' => 'C', 'Ч' => 'Č', 'Џ' => 'Dž', 'Ш' => 'Š', + ); + + var $mToCyrillics = array( + 'a' => 'а', 'b' => 'б', 'c' => 'ц', 'č' => 'ч', 'ć' => 'ћ', + 'd' => 'д', 'dž' => 'џ', 'đ' => 'ђ', 'e' => 'е', 'f' => 'ф', + 'g' => 'г', 'h' => 'х', 'i' => 'и', 'j' => 'ј', 'k' => 'к', + 'l' => 'л', 'lj' => 'љ', 'm' => 'м', 'n' => 'н', 'nj' => 'њ', + 'o' => 'о', 'p' => 'п', 'r' => 'р', 's' => 'с', 'š' => 'ш', + 't' => 'т', 'u' => 'у', 'v' => 'в', 'z' => 'з', 'ž' => 'ж', + + 'A' => 'А', 'B' => 'Б', 'C' => 'Ц', 'Č' => 'Ч', 'Ć' => 'Ћ', + 'D' => 'Д', 'Dž' => 'Џ', 'Đ' => 'Ђ', 'E' => 'Е', 'F' => 'Ф', + 'G' => 'Г', 'H' => 'Х', 'I' => 'И', 'J' => 'Ј', 'K' => 'К', + 'L' => 'Л', 'LJ' => 'Љ', 'M' => 'М', 'N' => 'Н', 'NJ' => 'Њ', + 'O' => 'О', 'P' => 'П', 'R' => 'Р', 'S' => 'С', 'Š' => 'Ш', + 'T' => 'Т', 'U' => 'У', 'V' => 'В', 'Z' => 'З', 'Ž' => 'Ж', + + 'DŽ' => 'Џ', 'd!ž' => 'дж', 'D!ž'=> 'Дж', 'D!Ž'=> 'ДЖ', + 'Lj' => 'Љ', 'l!j' => 'лј', 'L!j'=> 'Лј', 'L!J'=> 'ЛЈ', + 'Nj' => 'Њ', 'n!j' => 'нј', 'N!j'=> 'Нј', 'N!J'=> 'НЈ' + ); + + function loadDefaultTables() { + $this->mTables = array(); + $this->mTables['sr-ec'] = $this->mToCyrillics; + $this->mTables['sr-jc'] = $this->mToCyrillics; + $this->mTables['sr-el'] = $this->mToLatin; + $this->mTables['sr-jl'] = $this->mToLatin; + $this->mTables['sr'] = array(); + } + + /* 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 + */ + function parseManualRule($rule, $flags=array()) { + // ignore all formatting + foreach($this->mVariants as $v) { + $carray[$v] = $rule; + } + + return $carray; + } + + /* + * Override function from LanguageConvertor + * Additional checks: + * - There should be no conversion for Talk pages + */ + function getPreferredVariant(){ + global $wgTitle; + if($wgTitle!=NULL && $wgTitle->isTalkPage()){ + return $this->mMainLanguageCode; + } + return parent::getPreferredVariant(); + } + + + /* + * A function wrapper, if there is no selected variant, + * leave the link names as they were + */ + function findVariantLink( &$link, &$nt ) { + $oldlink=$link; + parent::findVariantLink($link,$nt); + if($this->getPreferredVariant()==$this->mMainLanguageCode) + $link=$oldlink; + } + + + /* + * We want our external link captions to be converted in variants, + * so we return the original text instead -{$text}-, except for URLs + */ + function markNoConversion($text, $noParse=false) { + if($noParse || preg_match("/^https?:\/\/|ftp:\/\/|irc:\/\//",$text)) + return parent::markNoConversion($text); + return $text; + } + + /* + * An ugly function wrapper for parsing Image titles + * (to prevent image name conversion) + */ + function autoConvert($text, $toVariant=false) { + global $wgTitle; + if($wgTitle->getNameSpace()==NS_IMAGE){ + $imagename = $wgTitle->getNsText(); + if(preg_match("/^$imagename:/",$text)) return $text; + } + return parent::autoConvert($text,$toVariant); + } + + /** + * It translates text into variant, specials: + * - ommiting roman numbers + */ + 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); + $ret = strtr($m[0], $this->mTables[$toVariant]); + $mstart = $m[1]+strlen($m[0]); + foreach($matches as $m) { + $ret .= substr($text, $mstart, $m[1]-$mstart); + $ret .= parent::translate($m[0], $toVariant); + $mstart = $m[1] + strlen($m[0]); + } + + return $ret; + } + + +} + +class LanguageSr extends LanguageSr_ec { + function __construct() { + global $wgHooks; + + parent::__construct(); + + // these variants are currently UNUSED: + // 'sr-jc', 'sr-jl' + $variants = array('sr', 'sr-ec', 'sr-el'); + $variantfallbacks = array( + 'sr' => 'sr-ec', + 'sr-ec' => 'sr-ec', + 'sr-el' => 'sr-el', + ); + + + $marker = array();//don't mess with these, leave them as they are + $flags = array( + 'S' => 'S', 'писмо' => 'S', 'pismo' => 'S', + 'W' => 'W', 'реч' => 'W', 'reč' => 'W', 'ријеч' => 'W', 'riječ' => 'W' + ); + $this->mConverter = new SrConverter($this, 'sr', $variants, $variantfallbacks, $marker, $flags); + $wgHooks['ArticleSaveComplete'][] = $this->mConverter; + } +} +?> diff --git a/languages/classes/LanguageSr_ec.php b/languages/classes/LanguageSr_ec.php new file mode 100644 index 00000000..f84ebd06 --- /dev/null +++ b/languages/classes/LanguageSr_ec.php @@ -0,0 +1,28 @@ +<?php +/** + * @package MediaWiki + * @subpackage Language + */ + +#-------------------------------------------------------------------------- +# Internationalisation code +#-------------------------------------------------------------------------- + +class LanguageSr_ec extends Language { + function convertPlural( $count, $wordform1, $wordform2, $wordform3) { + $count = str_replace ('.', '', $count); + if ($count > 10 && floor(($count % 100) / 10) == 1) { + return $wordform3; + } else { + switch ($count % 10) { + case 1: return $wordform1; + case 2: + case 3: + case 4: return $wordform2; + default: return $wordform3; + } + } + } + +} +?> diff --git a/languages/classes/LanguageSr_el.deps.php b/languages/classes/LanguageSr_el.deps.php new file mode 100644 index 00000000..f39da2f2 --- /dev/null +++ b/languages/classes/LanguageSr_el.deps.php @@ -0,0 +1,9 @@ +<?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 +// 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' ); +?> diff --git a/languages/classes/LanguageSr_el.php b/languages/classes/LanguageSr_el.php new file mode 100644 index 00000000..cba1b57e --- /dev/null +++ b/languages/classes/LanguageSr_el.php @@ -0,0 +1,28 @@ +<?php +/** + * @package MediaWiki + * @subpackage Language + */ + +#-------------------------------------------------------------------------- +# Internationalisation code +#-------------------------------------------------------------------------- + +class LanguageSr_el extends Language { + function convertPlural( $count, $wordform1, $wordform2, $wordform3) { + $count = str_replace ('.', '', $count); + if ($count > 10 && floor(($count % 100) / 10) == 1) { + return $wordform3; + } else { + switch ($count % 10) { + case 1: return $wordform1; + case 2: + case 3: + case 4: return $wordform2; + default: return $wordform3; + } + } + } + +} +?> diff --git a/languages/classes/LanguageTr.php b/languages/classes/LanguageTr.php new file mode 100644 index 00000000..67d68f60 --- /dev/null +++ b/languages/classes/LanguageTr.php @@ -0,0 +1,18 @@ +<?php +/** + * Turkish (Türkçe) + * + * @package MediaWiki + * @subpackage Language + */ +class LanguageTr extends Language { + function ucfirst ( $string ) { + if ( $string[0] == 'i' ) { + return 'İ' . substr( $string, 1 ); + } else { + return parent::ucfirst( $string ); + } + } + +} +?> diff --git a/languages/classes/LanguageTyv.php b/languages/classes/LanguageTyv.php new file mode 100644 index 00000000..aacfaff5 --- /dev/null +++ b/languages/classes/LanguageTyv.php @@ -0,0 +1,233 @@ +<?php +/** Tyvan localization (Тыва дыл) + * @package MediaWiki + * @subpackage Language + */ + +# From friends at tyvawiki.org + +#-------------------------------------------------------------------------- +# Internationalisation code +#-------------------------------------------------------------------------- + +class LanguageTyv extends Language { + /** + * Grammatical transformations, needed for inflected languages + * Invoked by putting {{grammar:case|word}} in a message + * + * @param string $word + * @param string $case + * @return string + */ + function convertGrammar( $word, $case ) { + global $wgGrammarForms; + if ( isset($wgGrammarForms['tyv'][$case][$word]) ) { + return $wgGrammarForms['tyv'][$case][$word]; + } + + + // Set up some constants... + $allVowels = array("е", "и", "э", "ө", "ү", "а", "ё", "о", "у", "ы", "ю", "я", "a", "e", "i", "o", "ö", "u", "ü", "y"); + $frontVowels = array("е", "и", "э", "ө", "ү", "e", "i", "ö", "ü"); + $backVowels = array("а", "ё", "о", "у", "ы", "ю", "я", "a", "o", "u", "y"); + $unroundFrontVowels = array("е", "и", "э", "e", "i"); + $roundFrontVowels = array("ө", "ү", "ö", "ü"); + $unroundBackVowels = array("а", "ы", "я", "a", "y"); + $roundBackVowels = array("ё", "о", "у", "ю", "o", "u"); + $voicedPhonemes = array("д", "б", "з", "ж", "г", "d", "b", "z", "g"); + $unvoicedPhonemes = array("т", "п", "с", "ш", "к", "ч", "х", "t", "p", "s", "k", "x"); + $directiveUnvoicedStems = array("т", "п", "с", "ш", "к", "ч", "х", "л", "м", "н", "ң", "t", "p", "s", "k", "x", "l", "m", "n", "ŋ"); + $directiveVoicedStems = array("д", "б", "з", "ж", "г", "р", "й", "d", "b", "z", "g", "r", "j"); + +// $allSonants = array("л", "м", "н", "ң", "р", "й"); +// $allNasals = array("м", "н", "ң"); + + // Put the word in a form we can play with since we're using UTF-8 + preg_match_all( '/./us', $word, $ar ); + + $wordEnding = $ar[0][count($ar[0]) - 1]; //Here's the last letter in the word + $wordReversed = array_reverse($ar[0]); //Here's an array with the order of the letters in the word reversed so we can find a match quicker *shrug* + + // Find the last vowel in the word + $wordLastVowel = NULL; + foreach ( $wordReversed as $xvalue ) { + foreach ( $allVowels as $yvalue ) { + if ( strcmp($xvalue, $yvalue) == 0 ) { + $wordLastVowel = $xvalue; + break; + } else { + continue; + } + } + if ( $wordLastVowel !== NULL ) { + break; + } else { + continue; + } + } + + // Now convert the word + switch ( $case ) { + case "genitive": + if ( in_array($wordEnding, $unvoicedPhonemes) ) { + if ( in_array($wordLastVowel, $roundFrontVowels) ) { + $word = implode("",$ar[0]) . "түң"; + } elseif ( in_array($wordLastVowel, $unroundFrontVowels) ) { + $word = implode("",$ar[0]) . "тиң"; + } elseif ( in_array($wordLastVowel, $roundBackVowels) ) { + $word = implode("",$ar[0]) . "туң"; + } elseif ( in_array($wordLastVowel, $unroundBackVowels) ) { + $word = implode("",$ar[0]) . "тың"; + } else { + } + } elseif ( $wordEnding === "л" || $wordEnding === "l") { + if ( in_array($wordLastVowel, $roundFrontVowels) ) { + $word = implode("",$ar[0]) . "дүң"; + } elseif ( in_array($wordLastVowel, $unroundFrontVowels) ) { + $word = implode("",$ar[0]) . "диң"; + } elseif ( in_array($wordLastVowel, $roundBackVowels) ) { + $word = implode("",$ar[0]) . "дуң"; + } elseif ( in_array($wordLastVowel, $unroundBackVowels) ) { + $word = implode("",$ar[0]) . "дың"; + } else { + } + } else { + if ( in_array($wordLastVowel, $roundFrontVowels) ) { + $word = implode("",$ar[0]) . "нүң"; + } elseif ( in_array($wordLastVowel, $unroundFrontVowels) ) { + $word = implode("",$ar[0]) . "ниң"; + } elseif ( in_array($wordLastVowel, $roundBackVowels) ) { + $word = implode("",$ar[0]) . "нуң"; + } elseif ( in_array($wordLastVowel, $unroundBackVowels) ) { + $word = implode("",$ar[0]) . "ның"; + } else { + } + } + break; + case "dative": + if ( in_array($wordEnding, $unvoicedPhonemes) ) { + if ( in_array($wordLastVowel, $frontVowels) ) { + $word = implode("",$ar[0]) . "ке"; + } elseif ( in_array($wordLastVowel, $backVowels) ) { + $word = implode("",$ar[0]) . "ка"; + } else { + } + } else { + if ( in_array($wordLastVowel, $frontVowels) ) { + $word = implode("",$ar[0]) . "ге"; + } elseif ( in_array($wordLastVowel, $backVowels) ) { + $word = implode("",$ar[0]) . "га"; + } else { + } + } + break; + case "accusative": + if ( in_array($wordEnding, $unvoicedPhonemes) ) { + if ( in_array($wordLastVowel, $roundFrontVowels) ) { + $word = implode("",$ar[0]) . "тү"; + } elseif ( in_array($wordLastVowel, $unroundFrontVowels) ) { + $word = implode("",$ar[0]) . "ти"; + } elseif ( in_array($wordLastVowel, $roundBackVowels) ) { + $word = implode("",$ar[0]) . "ту"; + } elseif ( in_array($wordLastVowel, $unroundBackVowels) ) { + $word = implode("",$ar[0]) . "ты"; + } else { + } + } elseif ( $wordEnding === "л" || $wordEnding === "l") { + if ( in_array($wordLastVowel, $roundFrontVowels) ) { + $word = implode("",$ar[0]) . "дү"; + } elseif ( in_array($wordLastVowel, $unroundFrontVowels) ) { + $word = implode("",$ar[0]) . "ди"; + } elseif ( in_array($wordLastVowel, $roundBackVowels) ) { + $word = implode("",$ar[0]) . "ду"; + } elseif ( in_array($wordLastVowel, $unroundBackVowels) ) { + $word = implode("",$ar[0]) . "ды"; + } else { + } + } else { + if ( in_array($wordLastVowel, $roundFrontVowels) ) { + $word = implode("",$ar[0]) . "нү"; + } elseif ( in_array($wordLastVowel, $unroundFrontVowels) ) { + $word = implode("",$ar[0]) . "ни"; + } elseif ( in_array($wordLastVowel, $roundBackVowels) ) { + $word = implode("",$ar[0]) . "ну"; + } elseif ( in_array($wordLastVowel, $unroundBackVowels) ) { + $word = implode("",$ar[0]) . "ны"; + } else { + } + } + break; + case "locative": + if ( in_array($wordEnding, $unvoicedPhonemes) ) { + if ( in_array($wordLastVowel, $frontVowels) ) { + $word = implode("",$ar[0]) . "те"; + } elseif ( in_array($wordLastVowel, $backVowels) ) { + $word = implode("",$ar[0]) . "та"; + } else { + } + } else { + if ( in_array($wordLastVowel, $frontVowels) ) { + $word = implode("",$ar[0]) . "де"; + } elseif ( in_array($wordLastVowel, $backVowels) ) { + $word = implode("",$ar[0]) . "да"; + } else { + } + } + break; + case "ablative": + if ( in_array($wordEnding, $unvoicedPhonemes) ) { + if ( in_array($wordLastVowel, $frontVowels) ) { + $word = implode("",$ar[0]) . "тен"; + } elseif ( in_array($wordLastVowel, $backVowels) ) { + $word = implode("",$ar[0]) . "тан"; + } else { + } + } else { + if ( in_array($wordLastVowel, $frontVowels) ) { + $word = implode("",$ar[0]) . "ден"; + } elseif ( in_array($wordLastVowel, $backVowels) ) { + $word = implode("",$ar[0]) . "дан"; + } else { + } + } + break; + case "directive1": + if ( in_array($wordEnding, $directiveVoicedStems) ) { + $word = implode("",$ar[0]) . "же"; + } elseif ( in_array($wordEnding, $directiveUnvoicedStems) ) { + $word = implode("",$ar[0]) . "че"; + } else { + } + break; + case "directive2": + if ( in_array($wordEnding, $unvoicedPhonemes) ) { + if ( in_array($wordLastVowel, $roundFrontVowels) ) { + $word = implode("",$ar[0]) . "түве"; + } elseif ( in_array($wordLastVowel, $unroundFrontVowels) ) { + $word = implode("",$ar[0]) . "тиве"; + } elseif ( in_array($wordLastVowel, $roundBackVowels) ) { + $word = implode("",$ar[0]) . "туве"; + } elseif ( in_array($wordLastVowel, $unroundBackVowels) ) { + $word = implode("",$ar[0]) . "тыве"; + } else { + } + } else { + if ( in_array($wordLastVowel, $roundFrontVowels) ) { + $word = implode("",$ar[0]) . "дүве"; + } elseif ( in_array($wordLastVowel, $unroundFrontVowels) ) { + $word = implode("",$ar[0]) . "диве"; + } elseif ( in_array($wordLastVowel, $roundBackVowels) ) { + $word = implode("",$ar[0]) . "дуве"; + } elseif ( in_array($wordLastVowel, $unroundBackVowels) ) { + $word = implode("",$ar[0]) . "дыве"; + } else { + } + } + break; + default: + break; + } + return $word; + } +} +?> diff --git a/languages/classes/LanguageVi.php b/languages/classes/LanguageVi.php new file mode 100644 index 00000000..4f9c4da3 --- /dev/null +++ b/languages/classes/LanguageVi.php @@ -0,0 +1,74 @@ +<?php +/** + * Based on Language.php 1.645 + * @package MediaWiki + * @subpackage Language + * Compatible to MediaWiki 1.5 + * Initial translation by Trần Thế Trung and Nguyễn Thanh Quang + * Last update 28 August 2005 (UTC) + */ + +class LanguageVi extends Language { + function date( $ts, $adj = false, $format = true, $timecorrection = false ) { + if ( $adj ) { $ts = $this->userAdjust( $ts, $timecorrection ); } + + $datePreference = $this->dateFormat( $format ); + + $month = $this->formatMonth( substr( $ts, 4, 2 ), $datePreference ); + $day = $this->formatDay( substr( $ts, 6, 2 ), $datePreference ); + $year = $this->formatNum( substr( $ts, 0, 4 ), true ); + + switch( $datePreference ) { + case 3: + case 4: return "$day/$month/$year"; + case MW_DATE_ISO: return substr($ts, 0, 4). '-' . substr($ts, 4, 2). '-' .substr($ts, 6, 2); + default: return "$day $month năm $year"; + } + } + + function timeSeparator( $format ) { + $datePreference = $this->dateFormat($format); + switch ( $datePreference ) { + case '4': return 'h'; + default: return ':'; + } + } + + function timeDateSeparator( $format ) { + $datePreference = $this->dateFormat($format); + switch ( $datePreference ) { + case '0': + case '1': + case '2': return ', '; + default: return ' '; + } + } + + function formatMonth( $month, $format ) { + $datePreference = $this->dateFormat($format); + switch ( $datePreference ) { + case '0': + case '1': return 'tháng ' . ( 0 + $month ); + case '2': return 'tháng ' . $this->getSpecialMonthName( $month ); + default: return 0 + $month; + } + } + + function formatDay( $day, $format ) { + $datePreference = $this->dateFormat($format); + switch ( $datePreference ) { + case '0': + case '1': + case '2': return 'ngày ' . (0 + $day); + default: return 0 + $day; + } + } + + function getSpecialMonthName( $key ) { + $names = 'Một, Hai, Ba, Tư, Năm, Sáu, Bảy, Tám, Chín, Mười, Mười một, Mười hai'; + $names = explode(', ', $names); + return $names[$key-1]; + } +} + +?> diff --git a/languages/classes/LanguageWa.php b/languages/classes/LanguageWa.php new file mode 100644 index 00000000..541c6de8 --- /dev/null +++ b/languages/classes/LanguageWa.php @@ -0,0 +1,71 @@ +<?php +/** + * Walloon (Walon) + * + * @package MediaWiki + * @subpackage Language + */ + +# NOTE: cweri après "NOTE:" po des racsegnes so des ratournaedjes +# k' i gn a. + +class LanguageWa extends Language { + ### + ### Dates in Walloon are "1î d' <monthname>" for 1st of the month, + ### "<day> di <monthname>" for months starting by a consoun, and + ### "<day> d' <monthname>" for months starting with a vowel + ### + function date( $ts, $adj = false, $format = true, $tc = false ) { + global $wgUser; + + if ( $adj ) { $ts = $this->userAdjust( $ts, $tc ); } + $datePreference = $this->dateFormat( $format ); + + # ISO (YYYY-mm-dd) format + # + # we also output this format for YMD (eg: 2001 January 15) + if ( $datePreference == 'ISO 8601' ) { + $d = substr($ts, 0, 4). '-' . substr($ts, 4, 2). '-' .substr($ts, 6, 2); + return $d; + } + + # dd/mm/YYYY format + if ( $datePreference == 'walloon short' ) { + $d = substr($ts, 6, 2). '/' . substr($ts, 4, 2). '/' .substr($ts, 0, 4); + return $d; + } + + # Walloon format + # + # we output this in all other cases + $m = substr( $ts, 4, 2 ); + $n = substr( $ts, 6, 2 ); + if ($n == 1) { + $d = "1î d' " . $this->getMonthName( $m ) . + " " . substr( $ts, 0, 4 ); + } else if ($n == 2 || $n == 3 || $n == 20 || $n == 22 || $n == 23) { + $d = (0 + $n) . " d' " . $this->getMonthName( $m ) . + " " . substr( $ts, 0, 4 ); + } else if ($m == 4 || $m == 8 || $m == 10) { + $d = (0 + $n) . " d' " . $this->getMonthName( $m ) . + " " . substr( $ts, 0, 4 ); + } else { + $d = (0 + $n) . " di " . $this->getMonthName( $m ) . + " " . substr( $ts, 0, 4 ); + } + return $d; + } + + function timeanddate( $ts, $adj = false, $format = true, $tc = false ) { + if ( $adj ) { $ts = $this->userAdjust( $ts, $tc ); } + $datePreference = $this->dateFormat( $format ); + if ( $datePreference == 'ISO 8601' ) { + return parent::timeanddate( $ts, $adj, $format, $tc ); + } else { + return $this->date( $ts, $adj, $format, $tc ) . ' a ' . + $this->time( $ts, $adj, $format, $tc ); + } + } +} + +?> diff --git a/languages/classes/LanguageZh.deps.php b/languages/classes/LanguageZh.deps.php new file mode 100644 index 00000000..1d736340 --- /dev/null +++ b/languages/classes/LanguageZh.deps.php @@ -0,0 +1,10 @@ +<?php +// This file exists to ensure that base classes are preloaded before +// LanguageZh.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__).'/LanguageZh_cn.php' ); +require_once( dirname(__FILE__).'/../LanguageConverter.php' ); +?> diff --git a/languages/classes/LanguageZh.php b/languages/classes/LanguageZh.php new file mode 100644 index 00000000..c34315ac --- /dev/null +++ b/languages/classes/LanguageZh.php @@ -0,0 +1,101 @@ +<?php +/** + * @package MediaWiki + * @subpackage Language + */ +require_once( dirname(__FILE__).'/../LanguageConverter.php' ); +require_once( dirname(__FILE__).'/LanguageZh_cn.php' ); + +class ZhConverter extends LanguageConverter { + function loadDefaultTables() { + require( "includes/ZhConversion.php" ); + $this->mTables = array(); + $this->mTables['zh-cn'] = $zh2CN; + $this->mTables['zh-tw'] = $zh2TW; + $this->mTables['zh-sg'] = array_merge($zh2CN, $zh2SG); + $this->mTables['zh-hk'] = array_merge($zh2TW, $zh2HK); + $this->mTables['zh'] = array(); + } + + function postLoadTables() { + $this->mTables['zh-sg'] = array_merge($this->mTables['zh-cn'], $this->mTables['zh-sg']); + $this->mTables['zh-hk'] = array_merge($this->mTables['zh-tw'], $this->mTables['zh-hk']); + } + + /* there shouldn't be any latin text in Chinese conversion, so no need + to mark anything + */ + function markNoConversion($text) { + return $text; + } + + function convertCategoryKey( $key ) { + return $this->autoConvert( $key, 'zh-cn' ); + } +} + + +/* class that handles both Traditional and Simplified Chinese + right now it only distinguish zh_cn, zh_tw, zh_sg and zh_hk. +*/ +class LanguageZh extends LanguageZh_cn { + + 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')); + $wgHooks['ArticleSaveComplete'][] = $this->mConverter; + } + + + # this should give much better diff info + function segmentForDiff( $text ) { + return preg_replace( + "/([\\xc0-\\xff][\\x80-\\xbf]*)/e", + "' ' .\"$1\"", $text); + } + + function unsegmentForDiff( $text ) { + return preg_replace( + "/ ([\\xc0-\\xff][\\x80-\\xbf]*)/e", + "\"$1\"", $text); + } + + // word segmentation + function stripForSearch( $string ) { + $fname="LanguageZh::stripForSearch"; + wfProfileIn( $fname ); + + // eventually this should be a word segmentation + // for now just treat each character as a word + $t = preg_replace( + "/([\\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 + //Traditional to Simplified is less ambiguous than the + //other way around + + $t = $this->mConverter->autoConvert($t, 'zh-cn'); + $t = parent::stripForSearch( $t ); + wfProfileOut( $fname ); + return $t; + + } + + function convertForSearchResult( $termsArray ) { + $terms = implode( '|', $termsArray ); + $terms = implode( '|', $this->mConverter->autoConvertToAllVariants( $terms ) ); + $ret = array_unique( explode('|', $terms) ); + return $ret; + } + +} +?> diff --git a/languages/classes/LanguageZh_cn.php b/languages/classes/LanguageZh_cn.php new file mode 100644 index 00000000..af94cb99 --- /dev/null +++ b/languages/classes/LanguageZh_cn.php @@ -0,0 +1,27 @@ +<?php +/** + * @package MediaWiki + * @subpackage Language + */ +class LanguageZh_cn 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_yue.php b/languages/classes/LanguageZh_yue.php new file mode 100644 index 00000000..0e45508c --- /dev/null +++ b/languages/classes/LanguageZh_yue.php @@ -0,0 +1,27 @@ +<?php +/** + * @package MediaWiki + * @subpackage Language + */ +class LanguageZh_yue 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 ); + } + } +} + + +?> |