2004-02-18 02:15:00 +00:00
|
|
|
|
<?php
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
|
|
2010-07-29 09:43:18 +00:00
|
|
|
|
require_once( dirname( __FILE__ ) . '/../LanguageConverter.php' );
|
|
|
|
|
|
require_once( dirname( __FILE__ ) . '/LanguageSr_ec.php' );
|
|
|
|
|
|
require_once( dirname( __FILE__ ) . '/LanguageSr_el.php' );
|
2006-03-02 22:22:18 +00:00
|
|
|
|
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* 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.
|
|
|
|
|
|
*
|
|
|
|
|
|
* @ingroup Language
|
|
|
|
|
|
*/
|
2006-03-02 22:22:18 +00:00
|
|
|
|
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' => 'З', 'Ž' => 'Ж',
|
|
|
|
|
|
|
2010-07-29 09:43:18 +00:00
|
|
|
|
'DŽ' => 'Џ', 'd!ž' => 'дж', 'D!ž' => 'Дж', 'D!Ž' => 'ДЖ',
|
|
|
|
|
|
'Lj' => 'Љ', 'l!j' => 'лј', 'L!j' => 'Лј', 'L!J' => 'ЛЈ',
|
|
|
|
|
|
'Nj' => 'Њ', 'n!j' => 'нј', 'N!j' => 'Нј', 'N!J' => 'НЈ'
|
2006-03-02 22:22:18 +00:00
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
function loadDefaultTables() {
|
2006-11-21 09:53:45 +00:00
|
|
|
|
$this->mTables = array(
|
|
|
|
|
|
'sr-ec' => new ReplacementArray( $this->mToCyrillics ),
|
2010-07-29 09:43:18 +00:00
|
|
|
|
'sr-el' => new ReplacementArray( $this->mToLatin ),
|
2006-11-21 09:53:45 +00:00
|
|
|
|
'sr' => new ReplacementArray()
|
|
|
|
|
|
);
|
2005-08-15 19:27:58 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2011-05-29 16:32:05 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* 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
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param $rule string
|
|
|
|
|
|
* @param $flags array
|
|
|
|
|
|
* @return array
|
|
|
|
|
|
*/
|
2010-07-29 09:43:18 +00:00
|
|
|
|
function parseManualRule( $rule, $flags = array() ) {
|
|
|
|
|
|
if ( in_array( 'T', $flags ) ) {
|
|
|
|
|
|
return parent::parseManualRule( $rule, $flags );
|
2007-01-01 17:20:19 +00:00
|
|
|
|
}
|
2005-08-19 00:05:06 +00:00
|
|
|
|
|
2011-02-18 23:21:48 +00:00
|
|
|
|
$carray = array();
|
2007-01-01 17:20:19 +00:00
|
|
|
|
// otherwise ignore all formatting
|
2010-07-29 09:43:18 +00:00
|
|
|
|
foreach ( $this->mVariants as $v ) {
|
2007-01-01 17:20:19 +00:00
|
|
|
|
$carray[$v] = $rule;
|
|
|
|
|
|
}
|
2008-05-17 17:10:18 +00:00
|
|
|
|
|
2006-03-02 22:22:18 +00:00
|
|
|
|
return $carray;
|
2005-10-12 07:40:34 +00:00
|
|
|
|
}
|
2005-08-19 00:05:06 +00:00
|
|
|
|
|
2011-05-22 22:05:18 +00:00
|
|
|
|
/**
|
2006-12-26 12:19:45 +00:00
|
|
|
|
* A function wrapper:
|
2008-05-17 17:10:18 +00:00
|
|
|
|
* - if there is no selected variant, leave the link
|
2006-12-26 12:19:45 +00:00
|
|
|
|
* names as they were
|
|
|
|
|
|
* - do not try to find variants for usernames
|
2011-05-29 16:32:05 +00:00
|
|
|
|
*
|
|
|
|
|
|
* @param $link string
|
|
|
|
|
|
* @param $nt Title
|
|
|
|
|
|
* @param $ignoreOtherCond bool
|
2006-06-16 22:30:39 +00:00
|
|
|
|
*/
|
2009-02-02 07:54:43 +00:00
|
|
|
|
function findVariantLink( &$link, &$nt, $ignoreOtherCond = false ) {
|
2006-12-26 12:19:45 +00:00
|
|
|
|
// check for user namespace
|
2010-07-29 09:43:18 +00:00
|
|
|
|
if ( is_object( $nt ) ) {
|
2006-12-26 12:19:45 +00:00
|
|
|
|
$ns = $nt->getNamespace();
|
2010-07-29 09:43:18 +00:00
|
|
|
|
if ( $ns == NS_USER || $ns == NS_USER_TALK )
|
2006-12-26 12:19:45 +00:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2010-07-29 09:43:18 +00:00
|
|
|
|
$oldlink = $link;
|
2009-02-02 07:54:43 +00:00
|
|
|
|
parent::findVariantLink( $link, $nt, $ignoreOtherCond );
|
2010-07-29 09:43:18 +00:00
|
|
|
|
if ( $this->getPreferredVariant() == $this->mMainLanguageCode )
|
|
|
|
|
|
$link = $oldlink;
|
2006-06-16 22:30:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2011-05-22 22:05:18 +00:00
|
|
|
|
/**
|
2006-06-16 22:30:39 +00:00
|
|
|
|
* We want our external link captions to be converted in variants,
|
|
|
|
|
|
* so we return the original text instead -{$text}-, except for URLs
|
2011-05-29 15:59:47 +00:00
|
|
|
|
*
|
2011-05-29 16:32:05 +00:00
|
|
|
|
* @param $text string
|
|
|
|
|
|
* @param $noParse bool
|
|
|
|
|
|
*
|
2011-05-29 15:59:47 +00:00
|
|
|
|
* @return string
|
2006-06-16 22:30:39 +00:00
|
|
|
|
*/
|
2010-07-29 09:43:18 +00:00
|
|
|
|
function markNoConversion( $text, $noParse = false ) {
|
|
|
|
|
|
if ( $noParse || preg_match( "/^https?:\/\/|ftp:\/\/|irc:\/\//", $text ) )
|
|
|
|
|
|
return parent::markNoConversion( $text );
|
2006-06-16 22:30:39 +00:00
|
|
|
|
return $text;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2011-05-22 22:05:18 +00:00
|
|
|
|
/**
|
2006-06-16 22:30:39 +00:00
|
|
|
|
* An ugly function wrapper for parsing Image titles
|
|
|
|
|
|
* (to prevent image name conversion)
|
2011-05-29 15:59:47 +00:00
|
|
|
|
*
|
2011-05-29 16:32:05 +00:00
|
|
|
|
* @param $text string
|
|
|
|
|
|
* @param $toVariant bool
|
|
|
|
|
|
*
|
2011-05-29 15:59:47 +00:00
|
|
|
|
* @return string
|
2006-06-16 22:30:39 +00:00
|
|
|
|
*/
|
2010-07-29 09:43:18 +00:00
|
|
|
|
function autoConvert( $text, $toVariant = false ) {
|
2006-06-16 22:30:39 +00:00
|
|
|
|
global $wgTitle;
|
2010-07-29 09:43:18 +00:00
|
|
|
|
if ( is_object( $wgTitle ) && $wgTitle->getNameSpace() == NS_FILE ) {
|
2006-06-16 22:30:39 +00:00
|
|
|
|
$imagename = $wgTitle->getNsText();
|
2010-07-29 09:43:18 +00:00
|
|
|
|
if ( preg_match( "/^$imagename:/", $text ) ) return $text;
|
2006-06-16 22:30:39 +00:00
|
|
|
|
}
|
2010-07-29 09:43:18 +00:00
|
|
|
|
return parent::autoConvert( $text, $toVariant );
|
2008-05-17 17:10:18 +00:00
|
|
|
|
}
|
2006-06-16 22:30:39 +00:00
|
|
|
|
|
2006-09-20 10:22:12 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* It translates text into variant, specials:
|
|
|
|
|
|
* - ommiting roman numbers
|
2011-05-29 15:59:47 +00:00
|
|
|
|
*
|
2011-05-29 16:32:05 +00:00
|
|
|
|
* @param $text string
|
|
|
|
|
|
* @param $toVariant string
|
|
|
|
|
|
*
|
2011-05-29 15:59:47 +00:00
|
|
|
|
* @return string
|
2006-09-20 10:22:12 +00:00
|
|
|
|
*/
|
2010-07-29 09:43:18 +00:00
|
|
|
|
function translate( $text, $toVariant ) {
|
2006-09-20 10:22:12 +00:00
|
|
|
|
$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})';
|
|
|
|
|
|
|
2010-07-29 09:43:18 +00:00
|
|
|
|
$reg = '/^' . $roman . '$|^' . $roman . $breaks . '|' . $breaks . $roman . '$|' . $breaks . $roman . $breaks . '/';
|
2006-09-20 10:22:12 +00:00
|
|
|
|
|
2010-07-29 09:43:18 +00:00
|
|
|
|
$matches = preg_split( $reg, $text, -1, PREG_SPLIT_OFFSET_CAPTURE );
|
2008-05-17 17:10:18 +00:00
|
|
|
|
|
2010-07-29 09:43:18 +00:00
|
|
|
|
$m = array_shift( $matches );
|
|
|
|
|
|
if ( !isset( $this->mTables[$toVariant] ) ) {
|
2006-12-27 01:49:09 +00:00
|
|
|
|
throw new MWException( "Broken variant table: " . implode( ',', array_keys( $this->mTables ) ) );
|
|
|
|
|
|
}
|
2006-11-21 09:53:45 +00:00
|
|
|
|
$ret = $this->mTables[$toVariant]->replace( $m[0] );
|
2010-07-29 09:43:18 +00:00
|
|
|
|
$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] );
|
2006-09-20 10:22:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return $ret;
|
|
|
|
|
|
}
|
2003-11-09 11:24:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
|
/**
|
2010-10-10 12:53:37 +00:00
|
|
|
|
* Serbian (Српски / Srpski)
|
|
|
|
|
|
*
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
|
* @ingroup Language
|
|
|
|
|
|
*/
|
2006-03-02 22:22:18 +00:00
|
|
|
|
class LanguageSr extends LanguageSr_ec {
|
2006-06-24 18:48:58 +00:00
|
|
|
|
function __construct() {
|
2006-03-02 22:22:18 +00:00
|
|
|
|
global $wgHooks;
|
2006-09-20 10:22:12 +00:00
|
|
|
|
|
2006-07-26 07:15:39 +00:00
|
|
|
|
parent::__construct();
|
|
|
|
|
|
|
2010-07-29 09:43:18 +00:00
|
|
|
|
$variants = array( 'sr', 'sr-ec', 'sr-el' );
|
2006-03-02 22:22:18 +00:00
|
|
|
|
$variantfallbacks = array(
|
|
|
|
|
|
'sr' => 'sr-ec',
|
2007-01-01 17:20:19 +00:00
|
|
|
|
'sr-ec' => 'sr',
|
|
|
|
|
|
'sr-el' => 'sr',
|
2008-05-17 17:10:18 +00:00
|
|
|
|
);
|
2006-09-20 10:22:12 +00:00
|
|
|
|
|
2006-03-02 22:22:18 +00:00
|
|
|
|
$flags = array(
|
|
|
|
|
|
'S' => 'S', 'писмо' => 'S', 'pismo' => 'S',
|
|
|
|
|
|
'W' => 'W', 'реч' => 'W', 'reč' => 'W', 'ријеч' => 'W', 'riječ' => 'W'
|
|
|
|
|
|
);
|
2010-07-29 09:43:18 +00:00
|
|
|
|
$this->mConverter = new SrConverter( $this, 'sr', $variants, $variantfallbacks, $flags );
|
2006-03-02 22:22:18 +00:00
|
|
|
|
$wgHooks['ArticleSaveComplete'][] = $this->mConverter;
|
|
|
|
|
|
}
|
2009-10-02 18:30:23 +00:00
|
|
|
|
|
2011-05-29 15:21:03 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* @param $count int
|
|
|
|
|
|
* @param $forms array
|
|
|
|
|
|
*
|
|
|
|
|
|
* @return string
|
|
|
|
|
|
*/
|
2009-10-02 18:30:23 +00:00
|
|
|
|
function convertPlural( $count, $forms ) {
|
2011-02-18 23:21:48 +00:00
|
|
|
|
if ( !count( $forms ) ) {
|
|
|
|
|
|
return '';
|
|
|
|
|
|
}
|
2009-10-02 18:30:23 +00:00
|
|
|
|
|
2010-07-29 09:43:18 +00:00
|
|
|
|
// if no number with word, then use $form[0] for singular and $form[1] for plural or zero
|
2011-02-18 23:21:48 +00:00
|
|
|
|
if ( count( $forms ) === 2 ) {
|
|
|
|
|
|
return $count == 1 ? $forms[0] : $forms[1];
|
|
|
|
|
|
}
|
2009-10-02 18:30:23 +00:00
|
|
|
|
|
2011-05-17 22:03:20 +00:00
|
|
|
|
// @todo FIXME: CLDR defines 4 plural forms. Form with decimals missing.
|
2009-10-02 18:30:23 +00:00
|
|
|
|
// See http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/language_plural_rules.html#ru
|
|
|
|
|
|
$forms = $this->preConvertPlural( $forms, 3 );
|
|
|
|
|
|
|
2010-07-29 09:43:18 +00:00
|
|
|
|
if ( $count > 10 && floor( ( $count % 100 ) / 10 ) == 1 ) {
|
2009-10-02 18:30:23 +00:00
|
|
|
|
return $forms[2];
|
|
|
|
|
|
} else {
|
2010-07-29 09:43:18 +00:00
|
|
|
|
switch ( $count % 10 ) {
|
2009-10-02 18:30:23 +00:00
|
|
|
|
case 1: return $forms[0];
|
|
|
|
|
|
case 2:
|
|
|
|
|
|
case 3:
|
|
|
|
|
|
case 4: return $forms[1];
|
|
|
|
|
|
default: return $forms[2];
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2006-03-02 22:22:18 +00:00
|
|
|
|
}
|