* @ingroup Language
*/
-if( !defined( 'MEDIAWIKI' ) ) {
+if ( !defined( 'MEDIAWIKI' ) ) {
echo "This file is part of MediaWiki, it is not a valid entry point.\n";
exit( 1 );
}
$wgInputEncoding = 'UTF-8';
$wgOutputEncoding = 'UTF-8';
-if( function_exists( 'mb_strtoupper' ) ) {
+if ( function_exists( 'mb_strtoupper' ) ) {
mb_internal_encoding( 'UTF-8' );
}
function getVariants() { return array( $this->mLang->getCode() ); }
function getPreferredVariant() { return $this->mLang->getCode(); }
function getConvRuleTitle() { return false; }
- function findVariantLink( &$l, &$n, $ignoreOtherCond = false ) {}
+ function findVariantLink( &$l, &$n, $ignoreOtherCond = false ) { }
function getExtraHashOptions() { return ''; }
function getParsedTitle() { return ''; }
function markNoConversion( $text, $noParse = false ) { return $text; }
*/
static function factory( $code ) {
if ( !isset( self::$mLangObjCache[$code] ) ) {
- if( count( self::$mLangObjCache ) > 10 ) {
+ if ( count( self::$mLangObjCache ) > 10 ) {
// Don't keep a billion objects around, that's stupid.
self::$mLangObjCache = array();
}
throw new MWException( "Language fallback loop detected when creating class $class\n" );
}
- if( !class_exists( $class ) ) {
+ if ( !class_exists( $class ) ) {
$fallback = Language::getFallbackFor( $code );
++$recursionLevel;
$lang = Language::newFromCode( $fallback );
* Hook which will be called if this is the content language.
* Descendants can use this to register hook functions or modify globals
*/
- function initContLang() {}
+ function initContLang() { }
/**
* @deprecated Use User::getDefaultOptions()
*/
function getFormattedNamespaces() {
$ns = $this->getNamespaces();
- foreach( $ns as $k => $v ) {
+ foreach ( $ns as $k => $v ) {
$ns[$k] = strtr( $v, '_', ' ' );
}
return $ns;
global $IP;
$names = array();
$dir = opendir( "$IP/languages/messages" );
- while( false !== ( $file = readdir( $dir ) ) ) {
+ while ( false !== ( $file = readdir( $dir ) ) ) {
$code = self::getCodeFromFileName( $file, 'Messages' );
if ( $code && isset( $allNames[$code] ) ) {
$names[$code] = $allNames[$code];
$minDiff = 0;
if ( $data[0] == 'System' || $tz == '' ) {
- # Global offset in minutes.
- if( isset( $wgLocalTZoffset ) ) {
+ # Global offset in minutes.
+ if ( isset( $wgLocalTZoffset ) ) {
$minDiff = $wgLocalTZoffset;
}
} else if ( $data[0] == 'Offset' ) {
$minDiff = intval( $data[1] );
} else {
$data = explode( ':', $tz );
- if( count( $data ) == 2 ) {
+ if ( count( $data ) == 2 ) {
$data[0] = intval( $data[0] );
$data[1] = intval( $data[1] );
$minDiff = abs( $data[0] ) * 60 + $data[1];
# will normalize out-of-range values so we don't have to split $minDiff
# into hours and minutes.
$t = mktime( (
- (int)substr( $ts, 8, 2) ), # Hours
+ (int)substr( $ts, 8, 2 ) ), # Hours
(int)substr( $ts, 10, 2 ) + $minDiff, # Minutes
(int)substr( $ts, 12, 2 ), # Seconds
(int)substr( $ts, 4, 2 ), # Month
(int)substr( $ts, 6, 2 ), # Day
- (int)substr( $ts, 0, 4 ) ); #Year
+ (int)substr( $ts, 0, 4 ) ); # Year
$date = date( 'YmdHis', $t );
wfRestoreWarnings();
} elseif ( $roman ) {
$s .= self::romanNumeral( $num );
$roman = false;
- } elseif( $hebrewNum ) {
+ } elseif ( $hebrewNum ) {
$s .= self::hebrewNumeral( $num );
$hebrewNum = false;
} else {
// Add days of the past months of this year
- for( $i = 0; $i < $gm; $i++ ) {
+ for ( $i = 0; $i < $gm; $i++ ) {
$gDayNo += self::$GREG_DAYS[$i];
}
// Leap years
- if ( $gm > 1 && ( ( $gy%4 === 0 && $gy%100 !== 0 || ( $gy%400 == 0 ) ) ) ) {
+ if ( $gm > 1 && ( ( $gy % 4 === 0 && $gy % 100 !== 0 || ( $gy % 400 == 0 ) ) ) ) {
$gDayNo++;
}
(int)( ( 275 * $zm ) / 9 ) + $zd + 1729777;
}
- $zl = $zjd-1948440 + 10632;
+ $zl = $zjd -1948440 + 10632;
$zn = (int)( ( $zl - 1 ) / 10631 );
$zl = $zl - 10631 * $zn + 354;
- $zj = ( (int)( ( 10985 - $zl ) / 5316 ) ) * ((int)( ( 50 * $zl ) / 17719 ) ) + ( (int)( $zl / 5670 ) ) * ( (int)( ( 43 * $zl ) / 15238 ) );
- $zl = $zl - ( (int)( ( 30 - $zj ) / 15 ) ) * ((int)( ( 17719 * $zj ) / 50 ) ) - ( (int)( $zj / 16 ) ) * ( (int)( ( 15238 * $zj ) / 43 ) ) + 29;
+ $zj = ( (int)( ( 10985 - $zl ) / 5316 ) ) * ( (int)( ( 50 * $zl ) / 17719 ) ) + ( (int)( $zl / 5670 ) ) * ( (int)( ( 43 * $zl ) / 15238 ) );
+ $zl = $zl - ( (int)( ( 30 - $zj ) / 15 ) ) * ( (int)( ( 17719 * $zj ) / 50 ) ) - ( (int)( $zj / 16 ) ) * ( (int)( ( 15238 * $zj ) / 43 ) ) + 29;
$zm = (int)( ( 24 * $zl ) / 709 );
$zd = $zl - (int)( ( 709 * $zm ) / 24 );
$zy = 30 * $zn + $zj - 30;
# Month number when September = 1, August = 12
$month += 4;
- if( $month > 12 ) {
+ if ( $month > 12 ) {
# Next year
$month -= 12;
$year++;
# Calculate day of year from 1 September
$dayOfYear = $day;
- for( $i = 1; $i < $month; $i++ ) {
- if( $i == 6 ) {
+ for ( $i = 1; $i < $month; $i++ ) {
+ if ( $i == 6 ) {
# February
$dayOfYear += 28;
# Check if the year is leap
- if( $year % 400 == 0 || ( $year % 4 == 0 && $year % 100 > 0 ) ) {
+ if ( $year % 400 == 0 || ( $year % 4 == 0 && $year % 100 > 0 ) ) {
$dayOfYear++;
}
- } elseif( $i == 8 || $i == 10 || $i == 1 || $i == 3 ) {
+ } elseif ( $i == 8 || $i == 10 || $i == 1 || $i == 3 ) {
$dayOfYear += 30;
} else {
$dayOfYear += 31;
$start = self::hebrewYearStart( $hebrewYear );
# Calculate next year's start
- if( $dayOfYear <= $start ) {
+ if ( $dayOfYear <= $start ) {
# Day is before the start of the year - it is the previous year
# Next year's start
$nextStart = $start;
$hebrewYear--;
# Add days since previous year's 1 September
$dayOfYear += 365;
- if( ( $year % 400 == 0 ) || ( $year % 100 != 0 && $year % 4 == 0 ) ) {
+ if ( ( $year % 400 == 0 ) || ( $year % 100 != 0 && $year % 4 == 0 ) ) {
# Leap year
$dayOfYear++;
}
# Add 12 (or 13 for leap years) days to ignore the difference between
# Hebrew and Gregorian year (353 at least vs. 365/6) - now the
# difference is only about the year type
- if( ( $year % 400 == 0 ) || ( $year % 100 != 0 && $year % 4 == 0 ) ) {
+ if ( ( $year % 400 == 0 ) || ( $year % 100 != 0 && $year % 4 == 0 ) ) {
$diff += 13;
} else {
$diff += 12;
$hebrewDay = $hebrewDayOfYear;
$hebrewMonth = 1;
$days = 0;
- while( $hebrewMonth <= 12 ) {
+ while ( $hebrewMonth <= 12 ) {
# Calculate days in this month
- if( $isLeap && $hebrewMonth == 6 ) {
+ if ( $isLeap && $hebrewMonth == 6 ) {
# Adar in a leap year
- if( $isLeap ) {
+ if ( $isLeap ) {
# Leap year - has Adar I, with 30 days, and Adar II, with 29 days
$days = 30;
- if( $hebrewDay <= $days ) {
+ if ( $hebrewDay <= $days ) {
# Day in Adar I
$hebrewMonth = 13;
} else {
$hebrewDay -= $days;
# Try Adar II
$days = 29;
- if( $hebrewDay <= $days ) {
+ if ( $hebrewDay <= $days ) {
# Day in Adar II
$hebrewMonth = 14;
}
}
}
- } elseif( $hebrewMonth == 2 && $yearPattern == 2 ) {
+ } elseif ( $hebrewMonth == 2 && $yearPattern == 2 ) {
# Cheshvan in a complete year (otherwise as the rule below)
$days = 30;
- } elseif( $hebrewMonth == 3 && $yearPattern == 0 ) {
+ } elseif ( $hebrewMonth == 3 && $yearPattern == 0 ) {
# Kislev in an incomplete year (otherwise as the rule below)
$days = 29;
} else {
# Odd months have 30 days, even have 29
$days = 30 - ( $hebrewMonth - 1 ) % 2;
}
- if( $hebrewDay <= $days ) {
+ if ( $hebrewDay <= $days ) {
# In the current month
break;
} else {
$a = intval( ( 12 * ( $year - 1 ) + 17 ) % 19 );
$b = intval( ( $year - 1 ) % 4 );
$m = 32.044093161144 + 1.5542417966212 * $a + $b / 4.0 - 0.0031777940220923 * ( $year - 1 );
- if( $m < 0 ) {
+ if ( $m < 0 ) {
$m--;
}
$Mar = intval( $m );
- if( $m < 0 ) {
+ if ( $m < 0 ) {
$m++;
}
$m -= $Mar;
- $c = intval( ( $Mar + 3 * ( $year - 1 ) + 5 * $b + 5 ) % 7);
- if( $c == 0 && $a > 11 && $m >= 0.89772376543210 ) {
+ $c = intval( ( $Mar + 3 * ( $year - 1 ) + 5 * $b + 5 ) % 7 );
+ if ( $c == 0 && $a > 11 && $m >= 0.89772376543210 ) {
$Mar++;
- } else if( $c == 1 && $a > 6 && $m >= 0.63287037037037 ) {
+ } else if ( $c == 1 && $a > 6 && $m >= 0.63287037037037 ) {
$Mar += 2;
- } else if( $c == 2 || $c == 4 || $c == 6 ) {
+ } else if ( $c == 2 || $c == 4 || $c == 6 ) {
$Mar++;
}
$num = 0;
} else {
$s .= $table[$i][intval( ( $num / $pow10 ) )];
- if( $pow10 == 1000 ) {
+ if ( $pow10 == 1000 ) {
$s .= "'";
}
}
}
$num = $num % $pow10;
}
- if( strlen( $s ) == 2 ) {
+ if ( strlen( $s ) == 2 ) {
$str = $s . "'";
} else {
$str = substr( $s, 0, strlen( $s ) - 2 ) . '"';
function dateFormat( $usePrefs = true ) {
global $wgUser;
- if( is_bool( $usePrefs ) ) {
- if( $usePrefs ) {
+ if ( is_bool( $usePrefs ) ) {
+ if ( $usePrefs ) {
$datePreference = $wgUser->getDatePreference();
} else {
$datePreference = (string)User::getDefaultOption( 'date' );
}
// return int
- if( $datePreference == '' ) {
+ if ( $datePreference == '' ) {
return 'default';
}
* validateTimeZone() in Special:Preferences
* @return string
*/
- function timeanddate( $ts, $adj = false, $format = true, $timecorrection = false) {
+ function timeanddate( $ts, $adj = false, $format = true, $timecorrection = false ) {
$ts = wfTimestamp( TS_MW, $ts );
if ( $adj ) {
$ts = $this->userAdjust( $ts, $timecorrection );
}
function checkTitleEncoding( $s ) {
- if( is_array( $s ) ) {
+ if ( is_array( $s ) ) {
wfDebugDieBacktrace( 'Given array to checkTitleEncoding.' );
}
# Check for non-UTF-8 URLs
- $ishigh = preg_match( '/[\x80-\xff]/', $s);
- if( !$ishigh ) {
+ $ishigh = preg_match( '/[\x80-\xff]/', $s );
+ if ( !$ishigh ) {
return $s;
}
$isutf8 = preg_match( '/^([\x00-\x7f]|[\xc0-\xdf][\x80-\xbf]|' .
'[\xe0-\xef][\x80-\xbf]{2}|[\xf0-\xf7][\x80-\xbf]{3})+$/', $s );
- if( $isutf8 ) {
+ if ( $isutf8 ) {
return $s;
}
* @return String
*/
function normalizeForSearch( $string ) {
- return self::convertDoubleWidth($string);
+ return self::convertDoubleWidth( $string );
}
/**
static $full = null;
static $half = null;
- if( $full === null ) {
+ if ( $full === null ) {
$fullWidth = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
$halfWidth = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
$full = str_split( $fullWidth, 3 );
# wgInputEncoding, this text will be further converted
# to wgOutputEncoding.
global $wgEditEncoding;
- if( $wgEditEncoding == '' || $wgEditEncoding == 'UTF-8' ) {
+ if ( $wgEditEncoding == '' || $wgEditEncoding == 'UTF-8' ) {
return $s;
} else {
return $this->iconv( 'UTF-8', $wgEditEncoding, $s );
function recodeInput( $s ) {
# Take the previous into account.
global $wgEditEncoding;
- if( $wgEditEncoding != '' ) {
+ if ( $wgEditEncoding != '' ) {
$enc = $wgEditEncoding;
} else {
$enc = 'UTF-8';
}
- if( $enc == 'UTF-8' ) {
+ if ( $enc == 'UTF-8' ) {
return $s;
} else {
return $this->iconv( $enc, 'UTF-8', $s );
}
}
- if( !is_array( $rawEntry ) ) {
+ if ( !is_array( $rawEntry ) ) {
error_log( "\"$rawEntry\" is not a valid magic thingie for \"$mw->mId\"" );
} else {
$mw->mCaseSensitive = $rawEntry[0];
* @param $_ mixed
* @return string
*/
- function commafy($_) {
+ function commafy( $_ ) {
return strrev( (string)preg_replace( '/(\d{3})(?=\d)(?!\d*\.)/', '$1,', strrev( $_ ) ) );
}
function listToText( $l ) {
$s = '';
$m = count( $l ) - 1;
- if( $m == 1 ) {
+ if ( $m == 1 ) {
return $l[0] . $this->getMessageFromDB( 'and' ) . $this->getMessageFromDB( 'word-separator' ) . $l[1];
} else {
for ( $i = $m; $i >= 0; $i-- ) {
if ( $i == $m ) {
$s = $l[$i];
- } else if( $i == $m - 1 ) {
+ } else if ( $i == $m - 1 ) {
$s = $l[$i] . $this->getMessageFromDB( 'and' ) . $this->getMessageFromDB( 'word-separator' ) . $s;
} else {
$s = $l[$i] . $this->getMessageFromDB( 'comma-separator' ) . $s;
$entityState = 0; // 0-not entity, 1-entity
$tag = $ret = $ch = '';
$openTags = array();
- $textLen = strlen($text);
- for( $pos = 0; $pos < $textLen; ++$pos ) {
+ $textLen = strlen( $text );
+ for ( $pos = 0; $pos < $textLen; ++$pos ) {
$ch = $text[$pos];
$lastCh = $pos ? $text[$pos - 1] : '';
$ret .= $ch; // add to result string
// like strcspn() but adds the skipped chars to $ret
private function truncate_skip( &$ret, $text, $search, $start, $len = -1 ) {
$skipCount = 0;
- if( $start < strlen( $text ) ) {
+ if ( $start < strlen( $text ) ) {
$skipCount = strcspn( $text, $search, $start, $len );
$ret .= substr( $text, $start, $skipCount );
}
// (b) clear $tag value
private function truncate_endBracket( &$tag, $tagType, $lastCh, &$openTags ) {
$tag = ltrim( $tag );
- if( $tag != '' ) {
- if( $tagType == 0 && $lastCh != '/' ) {
+ if ( $tag != '' ) {
+ if ( $tagType == 0 && $lastCh != '/' ) {
$openTags[] = $tag; // tag opened (didn't close itself)
- } else if( $tagType == 1 ) {
- if( $openTags && $tag == $openTags[count( $openTags ) - 1] ) {
+ } else if ( $tagType == 1 ) {
+ if ( $openTags && $tag == $openTags[count( $openTags ) - 1] ) {
array_pop( $openTags ); // tag closed
}
}
return $str;
}
- foreach ( explode( ',', $scBlockExpiryOptions) as $option ) {
+ foreach ( explode( ',', $scBlockExpiryOptions ) as $option ) {
if ( strpos( $option, ':' ) === false ) {
continue;
}
function formatSize( $size ) {
// For small sizes no decimal places necessary
$round = 0;
- if( $size > 1024 ) {
+ if ( $size > 1024 ) {
$size = $size / 1024;
- if( $size > 1024 ) {
+ if ( $size > 1024 ) {
$size = $size / 1024;
// For MB and bigger two decimal places are smarter
$round = 2;
- if( $size > 1024 ) {
+ if ( $size > 1024 ) {
$size = $size / 1024;
$msg = 'size-gigabytes';
} else {
/**
* Apply manual conversion rules.
- *
+ *
* @param $convRule Object: Object of ConverterRule
*/
protected function applyManualConv( $convRule ) {
// Bug 24072: $mConvRuleTitle was overwritten by other manual
// rule(s) not for title, this breaks the title conversion.
$newConvRuleTitle = $convRule->getTitle();
- if( $newConvRuleTitle ) {
+ if ( $newConvRuleTitle ) {
// So I add an empty check for getTitle()
$this->mConvRuleTitle = $newConvRuleTitle;
}
$variant = $this->getPreferredVariant();
return $this->convertTo( $text, $variant );
}
-
+
/**
* Same as convert() except a extra parameter to custom variant.
*
while ( $startPos < $length ) {
$m = false;
$pos = strpos( $text, '-{', $startPos );
-
+
if ( $pos === false ) {
// No more markup, append final segment
$out .= $this->autoConvert( substr( $text, $startPos ), $variant );
protected function recursiveConvertRule( $text, $variant, &$startPos, $depth = 0 ) {
// Quick sanity check (no function calls)
if ( $text[$startPos] !== '-' || $text[$startPos + 1] !== '{' ) {
- throw new MWException( __METHOD__.': invalid input string' );
+ throw new MWException( __METHOD__ . ': invalid input string' );
}
$startPos += 2;
$inner .= '-{';
if ( !$warningDone ) {
$inner .= '<span class="error">' .
- wfMsgForContent( 'language-converter-depth-warning',
+ wfMsgForContent( 'language-converter-depth-warning',
$this->mMaxDepth ) .
'</span>';
$warningDone = true;
$this->applyManualConv( $rule );
return $rule->getDisplay();
default:
- throw new MWException( __METHOD__.': invalid regex match' );
+ throw new MWException( __METHOD__ . ': invalid regex match' );
}
}
if ( strpos( $code, '/' ) === false ) {
$txt = $wgMessageCache->get( 'Conversiontable', true, $code );
- if( $txt === false ){
+ if ( $txt === false ) {
# FIXME: this method doesn't seem to be expecting
# this possible outcome...
$txt = '<Conversiontable>';
}
/*for unidirectional array fill to convert tables */
if ( ( $manLevel[$v] == 'bidirectional' || $manLevel[$v] == 'unidirectional' )
- && isset( $unidtable[$v] ) )
+ && isset( $unidtable[$v] ) )
{
if ( isset( $this->mConvTable[$v] ) ) {
$this->mConvTable[$v] = array_merge( $this->mConvTable[$v], $unidtable[$v] );
'kri' => 'Krio', # Krio
'krj' => 'Kinaray-a', # Kinaray-a
'ks' => 'कश्मीरी - (كشميري)', # Kashmiri
- 'ksh' => 'Ripoarisch', # Ripuarian
+ 'ksh' => 'Ripoarisch', # Ripuarian
'ku' => 'Kurdî', # Kurdish
'ku-latn' => "\xE2\x80\xAAKurdî (latînî)\xE2\x80\xAC", # Northern Kurdish Latin script
'ku-arab' => "\xE2\x80\xABكوردي (عەرەبی)\xE2\x80\xAC", # Northern Kurdish Arabic script
'lzh' => '文言', # Literary Chinese -- (bug 8217) lzh instead of zh-classical, http://www.sil.org/iso639-3/codes.asp?order=639_3&letter=l
'lzz' => 'Lazuri', # Laz
'mai' => 'मैथिली', # Maithili
- 'map-bms' => 'Basa Banyumasan', # Banyumasan
+ 'map-bms' => 'Basa Banyumasan', # Banyumasan
'mdf' => 'Мокшень', # Moksha
'mg' => 'Malagasy', # Malagasy
'mh' => 'Ebon', # Marshallese
'rue' => 'русиньскый язык', # Rusyn
'ruq' => 'Vlăheşte', # Megleno-Romanian (falls back to ruq-latn)
'ruq-cyrl' => 'Влахесте', # Megleno-Romanian (Cyrillic script)
- #'ruq-grek' => 'Βλαεστε', # Megleno-Romanian (Greek script)
+ # 'ruq-grek' => 'Βλαεστε', # Megleno-Romanian (Greek script)
'ruq-latn' => 'Vlăheşte', # Megleno-Romanian (Latin script)
'rw' => 'Kinyarwanda', # Kinyarwanda, should possibly be Kinyarwandi
'sa' => 'संस्कृत', # Sanskrit
* Use singular form for zero
*/
function convertPlural( $count, $forms ) {
- if ( !count($forms) ) { return ''; }
+ if ( !count( $forms ) ) { return ''; }
$forms = $this->preConvertPlural( $forms, 2 );
- return ($count <= 1) ? $forms[0] : $forms[1];
+ return ( $count <= 1 ) ? $forms[0] : $forms[1];
}
}
*/
class LanguageAr extends Language {
function convertPlural( $count, $forms ) {
- if ( !count($forms) ) { return ''; }
+ if ( !count( $forms ) ) { return ''; }
$forms = $this->preConvertPlural( $forms, 6 );
if ( $count == 0 ) {
$index = 0;
} elseif ( $count == 1 ) {
$index = 1;
- } elseif( $count == 2 ) {
+ } elseif ( $count == 2 ) {
$index = 2;
- } elseif( $count % 100 >= 3 && $count % 100 <= 10 ) {
+ } elseif ( $count % 100 >= 3 && $count % 100 <= 10 ) {
$index = 3;
- } elseif( $count % 100 >= 11 && $count % 100 <= 99 ) {
+ } elseif ( $count % 100 >= 11 && $count % 100 <= 99 ) {
$index = 4;
} else {
$index = 5;
}
/**
- * Temporary hack for bug 9413: replace Arabic presentation forms with their
- * standard equivalents.
+ * Temporary hack for bug 9413: replace Arabic presentation forms with their
+ * standard equivalents.
*
- * FIXME: This is language-specific for now only to avoid the negative
+ * FIXME: This is language-specific for now only to avoid the negative
* performance impact of enabling it for all languages.
*/
function normalize( $s ) {
class LanguageBat_smg extends Language {
function convertPlural( $count, $forms ) {
- if ( !count($forms) ) { return ''; }
+ if ( !count( $forms ) ) { return ''; }
$forms = $this->preConvertPlural( $forms, 4 );
$count = abs( $count );
- if ( $count === 0 || ($count%100 === 0 || ($count%100 >= 10 && $count%100 < 20)) ) {
+ if ( $count === 0 || ( $count % 100 === 0 || ( $count % 100 >= 10 && $count % 100 < 20 ) ) ) {
return $forms[2];
- } elseif ( $count%10 === 1 ) {
+ } elseif ( $count % 10 === 1 ) {
return $forms[0];
- } elseif ( $count%10 === 2 ) {
+ } elseif ( $count % 10 === 2 ) {
return $forms[1];
} else {
return $forms[3];
class LanguageBe extends Language {
function convertPlural( $count, $forms ) {
- if ( !count($forms) ) { return ''; }
+ if ( !count( $forms ) ) { return ''; }
// FIXME: CLDR defines 4 plural forms instead of 3
// http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/language_plural_rules.html
$forms = $this->preConvertPlural( $forms, 3 );
- if ($count > 10 && floor(($count % 100) / 10) == 1) {
+ if ( $count > 10 && floor( ( $count % 100 ) / 10 ) == 1 ) {
return $forms[2];
} else {
- switch ($count % 10) {
+ switch ( $count % 10 ) {
case 1: return $forms[0];
case 2:
case 3:
*/
function convertPlural( $count, $forms ) {
- if ( !count($forms) ) { return ''; }
+ if ( !count( $forms ) ) { return ''; }
- //if no number with word, then use $form[0] for singular and $form[1] for plural or zero
- if( count($forms) === 2 ) return $count == 1 ? $forms[0] : $forms[1];
+ // if no number with word, then use $form[0] for singular and $form[1] for plural or zero
+ if ( count( $forms ) === 2 ) return $count == 1 ? $forms[0] : $forms[1];
// FIXME: CLDR defines 4 plural forms instead of 3
// http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/language_plural_rules.html
$forms = $this->preConvertPlural( $forms, 3 );
- if ($count > 10 && floor(($count % 100) / 10) == 1) {
+ if ( $count > 10 && floor( ( $count % 100 ) / 10 ) == 1 ) {
return $forms[2];
} else {
- switch ($count % 10) {
+ switch ( $count % 10 ) {
case 1: return $forms[0];
case 2:
case 3:
}
}
}
-
+
/*
- * The Belarusian language uses apostrophe sign,
+ * The Belarusian language uses apostrophe sign,
* but the characters used for this could be both U+0027 and U+2019.
* This function unifies apostrophe sign in search index values
* to enable seach using both apostrophe signs.
wfProfileOut( __METHOD__ );
return $s;
}
-
+
/*
* Four-digit number should be without group commas (spaces)
* So "1 234 567", "12 345" but "1234"
*/
- function commafy($_) {
- if (preg_match('/^-?\d{1,4}(\.\d*)?$/',$_)) {
+ function commafy( $_ ) {
+ if ( preg_match( '/^-?\d{1,4}(\.\d*)?$/', $_ ) ) {
return $_;
} else {
- return strrev((string)preg_replace('/(\d{3})(?=\d)(?!\d*\.)/','$1,',strrev($_)));
+ return strrev( (string)preg_replace( '/(\d{3})(?=\d)(?!\d*\.)/', '$1,', strrev( $_ ) ) );
}
}
}
* ISO number formatting: 123 456 789,99.
* Avoid tripple grouping by numbers with whole part up to 4 digits.
*/
- function commafy($_) {
- if (!preg_match('/^\d{1,4}$/',$_)) {
- return strrev((string)preg_replace('/(\d{3})(?=\d)(?!\d*\.)/','$1,',strrev($_)));
+ function commafy( $_ ) {
+ if ( !preg_match( '/^\d{1,4}$/', $_ ) ) {
+ return strrev( (string)preg_replace( '/(\d{3})(?=\d)(?!\d*\.)/', '$1,', strrev( $_ ) ) );
} else {
return $_;
}
* Use singular form for zero
*/
function convertPlural( $count, $forms ) {
- if ( !count($forms) ) { return ''; }
+ if ( !count( $forms ) ) { return ''; }
$forms = $this->preConvertPlural( $forms, 2 );
- return ($count <= 1) ? $forms[0] : $forms[1];
+ return ( $count <= 1 ) ? $forms[0] : $forms[1];
}
}
class LanguageBs extends Language {
function convertPlural( $count, $forms ) {
- if ( !count($forms) ) { return ''; }
+ if ( !count( $forms ) ) { return ''; }
$forms = $this->preConvertPlural( $forms, 3 );
// FIXME: CLDR defines 4 plural forms instead of 3. Plural for decimals is missing.
// http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/language_plural_rules.html
- if ($count > 10 && floor(($count % 100) / 10) == 1) {
+ if ( $count > 10 && floor( ( $count % 100 ) / 10 ) == 1 ) {
return $forms[2];
} else {
- switch ($count % 10) {
+ switch ( $count % 10 ) {
case 1: return $forms[0];
case 2:
case 3:
*/
function convertGrammar( $word, $case ) {
global $wgGrammarForms;
- if ( isset($wgGrammarForms['bs'][$case][$word]) ) {
+ if ( isset( $wgGrammarForms['bs'][$case][$word] ) ) {
return $wgGrammarForms['bs'][$case][$word];
}
switch ( $case ) {
# {{plural:count|form1|form0,2+}} for single form plurals
# in a message
function convertPlural( $count, $forms ) {
- if ( !count($forms) ) { return ''; }
+ if ( !count( $forms ) ) { return ''; }
$forms = $this->preConvertPlural( $forms, 3 );
switch ( $count ) {
# Invoked with {{grammar:case|word}}
function convertGrammar( $word, $case ) {
global $wgGrammarForms;
- if ( isset($wgGrammarForms['сu'][$case][$word]) ) {
+ if ( isset( $wgGrammarForms['сu'][$case][$word] ) ) {
return $wgGrammarForms['сu'][$case][$word];
}
# These rules are not perfect, but they are currently only used for site names so it doesn't
# matter if they are wrong sometimes. Just add a special case for your site name if necessary.
- #join and array_slice instead mb_substr
+ # join and array_slice instead mb_substr
$ar = array();
preg_match_all( '/./us', $word, $ar );
- if (!preg_match("/[a-zA-Z_]/us", $word))
+ if ( !preg_match( "/[a-zA-Z_]/us", $word ) )
switch ( $case ) {
- case 'genitive': #родительный падеж
- if ((join('',array_slice($ar[0],-4))=='вики') || (join('',array_slice($ar[0],-4))=='Вики'))
- {}
- elseif (join('',array_slice($ar[0],-2))=='ї')
- $word = join('',array_slice($ar[0],0,-2)).'їѩ';
+ case 'genitive': # родительный падеж
+ if ( ( join( '', array_slice( $ar[0], -4 ) ) == 'вики' ) || ( join( '', array_slice( $ar[0], -4 ) ) == 'Вики' ) )
+ { }
+ elseif ( join( '', array_slice( $ar[0], -2 ) ) == 'ї' )
+ $word = join( '', array_slice( $ar[0], 0, -2 ) ) . 'їѩ';
break;
- case 'accusative': #винительный падеж
- #stub
+ case 'accusative': # винительный падеж
+ # stub
break;
}
return $word;
}
function convertPlural( $count, $forms ) {
- if ( !count($forms) ) { return ''; }
+ if ( !count( $forms ) ) { return ''; }
$forms = $this->preConvertPlural( $forms, 4 );
- switch ($count % 10) {
+ switch ( $count % 10 ) {
case 1: return $forms[0];
case 2: return $forms[1];
case 3:
*/
class LanguageCy extends Language {
function convertPlural( $count, $forms ) {
- if ( !count($forms) ) { return ''; }
+ if ( !count( $forms ) ) { return ''; }
// FIXME: CLDR defines 4 plural forms; very different, actually.
// See http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/language_plural_rules.html#cy
}
function convertPlural( $count, $forms ) {
- if ( !count($forms) ) { return ''; }
+ if ( !count( $forms ) ) { return ''; }
$forms = $this->preConvertPlural( $forms, 4 );
switch ( abs( $count ) % 100 ) {
function iconv( $in, $out, $string ) {
# Por multaj lingvoj, ĉi tiu nur voku la sisteman funkcion iconv()
# Ni ankaŭ konvertu X-sistemajn surogotajn
- if( strcasecmp( $in, 'x' ) == 0 and strcasecmp( $out, 'utf-8' ) == 0) {
+ if ( strcasecmp( $in, 'x' ) == 0 and strcasecmp( $out, 'utf-8' ) == 0 ) {
$xu = array (
'xx' => 'x' , 'xX' => 'x' ,
'Xx' => 'X' , 'XX' => 'X' ,
) ;
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 ) {
+ } else if ( strcasecmp( $in, 'UTF-8' ) == 0 and strcasecmp( $out, 'x' ) == 0 ) {
$ux = array (
'x' => 'xx' , 'X' => 'Xx' ,
"\xc4\x88" => "Cx" , "\xc4\x89" => "cx" ,
"\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]'.
+ 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 parent::iconv( $in, $out, $string );
function checkTitleEncoding( $s ) {
# Check for X-system backwards-compatibility URLs
- $ishigh = preg_match( '/[\x80-\xff]/', $s);
+ $ishigh = preg_match( '/[\x80-\xff]/', $s );
$isutf = preg_match( '/^([\x00-\x7f]|[\xc0-\xdf][\x80-\xbf]|' .
'[\xe0-\xef][\x80-\xbf]{2}|[\xf0-\xf7][\x80-\xbf]{3})+$/', $s );
- if($ishigh and !$isutf) {
+ if ( $ishigh and !$isutf ) {
# Assume Latin1
$s = utf8_encode( $s );
} else {
- if( preg_match( '/(\xc4[\x88\x89\x9c\x9d\xa4\xa5\xb4\xb5]'.
+ if ( preg_match( '/(\xc4[\x88\x89\x9c\x9d\xa4\xa5\xb4\xb5]' .
'|\xc5[\x9c\x9d\xac\xad])/', $s ) )
return $s;
}
- //if( preg_match( '/[cghjsu]x/i', $s ) )
+ // if( preg_match( '/[cghjsu]x/i', $s ) )
// return $this->iconv( 'x', 'utf-8', $s );
return $s;
}
/**
* Avoid grouping whole numbers between 0 to 9999
*/
- function commafy($_) {
- if (!preg_match('/^\d{1,4}$/',$_)) {
- return strrev((string)preg_replace('/(\d{3})(?=\d)(?!\d*\.)/','$1,',strrev($_)));
+ function commafy( $_ ) {
+ if ( !preg_match( '/^\d{1,4}$/', $_ ) ) {
+ return strrev( (string)preg_replace( '/(\d{3})(?=\d)(?!\d*\.)/', '$1,', strrev( $_ ) ) );
} else {
return $_;
}
# Invoked with {{GRAMMAR:case|word}}
function convertGrammar( $word, $case ) {
global $wgGrammarForms;
- if ( isset($wgGrammarForms['fi'][$case][$word]) ) {
+ if ( isset( $wgGrammarForms['fi'][$case][$word] ) ) {
return $wgGrammarForms['fi'][$case][$word];
}
$word .= 'n';
break;
case 'elative':
- $word .= ($aou ? 'sta' : 'stä');
+ $word .= ( $aou ? 'sta' : 'stä' );
break;
case 'partitive':
- $word .= ($aou ? 'a' : 'ä');
+ $word .= ( $aou ? 'a' : 'ä' );
break;
case 'illative':
# Double the last letter and add 'n'
# mb_substr has a compatibility function in GlobalFunctions.php
- $word = $word . mb_substr($word, -1) . 'n';
+ $word = $word . mb_substr( $word, -1 ) . 'n';
break;
case 'inessive':
- $word .= ($aou ? 'ssa' : 'ssä');
+ $word .= ( $aou ? 'ssa' : 'ssä' );
break;
}
return $word;
);
$final = '';
- $tokens = explode ( ' ', $str);
- foreach( $tokens as $item ) {
- if ( !is_numeric($item) ) {
- if ( count ( explode( '-', $item ) ) == 3 && strlen($item) == 10 ) {
+ $tokens = explode ( ' ', $str );
+ foreach ( $tokens as $item ) {
+ if ( !is_numeric( $item ) ) {
+ if ( count ( explode( '-', $item ) ) == 3 && strlen( $item ) == 10 ) {
list( $yyyy, $mm, $dd ) = explode( '-', $item );
- $final .= ' ' . $this->date( "{$yyyy}{$mm}{$dd}00000000");
+ $final .= ' ' . $this->date( "{$yyyy}{$mm}{$dd}00000000" );
continue;
}
- if( isset( $weekds[$item] ) ) {
+ if ( isset( $weekds[$item] ) ) {
$final .= ' ' . $weekds[$item];
continue;
}
* Use singular form for zero (see bug 7309)
*/
function convertPlural( $count, $forms ) {
- if ( !count($forms) ) { return ''; }
+ if ( !count( $forms ) ) { return ''; }
$forms = $this->preConvertPlural( $forms, 2 );
- return ($count <= 1) ? $forms[0] : $forms[1];
+ return ( $count <= 1 ) ? $forms[0] : $forms[1];
}
}
# Invoked with {{GRAMMAR:transformation|word}}
function convertGrammar( $word, $case ) {
global $wgGrammarForms;
- if ( isset($wgGrammarForms['ga'][$case][$word]) ) {
+ if ( isset( $wgGrammarForms['ga'][$case][$word] ) ) {
return $wgGrammarForms['ga'][$case][$word];
}
switch ( $case ) {
case 'ainmlae':
- switch ($word) {
+ switch ( $word ) {
case 'an Domhnach':
$word = 'Dé Domhnaigh'; break;
case 'an Luan':
}
function convertPlural( $count, $forms ) {
- if ( !count($forms) ) { return ''; }
+ if ( !count( $forms ) ) { return ''; }
// plural forms per http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/language_plural_rules.html#ga
$forms = $this->preConvertPlural( $forms, 3 );
if ( $count == 1 ) {
$index = 0;
- } elseif( $count == 2 ) {
+ } elseif ( $count == 2 ) {
$index = 1;
} else {
$index = 2;
<?php
-require_once( dirname(__FILE__).'/../LanguageConverter.php' );
-require_once( dirname(__FILE__).'/LanguageZh.php' );
+require_once( dirname( __FILE__ ) . '/../LanguageConverter.php' );
+require_once( dirname( __FILE__ ) . '/LanguageZh.php' );
/**
* @ingroup Language
*/
class GanConverter extends LanguageConverter {
- function __construct($langobj, $maincode,
- $variants=array(),
- $variantfallbacks=array(),
+ function __construct( $langobj, $maincode,
+ $variants = array(),
+ $variantfallbacks = array(),
$flags = array(),
$manualLevel = array() ) {
$this->mDescCodeSep = ':';
$this->mDescVarSep = ';';
- parent::__construct($langobj, $maincode,
+ parent::__construct( $langobj, $maincode,
$variants,
$variantfallbacks,
$flags,
- $manualLevel);
+ $manualLevel );
$names = array(
'gan' => '原文',
'gan-hans' => '简体',
'gan-hant' => '繁體',
);
- $this->mVariantNames = array_merge($this->mVariantNames,$names);
+ $this->mVariantNames = array_merge( $this->mVariantNames, $names );
}
function loadDefaultTables() {
- require( dirname(__FILE__)."/../../includes/ZhConversion.php" );
+ require( dirname( __FILE__ ) . "/../../includes/ZhConversion.php" );
$this->mTables = array(
'gan-hans' => new ReplacementArray( $zh2Hans ),
'gan-hant' => new ReplacementArray( $zh2Hant ),
to mark anything.
$noParse is there for compatibility with LanguageConvert::markNoConversion
*/
- function markNoConversion($text, $noParse = false) {
+ function markNoConversion( $text, $noParse = false ) {
return $text;
}
global $wgHooks;
parent::__construct();
- $variants = array('gan','gan-hans','gan-hant');
+ $variants = array( 'gan', 'gan-hans', 'gan-hant' );
$variantfallbacks = array(
- 'gan' => array('gan-hans','gan-hant'),
- 'gan-hans' => array('gan'),
- 'gan-hant' => array('gan'),
+ 'gan' => array( 'gan-hans', 'gan-hant' ),
+ 'gan-hans' => array( 'gan' ),
+ 'gan-hant' => array( 'gan' ),
);
- $ml=array(
+ $ml = array(
'gan' => 'disable',
);
$this->mConverter = new GanConverter( $this, 'gan',
$variants, $variantfallbacks,
array(),
- $ml);
+ $ml );
$wgHooks['ArticleSaveComplete'][] = $this->mConverter;
}
function segmentForDiff( $text ) {
return preg_replace(
"/([\\xc0-\\xff][\\x80-\\xbf]*)/e",
- "' ' .\"$1\"", $text);
+ "' ' .\"$1\"", $text );
}
function unsegmentForDiff( $text ) {
return preg_replace(
"/ ([\\xc0-\\xff][\\x80-\\xbf]*)/e",
- "\"$1\"", $text);
+ "\"$1\"", $text );
}
// word segmentation
$terms = implode( '|', $termsArray );
$terms = self::convertDoubleWidth( $terms );
$terms = implode( '|', $this->mConverter->autoConvertToAllVariants( $terms ) );
- $ret = array_unique( explode('|', $terms) );
+ $ret = array_unique( explode( '|', $terms ) );
return $ret;
}
}
*
*/
function convertPlural( $count, $forms ) {
- if ( !count($forms) ) { return ''; }
+ if ( !count( $forms ) ) { return ''; }
$forms = $this->preConvertPlural( $forms, 4 );
$count = abs( $count );
class LanguageGv extends Language {
function convertPlural( $count, $forms ) {
- if ( !count($forms) ) { return ''; }
+ if ( !count( $forms ) ) { return ''; }
$forms = $this->preConvertPlural( $forms, 4 );
- if ($count > 0 && ($count % 20) === 0 ) {
+ if ( $count > 0 && ( $count % 20 ) === 0 ) {
return $forms[0];
} else {
- switch ($count % 10) {
+ switch ( $count % 10 ) {
case 1: return $forms[1];
case 2: return $forms[2];
default: return $forms[3];
*/
public function convertGrammar( $word, $case ) {
global $wgGrammarForms;
- if ( isset($wgGrammarForms['he'][$case][$word]) ) {
+ if ( isset( $wgGrammarForms['he'][$case][$word] ) ) {
return $wgGrammarForms['he'][$case][$word];
}
case 'תחילית':
# Duplicate the "Waw" if prefixed
if ( substr( $word, 0, 2 ) == "ו" && substr( $word, 0, 4 ) != "וו" ) {
- $word = "ו".$word;
+ $word = "ו" . $word;
}
# Remove the "He" if prefixed
# Add a hyphen if non-Hebrew letters
if ( substr( $word, 0, 2 ) < "א" || substr( $word, 0, 2 ) > "ת" ) {
- $word = "־".$word;
+ $word = "־" . $word;
}
}
* @return String: the suited form of word
*/
function convertPlural( $count, $forms ) {
- if ( !count($forms) ) { return ''; }
+ if ( !count( $forms ) ) { return ''; }
$forms = $this->preConvertPlural( $forms, 3 );
if ( $count == '1' ) {
return $forms[0];
- } elseif ( $count == '2' && isset($forms[2]) ) {
+ } elseif ( $count == '2' && isset( $forms[2] ) ) {
return $forms[2];
} else {
return $forms[1];
* Use singular form for zero
*/
function convertPlural( $count, $forms ) {
- if ( !count($forms) ) { return ''; }
+ if ( !count( $forms ) ) { return ''; }
$forms = $this->preConvertPlural( $forms, 2 );
- return ($count <= 1) ? $forms[0] : $forms[1];
+ return ( $count <= 1 ) ? $forms[0] : $forms[1];
}
}
class LanguageHr extends Language {
function convertPlural( $count, $forms ) {
- if ( !count($forms) ) { return ''; }
+ if ( !count( $forms ) ) { return ''; }
// FIXME: CLDR defines 4 plural forms instead of 3. Plural for for decimals is missing.
// http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/language_plural_rules.html
$forms = $this->preConvertPlural( $forms, 3 );
- if ($count > 10 && floor(($count % 100) / 10) == 1) {
+ if ( $count > 10 && floor( ( $count % 100 ) / 10 ) == 1 ) {
return $forms[2];
} else {
- switch ($count % 10) {
+ switch ( $count % 10 ) {
case 1: return $forms[0];
case 2:
case 3:
}
function convertPlural( $count, $forms ) {
- if ( !count($forms) ) { return ''; }
+ if ( !count( $forms ) ) { return ''; }
$forms = $this->preConvertPlural( $forms, 4 );
switch ( abs( $count ) % 100 ) {
class LanguageHu extends Language {
function convertGrammar( $word, $case ) {
global $wgGrammarForms;
- if ( isset($wgGrammarForms[$this->getCode()][$case][$word]) ) {
+ if ( isset( $wgGrammarForms[$this->getCode()][$case][$word] ) ) {
return $wgGrammarForms[$this->getCode()][$case][$word];
}
# Invoked with {{grammar:case|word}}
function convertGrammar( $word, $case ) {
global $wgGrammarForms;
- if ( isset($wgGrammarForms['hy'][$case][$word]) ) {
+ if ( isset( $wgGrammarForms['hy'][$case][$word] ) ) {
return $wgGrammarForms['hy'][$case][$word];
}
# These rules are not perfect, but they are currently only used for site names so it doesn't
# matter if they are wrong sometimes. Just add a special case for your site name if necessary.
- #join and array_slice instead mb_substr
+ # join and array_slice instead mb_substr
$ar = array();
preg_match_all( '/./us', $word, $ar );
- if (!preg_match("/[a-zA-Z_]/us", $word))
+ if ( !preg_match( "/[a-zA-Z_]/us", $word ) )
switch ( $case ) {
- case 'genitive': #սեռական հոլով
- if (join('',array_slice($ar[0],-1))=='ա')
- $word = join('',array_slice($ar[0],0,-1)).'այի';
- elseif (join('',array_slice($ar[0],-1))=='ո')
- $word=join('',array_slice($ar[0],0,-1)).'ոյի';
- elseif (join('',array_slice($ar[0],-4))=='գիրք')
- $word=join('',array_slice($ar[0],0,-4)).'գրքի';
+ case 'genitive': # սեռական հոլով
+ if ( join( '', array_slice( $ar[0], -1 ) ) == 'ա' )
+ $word = join( '', array_slice( $ar[0], 0, -1 ) ) . 'այի';
+ elseif ( join( '', array_slice( $ar[0], -1 ) ) == 'ո' )
+ $word = join( '', array_slice( $ar[0], 0, -1 ) ) . 'ոյի';
+ elseif ( join( '', array_slice( $ar[0], -4 ) ) == 'գիրք' )
+ $word = join( '', array_slice( $ar[0], 0, -4 ) ) . 'գրքի';
else
- $word.='ի';
+ $word .= 'ի';
break;
- case 'dative': #Տրական հոլով
- #stub
+ case 'dative': # Տրական հոլով
+ # stub
break;
- case 'accusative': #Հայցական հոլով
- #stub
+ case 'accusative': # Հայցական հոլով
+ # stub
break;
case 'instrumental': #
- #stub
+ # stub
break;
case 'prepositional': #
- #stub
+ # stub
break;
}
return $word;
}
function convertPlural( $count, $forms ) {
- if ( !count($forms) ) { return ''; }
+ if ( !count( $forms ) ) { return ''; }
$forms = $this->preConvertPlural( $forms, 2 );
- return (abs($count) <= 1) ? $forms[0] : $forms[1];
+ return ( abs( $count ) <= 1 ) ? $forms[0] : $forms[1];
}
/*
* Armenian numeric format is "12 345,67" but "1234,56"
*/
- function commafy($_) {
- if (!preg_match('/^\d{1,4}$/',$_)) {
- return strrev((string)preg_replace('/(\d{3})(?=\d)(?!\d*\.)/','$1,',strrev($_)));
+ function commafy( $_ ) {
+ if ( !preg_match( '/^\d{1,4}$/', $_ ) ) {
+ return strrev( (string)preg_replace( '/(\d{3})(?=\d)(?!\d*\.)/', '$1,', strrev( $_ ) ) );
} else {
return $_;
}
*/
function commafy( $_ ) {
if ( !preg_match( '/^\d{1,4}$/', $_ ) ) {
- return strrev( (string)preg_replace( '/(\d{3})(?=\d)(?!\d*\.)/', '$1,', strrev($_) ) );
+ return strrev( (string)preg_replace( '/(\d{3})(?=\d)(?!\d*\.)/', '$1,', strrev( $_ ) ) );
} else {
return $_;
}
// changed on a subsequent page view.
// see http://lists.wikimedia.org/pipermail/wikitech-l/2006-January/021311.html
-require_once( dirname(__FILE__).'/../LanguageConverter.php' );
-require_once( dirname(__FILE__).'/LanguageKk_cyrl.php' );
+require_once( dirname( __FILE__ ) . '/../LanguageConverter.php' );
+require_once( dirname( __FILE__ ) . '/LanguageKk_cyrl.php' );
<?php
-require_once( dirname(__FILE__).'/../LanguageConverter.php' );
-require_once( dirname(__FILE__).'/LanguageKk_cyrl.php' );
+require_once( dirname( __FILE__ ) . '/../LanguageConverter.php' );
+require_once( dirname( __FILE__ ) . '/LanguageKk_cyrl.php' );
define( 'KK_C_UC', 'АӘБВГҒДЕЁЖЗИЙКҚЛМНҢОӨПРСТУҰҮФХҺЦЧШЩЪЫІЬЭЮЯ' ); # Kazakh Cyrillic uppercase
define( 'KK_C_LC', 'аәбвгғдеёжзийкқлмнңоөпрстуұүфхһцчшщъыіьэюя' ); # Kazakh Cyrillic lowercase
define( 'KK_L_UC', 'AÄBCÇDEÉFGĞHIİÏJKLMNÑOÖPQRSŞTUÜVWXYÝZ' ); # Kazakh Latin uppercase
define( 'KK_L_LC', 'aäbcçdeéfgğhıiïjklmnñoöpqrsştuüvwxyýz' ); # Kazakh Latin lowercase
-//define( 'KK_A', 'ٴابپتجحدرزسشعفقكلمنڭەوۇۋۆىيچھ' ); # Kazakh Arabic
+// define( 'KK_A', 'ٴابپتجحدرزسشعفقكلمنڭەوۇۋۆىيچھ' ); # Kazakh Arabic
define( 'H_HAMZA', 'ٴ' ); # U+0674 ARABIC LETTER HIGH HAMZA
-//define( 'ZWNJ', '' ); # U+200C ZERO WIDTH NON-JOINER
+// define( 'ZWNJ', '' ); # U+200C ZERO WIDTH NON-JOINER
/** Kazakh (Қазақша)
* converter routines
*/
class KkConverter extends LanguageConverter {
- function __construct($langobj, $maincode,
- $variants=array(),
- $variantfallbacks=array(),
- $flags = array()) {
+ function __construct( $langobj, $maincode,
+ $variants = array(),
+ $variantfallbacks = array(),
+ $flags = array() ) {
parent::__construct( $langobj, $maincode,
$variants, $variantfallbacks, $flags );
'kk-cyrl' => new ReplacementArray( $kk2Cyrl ),
'kk-latn' => new ReplacementArray( $kk2Latn ),
'kk-arab' => new ReplacementArray( $kk2Arab ),
- 'kk-kz' => new ReplacementArray( array_merge($kk2Cyrl, $kk2KZ) ),
- 'kk-tr' => new ReplacementArray( array_merge($kk2Latn, $kk2TR) ),
- 'kk-cn' => new ReplacementArray( array_merge($kk2Arab, $kk2CN) ),
+ 'kk-kz' => new ReplacementArray( array_merge( $kk2Cyrl, $kk2KZ ) ),
+ 'kk-tr' => new ReplacementArray( array_merge( $kk2Latn, $kk2TR ) ),
+ 'kk-cn' => new ReplacementArray( array_merge( $kk2Arab, $kk2CN ) ),
'kk' => new ReplacementArray()
);
}
function loadRegs() {
$this->mCyrl2Latn = array(
- ## Punctuation
+ # # Punctuation
'/№/u' => 'No.',
- ## Е after vowels
+ # # Е after vowels
'/([АӘЕЁИОӨҰҮЭЮЯЪЬ])Е/u' => '$1YE',
'/([АӘЕЁИОӨҰҮЭЮЯЪЬ])е/ui' => '$1ye',
- ## leading ЁЮЯЩ
- '/^Ё(['.KK_C_UC.']|$)/u' => 'YO$1', '/^Ё(['.KK_C_LC.']|$)/u' => 'Yo$1',
- '/^Ю(['.KK_C_UC.']|$)/u' => 'YU$1', '/^Ю(['.KK_C_LC.']|$)/u' => 'Yu$1',
- '/^Я(['.KK_C_UC.']|$)/u' => 'YA$1', '/^Я(['.KK_C_LC.']|$)/u' => 'Ya$1',
- '/^Щ(['.KK_C_UC.']|$)/u' => 'ŞÇ$1', '/^Щ(['.KK_C_LC.']|$)/u' => 'Şç$1',
- ## other ЁЮЯ
+ # # leading ЁЮЯЩ
+ '/^Ё([' . KK_C_UC . ']|$)/u' => 'YO$1', '/^Ё([' . KK_C_LC . ']|$)/u' => 'Yo$1',
+ '/^Ю([' . KK_C_UC . ']|$)/u' => 'YU$1', '/^Ю([' . KK_C_LC . ']|$)/u' => 'Yu$1',
+ '/^Я([' . KK_C_UC . ']|$)/u' => 'YA$1', '/^Я([' . KK_C_LC . ']|$)/u' => 'Ya$1',
+ '/^Щ([' . KK_C_UC . ']|$)/u' => 'ŞÇ$1', '/^Щ([' . KK_C_LC . ']|$)/u' => 'Şç$1',
+ # # other ЁЮЯ
'/Ё/u' => 'YO', '/ё/u' => 'yo',
'/Ю/u' => 'YU', '/ю/u' => 'yu',
'/Я/u' => 'YA', '/я/u' => 'ya',
'/Щ/u' => 'ŞÇ', '/щ/u' => 'şç',
- ## soft and hard signs
+ # # soft and hard signs
'/[ъЪ]/u' => 'ʺ', '/[ьЬ]/u' => 'ʹ',
- ## other characters
+ # # other characters
'/А/u' => 'A', '/а/u' => 'a', '/Ә/u' => 'Ä', '/ә/u' => 'ä',
'/Б/u' => 'B', '/б/u' => 'b', '/В/u' => 'V', '/в/u' => 'v',
'/Г/u' => 'G', '/г/u' => 'g', '/Ғ/u' => 'Ğ', '/ғ/u' => 'ğ',
);
$this->mLatn2Cyrl = array(
- ## Punctuation
+ # # Punctuation
'/#|No\./' => '№',
- ## Şç
- '/ŞÇʹ/u'=> 'ЩЬ', '/Şçʹ/u'=> 'Щь', '/Şçʹ/u'=> 'Щь',
+ # # Şç
+ '/ŞÇʹ/u' => 'ЩЬ', '/Şçʹ/u' => 'Щь', '/Şçʹ/u' => 'Щь',
'/Ş[Çç]/u' => 'Щ', '/şç/u' => 'щ',
- ## soft and hard signs
- '/(['.KK_L_UC.'])ʺ(['.KK_L_UC.'])/u' => '$1Ъ$2',
- '/ʺ(['.KK_L_LC.'])/u' => 'ъ$1',
- '/(['.KK_L_UC.'])ʹ(['.KK_L_UC.'])/u' => '$1Ь$2',
- '/ʹ(['.KK_L_LC.'])/u' => 'ь$1',
+ # # soft and hard signs
+ '/([' . KK_L_UC . '])ʺ([' . KK_L_UC . '])/u' => '$1Ъ$2',
+ '/ʺ([' . KK_L_LC . '])/u' => 'ъ$1',
+ '/([' . KK_L_UC . '])ʹ([' . KK_L_UC . '])/u' => '$1Ь$2',
+ '/ʹ([' . KK_L_LC . '])/u' => 'ь$1',
'/ʺ/u' => 'ъ',
'/ʹ/u' => 'ь',
- ## Ye Yo Yu Ya.
+ # # Ye Yo Yu Ya.
'/Y[Ee]/u' => 'Е', '/ye/u' => 'е',
'/Y[Oo]/u' => 'Ё', '/yo/u' => 'ё',
'/Y[UWuw]/u' => 'Ю', '/y[uw]/u' => 'ю',
'/Y[Aa]/u' => 'Я', '/ya/u' => 'я',
- ## other characters
+ # # other characters
'/A/u' => 'А', '/a/u' => 'а', '/Ä/u' => 'Ә', '/ä/u' => 'ә',
'/B/u' => 'Б', '/b/u' => 'б', '/C/u' => 'Ц', '/c/u' => 'ц',
'/Ç/u' => 'Ч', '/ç/u' => 'ч', '/D/u' => 'Д', '/d/u' => 'д',
);
$this->mCyLa2Arab = array(
- ## Punctuation -> Arabic
+ # # Punctuation -> Arabic
'/#|№|No\./u' => '', # ؀
'/\,/' => '،', # ،
'/;/' => '؛', # ؛
'/\?/' => '؟', # ؟
'/%/' => '٪', # ٪
'/\*/' => '٭', # ٭
- ## Digits -> Arabic
+ # # Digits -> Arabic
'/0/' => '۰', # ۰
'/1/' => '۱', # ۱
'/2/' => '۲', # ۲
'/7/' => '۷', # ۷
'/8/' => '۸', # ۸
'/9/' => '۹', # ۹
- ## Cyrillic -> Arabic
+ # # Cyrillic -> Arabic
'/Аллаһ/ui' => 'ﷲ',
'/([АӘЕЁИОӨҰҮЭЮЯЪЬ])е/ui' => '$1يە',
'/[еэ]/ui' => 'ە', '/[ъь]/ui' => '',
'/[и]/ui' => 'ىي', '/ё/ui' => 'يو', '/ю/ui' => 'يۋ', '/я/ui' => 'يا', '/[й]/ui' => 'ي',
'/ц/ui' => 'تس', '/щ/ui' => 'شش',
'/һ/ui' => 'ح', '/ч/ui' => 'تش',
- #'/һ/ui' => 'ھ', '/ч/ui' => 'چ',
+ # '/һ/ui' => 'ھ', '/ч/ui' => 'چ',
'/б/ui' => 'ب', '/в/ui' => 'ۆ', '/г/ui' => 'گ', '/ғ/ui' => 'ع',
'/д/ui' => 'د', '/ж/ui' => 'ج', '/з/ui' => 'ز', '/к/ui' => 'ك',
'/қ/ui' => 'ق', '/л/ui' => 'ل', '/м/ui' => 'م', '/н/ui' => 'ن',
'/ң/ui' => 'ڭ', '/п/ui' => 'پ', '/р/ui' => 'ر', '/с/ui' => 'س',
'/т/ui' => 'ت', '/у/ui' => 'ۋ', '/ф/ui' => 'ف', '/х/ui' => 'ح',
'/ш/ui' => 'ش',
- ## Latin -> Arabic // commented for now...
+ # # Latin -> Arabic // commented for now...
/*'/Allah/ui' => 'ﷲ',
'/[eé]/ui' => 'ە', '/[yý]/ui' => 'ي', '/[ʺʹ]/ui' => '',
'/[aä]/ui' => 'ا', '/[oö]/ui' => 'و', '/[uü]/ui' => 'ۇ',
update: delete all rule parsing because it's not used
currently, and just produces a couple of bugs
*/
- function parseManualRule($rule, $flags=array()) {
- if(in_array('T',$flags)){
- return parent::parseManualRule($rule, $flags);
+ function parseManualRule( $rule, $flags = array() ) {
+ if ( in_array( 'T', $flags ) ) {
+ return parent::parseManualRule( $rule, $flags );
}
// otherwise ignore all formatting
- foreach($this->mVariants as $v) {
+ foreach ( $this->mVariants as $v ) {
$carray[$v] = $rule;
}
*/
function findVariantLink( &$link, &$nt, $ignoreOtherCond = false ) {
// check for user namespace
- if(is_object($nt)){
+ if ( is_object( $nt ) ) {
$ns = $nt->getNamespace();
- if($ns==NS_USER || $ns==NS_USER_TALK)
+ if ( $ns == NS_USER || $ns == NS_USER_TALK )
return;
}
- $oldlink=$link;
+ $oldlink = $link;
parent::findVariantLink( $link, $nt, $ignoreOtherCond );
- if( $this->getPreferredVariant()==$this->mMainLanguageCode )
- $link=$oldlink;
+ if ( $this->getPreferredVariant() == $this->mMainLanguageCode )
+ $link = $oldlink;
}
/*
* An ugly function wrapper for parsing Image titles
* (to prevent image name conversion)
*/
- function autoConvert($text, $toVariant=false) {
+ function autoConvert( $text, $toVariant = false ) {
global $wgTitle;
- if(is_object($wgTitle) && $wgTitle->getNameSpace()==NS_FILE){
+ if ( is_object( $wgTitle ) && $wgTitle->getNameSpace() == NS_FILE ) {
$imagename = $wgTitle->getNsText();
- if(preg_match("/^$imagename:/",$text)) return $text;
+ if ( preg_match( "/^$imagename:/", $text ) ) return $text;
}
- return parent::autoConvert($text,$toVariant);
+ return parent::autoConvert( $text, $toVariant );
}
/**
* It translates text into variant
*/
- function translate( $text, $toVariant ){
+ function translate( $text, $toVariant ) {
global $wgContLanguageCode;
$text = parent::translate( $text, $toVariant );
break;
case 'kk-arab':
case 'kk-cn':
- $letters = KK_C_UC.KK_C_LC./*KK_L_UC.KK_L_LC.'ʺʹ'.*/',;\?%\*№0123456789';
+ $letters = KK_C_UC . KK_C_LC . /*KK_L_UC.KK_L_LC.'ʺʹ'.*/',;\?%\*№0123456789';
$wgContLanguageCode = 'kk-Arab';
break;
default:
// disable conversion variables like $1, $2...
$varsfix = '\$[0-9]';
- $matches = preg_split( '/' . $varsfix . '[^' . $letters . ']+/u', $text, -1, PREG_SPLIT_OFFSET_CAPTURE);
+ $matches = preg_split( '/' . $varsfix . '[^' . $letters . ']+/u', $text, -1, PREG_SPLIT_OFFSET_CAPTURE );
$mstart = 0;
$ret = '';
- foreach( $matches as $m ) {
- $ret .= substr( $text, $mstart, $m[1]-$mstart );
+ foreach ( $matches as $m ) {
+ $ret .= substr( $text, $mstart, $m[1] -$mstart );
$ret .= $this->regsConverter( $m[0], $toVariant );
- $mstart = $m[1] + strlen($m[0]);
+ $mstart = $m[1] + strlen( $m[0] );
}
return $ret;
}
function regsConverter( $text, $toVariant ) {
- if ($text == '') return $text;
+ if ( $text == '' ) return $text;
$pat = array();
$rep = array();
switch( $toVariant ) {
case 'kk-arab':
case 'kk-cn':
- $letters = KK_C_LC.KK_C_UC/*.KK_L_LC.KK_L_UC*/;
+ $letters = KK_C_LC . KK_C_UC/*.KK_L_LC.KK_L_UC*/;
$front = 'әөүіӘӨҮІ'/*.'äöüiÄÖÜİ'*/;
$excludes = 'еэгғкқЕЭГҒКҚ'/*.'eégğkqEÉGĞKQ'*/;
// split text to words
- $matches = preg_split( '/[\b\s\-\.:]+/', $text, -1, PREG_SPLIT_OFFSET_CAPTURE);
+ $matches = preg_split( '/[\b\s\-\.:]+/', $text, -1, PREG_SPLIT_OFFSET_CAPTURE );
$mstart = 0;
$ret = '';
- foreach( $matches as $m ) {
+ foreach ( $matches as $m ) {
$ret .= substr( $text, $mstart, $m[1] - $mstart );
// is matched the word to front vowels?
// exclude a words matched to е, э, г, к, к, қ,
// them should be without hamza
- if ( preg_match('/['.$front.']/u', $m[0]) && !preg_match('/['.$excludes.']/u', $m[0]) ) {
- $ret .= preg_replace('/['.$letters.']+/u', H_HAMZA.'$0', $m[0]);
+ if ( preg_match( '/[' . $front . ']/u', $m[0] ) && !preg_match( '/[' . $excludes . ']/u', $m[0] ) ) {
+ $ret .= preg_replace( '/[' . $letters . ']+/u', H_HAMZA . '$0', $m[0] );
} else {
$ret .= $m[0];
}
- $mstart = $m[1] + strlen($m[0]);
+ $mstart = $m[1] + strlen( $m[0] );
}
$text =& $ret;
- foreach( $this->mCyLa2Arab as $pat => $rep ) {
+ foreach ( $this->mCyLa2Arab as $pat => $rep ) {
$text = preg_replace( $pat, $rep, $text );
}
return $text;
break;
case 'kk-latn':
case 'kk-tr':
- foreach( $this->mCyrl2Latn as $pat => $rep ) {
+ foreach ( $this->mCyrl2Latn as $pat => $rep ) {
$text = preg_replace( $pat, $rep, $text );
}
return $text;
break;
case 'kk-cyrl':
case 'kk-kz':
- foreach( $this->mLatn2Cyrl as $pat => $rep ) {
+ foreach ( $this->mLatn2Cyrl as $pat => $rep ) {
$text = preg_replace( $pat, $rep, $text );
}
return $text;
* We want our external link captions to be converted in variants,
* so we return the original text instead -{$text}-, except for URLs
*/
- function markNoConversion( $text, $noParse=false ) {
- if( $noParse || preg_match( "/^https?:\/\/|ftp:\/\/|irc:\/\//", $text ) )
+ function markNoConversion( $text, $noParse = false ) {
+ if ( $noParse || preg_match( "/^https?:\/\/|ftp:\/\/|irc:\/\//", $text ) )
return parent::markNoConversion( $text );
return $text;
}
*/
function ucfirst ( $string ) {
$variant = $this->getPreferredVariant();
- if ( ($variant == 'kk-latn' || $variant == 'kk-tr') && $string[0] == 'i' ) {
+ if ( ( $variant == 'kk-latn' || $variant == 'kk-tr' ) && $string[0] == 'i' ) {
$string = 'İ' . substr( $string, 1 );
} else {
$string = parent::ucfirst( $string );
*/
function lcfirst ( $string ) {
$variant = $this->getPreferredVariant();
- if ( ($variant == 'kk-latn' || $variant == 'kk-tr') && $string[0] == 'I' ) {
+ if ( ( $variant == 'kk-latn' || $variant == 'kk-tr' ) && $string[0] == 'I' ) {
$string = 'ı' . substr( $string, 1 );
} else {
$string = parent::lcfirst( $string );
$allVowels = array( "е", "ө", "ү", "і", "ә", "э", "а", "о", "ұ", "ы", "я", "ё", "и" );
// Preceding letters
$Nasals = array( "м", "н", "ң" );
- $Sonants = array( "и", "й", "л", "р", "у", "ю");
+ $Sonants = array( "и", "й", "л", "р", "у", "ю" );
$Consonants = array( "п", "ф", "к", "қ", "т", "ш", "с", "х", "ц", "ч", "щ", "б", "в", "г", "д" );
$Sibilants = array( "ж", "з" );
- $Sonorants = array( "и", "й", "л", "р", "у", "ю", "м", "н", "ң", "ж", "з");
+ $Sonorants = array( "и", "й", "л", "р", "у", "ю", "м", "н", "ң", "ж", "з" );
// Possessives
$firstPerson = array( "м", "ң" ); // 1st singular, 2nd unformal
// Now convert the word
switch ( $case ) {
case "dc1":
- case "genitive": #ilik
+ case "genitive": # ilik
if ( in_array( $wordEnding, $Consonants ) ) {
if ( in_array( $wordLastVowel, $frontVowels ) ) {
$word = $word . "тің";
} elseif ( in_array( $wordLastVowel, $backVowels ) ) {
$word = $word . "ның";
}
- } elseif ( in_array( $wordEnding, $Sonants ) || in_array( $wordEnding, $Sibilants )) {
+ } elseif ( in_array( $wordEnding, $Sonants ) || in_array( $wordEnding, $Sibilants ) ) {
if ( in_array( $wordLastVowel, $frontVowels ) ) {
$word = $word . "дің";
} elseif ( in_array( $wordLastVowel, $backVowels ) ) {
}
break;
case "dc2":
- case "dative": #barıs
+ case "dative": # barıs
if ( in_array( $wordEnding, $Consonants ) ) {
if ( in_array( $wordLastVowel, $frontVowels ) ) {
$word = $word . "ке";
}
break;
case "dc21":
- case "possessive dative": #täweldık + barıs
+ case "possessive dative": # täweldık + barıs
if ( in_array( $wordEnding, $firstPerson ) ) {
if ( in_array( $wordLastVowel, $frontVowels ) ) {
$word = $word . "е";
}
break;
case "dc3":
- case "accusative": #tabıs
+ case "accusative": # tabıs
if ( in_array( $wordEnding, $Consonants ) ) {
if ( in_array( $wordLastVowel, $frontVowels ) ) {
$word = $word . "ті";
$word = $word . "ты";
}
} elseif ( in_array( $wordEnding, $allVowels ) ) {
- if ( in_array($wordLastVowel, $frontVowels ) ) {
+ if ( in_array( $wordLastVowel, $frontVowels ) ) {
$word = $word . "ні";
} elseif ( in_array( $wordLastVowel, $backVowels ) ) {
$word = $word . "ны";
}
- } elseif ( in_array( $wordEnding, $Sonorants) ) {
- if ( in_array( $wordLastVowel, $frontVowels) ) {
+ } elseif ( in_array( $wordEnding, $Sonorants ) ) {
+ if ( in_array( $wordLastVowel, $frontVowels ) ) {
$word = $word . "ді";
} elseif ( in_array( $wordLastVowel, $backVowels ) ) {
$word = $word . "ды";
}
break;
case "dc31":
- case "possessive accusative": #täweldık + tabıs
+ case "possessive accusative": # täweldık + tabıs
if ( in_array( $wordEnding, $firstPerson ) || in_array( $wordEnding, $secondPerson ) ) {
if ( in_array( $wordLastVowel, $frontVowels ) ) {
$word = $word . "ді";
}
break;
case "dc4":
- case "locative": #jatıs
+ case "locative": # jatıs
if ( in_array( $wordEnding, $Consonants ) ) {
if ( in_array( $wordLastVowel, $frontVowels ) ) {
$word = $word . "те";
$word = $word . "та";
}
} elseif ( in_array( $wordEnding, $allVowels ) || in_array( $wordEnding, $Sonorants ) ) {
- if ( in_array( $wordLastVowel, $frontVowels) ) {
+ if ( in_array( $wordLastVowel, $frontVowels ) ) {
$word = $word . "де";
} elseif ( in_array( $wordLastVowel, $backVowels ) ) {
$word = $word . "да";
}
break;
case "dc41":
- case "possessive locative": #täweldık + jatıs
+ case "possessive locative": # täweldık + jatıs
if ( in_array( $wordEnding, $firstPerson ) || in_array( $wordEnding, $secondPerson ) ) {
if ( in_array( $wordLastVowel, $frontVowels ) ) {
$word = $word . "де";
$word = $word . "да";
}
} elseif ( in_array( $wordEnding, $thirdPerson ) ) {
- if ( in_array( $wordLastVowel, $frontVowels) ) {
+ if ( in_array( $wordLastVowel, $frontVowels ) ) {
$word = $word . "нде";
} elseif ( in_array( $wordLastVowel, $backVowels ) ) {
$word = $word . "нда";
}
break;
case "dc5":
- case "ablative": #şığıs
+ case "ablative": # şığıs
if ( in_array( $wordEnding, $Consonants ) ) {
if ( in_array( $wordLastVowel, $frontVowels ) ) {
$word = $word . "тен";
} elseif ( in_array( $wordLastVowel, $backVowels ) ) {
$word = $word . "тан";
}
- } elseif ( in_array($wordEnding, $allVowels ) || in_array($wordEnding, $Sonants ) || in_array($wordEnding, $Sibilants ) ) {
+ } elseif ( in_array( $wordEnding, $allVowels ) || in_array( $wordEnding, $Sonants ) || in_array( $wordEnding, $Sibilants ) ) {
if ( in_array( $wordLastVowel, $frontVowels ) ) {
$word = $word . "ден";
} elseif ( in_array( $wordLastVowel, $backVowels ) ) {
$word = $word . "дан";
}
- } elseif ( in_array($wordEnding, $Nasals ) ) {
+ } elseif ( in_array( $wordEnding, $Nasals ) ) {
if ( in_array( $wordLastVowel, $frontVowels ) ) {
$word = $word . "нен";
} elseif ( in_array( $wordLastVowel, $backVowels ) ) {
}
break;
case "dc51":
- case "possessive ablative": #täweldık + şığıs
+ case "possessive ablative": # täweldık + şığıs
if ( in_array( $wordEnding, $firstPerson ) || in_array( $wordEnding, $thirdPerson ) ) {
if ( in_array( $wordLastVowel, $frontVowels ) ) {
$word = $word . "нен";
} elseif ( in_array( $wordLastVowel, $backVowels ) ) {
$word = $word . "нан";
}
- } elseif ( in_array($wordEnding, $secondPerson ) ) {
+ } elseif ( in_array( $wordEnding, $secondPerson ) ) {
if ( in_array( $wordLastVowel, $frontVowels ) ) {
$word = $word . "ден";
} elseif ( in_array( $wordLastVowel, $backVowels ) ) {
}
break;
case "dc6":
- case "comitative": #kömektes
+ case "comitative": # kömektes
if ( in_array( $wordEnding, $Consonants ) ) {
$word = $word . "пен";
} elseif ( in_array( $wordEnding, $allVowels ) || in_array( $wordEnding, $Nasals ) || in_array( $wordEnding, $Sonants ) ) {
}
break;
case "dc61":
- case "possessive comitative": #täweldık + kömektes
+ case "possessive comitative": # täweldık + kömektes
if ( in_array( $wordEnding, $Consonants ) ) {
$word = $word . "пенен";
} elseif ( in_array( $wordEnding, $allVowels ) || in_array( $wordEnding, $Nasals ) || in_array( $wordEnding, $Sonants ) ) {
$word = $word . "бенен";
}
break;
- default: #dc0 #nominative #ataw
+ default: # dc0 #nominative #ataw
}
return $word;
}
$allVowels = array( "e", "ö", "ü", "i", "ä", "é", "a", "o", "u", "ı" );
// Preceding letters
$Nasals = array( "m", "n", "ñ" );
- $Sonants = array( "ï", "y", "ý", "l", "r", "w");
+ $Sonants = array( "ï", "y", "ý", "l", "r", "w" );
$Consonants = array( "p", "f", "k", "q", "t", "ş", "s", "x", "c", "ç", "b", "v", "g", "d" );
$Sibilants = array( "j", "z" );
- $Sonorants = array( "ï", "y", "ý", "l", "r", "w", "m", "n", "ñ", "j", "z");
+ $Sonorants = array( "ï", "y", "ý", "l", "r", "w", "m", "n", "ñ", "j", "z" );
// Possessives
$firstPerson = array( "m", "ñ" ); // 1st singular, 2nd unformal
// Now convert the word
switch ( $case ) {
case "dc1":
- case "genitive": #ilik
+ case "genitive": # ilik
if ( in_array( $wordEnding, $Consonants ) ) {
if ( in_array( $wordLastVowel, $frontVowels ) ) {
$word = $word . "tiñ";
} elseif ( in_array( $wordLastVowel, $backVowels ) ) {
$word = $word . "nıñ";
}
- } elseif ( in_array( $wordEnding, $Sonants ) || in_array( $wordEnding, $Sibilants )) {
+ } elseif ( in_array( $wordEnding, $Sonants ) || in_array( $wordEnding, $Sibilants ) ) {
if ( in_array( $wordLastVowel, $frontVowels ) ) {
$word = $word . "diñ";
} elseif ( in_array( $wordLastVowel, $backVowels ) ) {
}
break;
case "dc2":
- case "dative": #barıs
+ case "dative": # barıs
if ( in_array( $wordEnding, $Consonants ) ) {
if ( in_array( $wordLastVowel, $frontVowels ) ) {
$word = $word . "ke";
}
break;
case "dc21":
- case "possessive dative": #täweldık + barıs
+ case "possessive dative": # täweldık + barıs
if ( in_array( $wordEnding, $firstPerson ) ) {
if ( in_array( $wordLastVowel, $frontVowels ) ) {
$word = $word . "e";
}
break;
case "dc3":
- case "accusative": #tabıs
+ case "accusative": # tabıs
if ( in_array( $wordEnding, $Consonants ) ) {
if ( in_array( $wordLastVowel, $frontVowels ) ) {
$word = $word . "ti";
$word = $word . "tı";
}
} elseif ( in_array( $wordEnding, $allVowels ) ) {
- if ( in_array($wordLastVowel, $frontVowels ) ) {
+ if ( in_array( $wordLastVowel, $frontVowels ) ) {
$word = $word . "ni";
} elseif ( in_array( $wordLastVowel, $backVowels ) ) {
$word = $word . "nı";
}
- } elseif ( in_array( $wordEnding, $Sonorants) ) {
- if ( in_array( $wordLastVowel, $frontVowels) ) {
+ } elseif ( in_array( $wordEnding, $Sonorants ) ) {
+ if ( in_array( $wordLastVowel, $frontVowels ) ) {
$word = $word . "di";
} elseif ( in_array( $wordLastVowel, $backVowels ) ) {
$word = $word . "dı";
}
break;
case "dc31":
- case "possessive accusative": #täweldık + tabıs
+ case "possessive accusative": # täweldık + tabıs
if ( in_array( $wordEnding, $firstPerson ) || in_array( $wordEnding, $secondPerson ) ) {
if ( in_array( $wordLastVowel, $frontVowels ) ) {
$word = $word . "di";
}
break;
case "dc4":
- case "locative": #jatıs
+ case "locative": # jatıs
if ( in_array( $wordEnding, $Consonants ) ) {
if ( in_array( $wordLastVowel, $frontVowels ) ) {
$word = $word . "te";
$word = $word . "ta";
}
} elseif ( in_array( $wordEnding, $allVowels ) || in_array( $wordEnding, $Sonorants ) ) {
- if ( in_array( $wordLastVowel, $frontVowels) ) {
+ if ( in_array( $wordLastVowel, $frontVowels ) ) {
$word = $word . "de";
} elseif ( in_array( $wordLastVowel, $backVowels ) ) {
$word = $word . "da";
}
break;
case "dc41":
- case "possessive locative": #täweldık + jatıs
+ case "possessive locative": # täweldık + jatıs
if ( in_array( $wordEnding, $firstPerson ) || in_array( $wordEnding, $secondPerson ) ) {
if ( in_array( $wordLastVowel, $frontVowels ) ) {
$word = $word . "de";
$word = $word . "da";
}
} elseif ( in_array( $wordEnding, $thirdPerson ) ) {
- if ( in_array( $wordLastVowel, $frontVowels) ) {
+ if ( in_array( $wordLastVowel, $frontVowels ) ) {
$word = $word . "nde";
} elseif ( in_array( $wordLastVowel, $backVowels ) ) {
$word = $word . "nda";
}
break;
case "dc5":
- case "ablative": #şığıs
+ case "ablative": # şığıs
if ( in_array( $wordEnding, $Consonants ) ) {
if ( in_array( $wordLastVowel, $frontVowels ) ) {
$word = $word . "ten";
} elseif ( in_array( $wordLastVowel, $backVowels ) ) {
$word = $word . "tan";
}
- } elseif ( in_array($wordEnding, $allVowels ) || in_array($wordEnding, $Sonants ) || in_array($wordEnding, $Sibilants ) ) {
+ } elseif ( in_array( $wordEnding, $allVowels ) || in_array( $wordEnding, $Sonants ) || in_array( $wordEnding, $Sibilants ) ) {
if ( in_array( $wordLastVowel, $frontVowels ) ) {
$word = $word . "den";
} elseif ( in_array( $wordLastVowel, $backVowels ) ) {
$word = $word . "dan";
}
- } elseif ( in_array($wordEnding, $Nasals ) ) {
+ } elseif ( in_array( $wordEnding, $Nasals ) ) {
if ( in_array( $wordLastVowel, $frontVowels ) ) {
$word = $word . "nen";
} elseif ( in_array( $wordLastVowel, $backVowels ) ) {
}
break;
case "dc51":
- case "possessive ablative": #täweldık + şığıs
+ case "possessive ablative": # täweldık + şığıs
if ( in_array( $wordEnding, $firstPerson ) || in_array( $wordEnding, $thirdPerson ) ) {
if ( in_array( $wordLastVowel, $frontVowels ) ) {
$word = $word . "nen";
} elseif ( in_array( $wordLastVowel, $backVowels ) ) {
$word = $word . "nan";
}
- } elseif ( in_array($wordEnding, $secondPerson ) ) {
+ } elseif ( in_array( $wordEnding, $secondPerson ) ) {
if ( in_array( $wordLastVowel, $frontVowels ) ) {
$word = $word . "den";
} elseif ( in_array( $wordLastVowel, $backVowels ) ) {
}
break;
case "dc6":
- case "comitative": #kömektes
+ case "comitative": # kömektes
if ( in_array( $wordEnding, $Consonants ) ) {
$word = $word . "pen";
} elseif ( in_array( $wordEnding, $allVowels ) || in_array( $wordEnding, $Nasals ) || in_array( $wordEnding, $Sonants ) ) {
}
break;
case "dc61":
- case "possessive comitative": #täweldık + kömektes
+ case "possessive comitative": # täweldık + kömektes
if ( in_array( $wordEnding, $Consonants ) ) {
$word = $word . "penen";
} elseif ( in_array( $wordEnding, $allVowels ) || in_array( $wordEnding, $Nasals ) || in_array( $wordEnding, $Sonants ) ) {
$word = $word . "benen";
}
break;
- default: #dc0 #nominative #ataw
+ default: # dc0 #nominative #ataw
}
return $word;
}
$allVowels = array( "ە", "ٶ", "ٷ", "ٸ", "ٵ", "ە", "ا", "و", "ۇ", "ى" );
// Preceding letters
$Nasals = array( "م", "ن", "ڭ" );
- $Sonants = array( "ي", "ي", "ل", "ر", "ۋ");
+ $Sonants = array( "ي", "ي", "ل", "ر", "ۋ" );
$Consonants = array( "پ", "ف", "ك", "ق", "ت", "ش", "س", "ح", "تس", "چ", "ب", "ۆ", "گ", "د" );
$Sibilants = array( "ج", "ز" );
- $Sonorants = array( "ي", "ي", "ل", "ر", "ۋ", "م", "ن", "ڭ", "ج", "ز");
+ $Sonorants = array( "ي", "ي", "ل", "ر", "ۋ", "م", "ن", "ڭ", "ج", "ز" );
// Possessives
$firstPerson = array( "م", "ڭ" ); // 1st singular, 2nd unformal
// Now convert the word
switch ( $case ) {
case "dc1":
- case "genitive": #ilik
+ case "genitive": # ilik
if ( in_array( $wordEnding, $Consonants ) ) {
if ( in_array( $wordLastVowel, $frontVowels ) ) {
$word = $word . "تٸڭ";
} elseif ( in_array( $wordLastVowel, $backVowels ) ) {
$word = $word . "نىڭ";
}
- } elseif ( in_array( $wordEnding, $Sonants ) || in_array( $wordEnding, $Sibilants )) {
+ } elseif ( in_array( $wordEnding, $Sonants ) || in_array( $wordEnding, $Sibilants ) ) {
if ( in_array( $wordLastVowel, $frontVowels ) ) {
$word = $word . "دٸڭ";
} elseif ( in_array( $wordLastVowel, $backVowels ) ) {
}
break;
case "dc2":
- case "dative": #barıs
+ case "dative": # barıs
if ( in_array( $wordEnding, $Consonants ) ) {
if ( in_array( $wordLastVowel, $frontVowels ) ) {
$word = $word . "كە";
}
break;
case "dc21":
- case "possessive dative": #täweldık + barıs
+ case "possessive dative": # täweldık + barıs
if ( in_array( $wordEnding, $firstPerson ) ) {
if ( in_array( $wordLastVowel, $frontVowels ) ) {
$word = $word . "ە";
}
break;
case "dc3":
- case "accusative": #tabıs
+ case "accusative": # tabıs
if ( in_array( $wordEnding, $Consonants ) ) {
if ( in_array( $wordLastVowel, $frontVowels ) ) {
$word = $word . "تٸ";
$word = $word . "تى";
}
} elseif ( in_array( $wordEnding, $allVowels ) ) {
- if ( in_array($wordLastVowel, $frontVowels ) ) {
+ if ( in_array( $wordLastVowel, $frontVowels ) ) {
$word = $word . "نٸ";
} elseif ( in_array( $wordLastVowel, $backVowels ) ) {
$word = $word . "نى";
}
- } elseif ( in_array( $wordEnding, $Sonorants) ) {
- if ( in_array( $wordLastVowel, $frontVowels) ) {
+ } elseif ( in_array( $wordEnding, $Sonorants ) ) {
+ if ( in_array( $wordLastVowel, $frontVowels ) ) {
$word = $word . "دٸ";
} elseif ( in_array( $wordLastVowel, $backVowels ) ) {
$word = $word . "دى";
}
break;
case "dc31":
- case "possessive accusative": #täweldık + tabıs
+ case "possessive accusative": # täweldık + tabıs
if ( in_array( $wordEnding, $firstPerson ) || in_array( $wordEnding, $secondPerson ) ) {
if ( in_array( $wordLastVowel, $frontVowels ) ) {
$word = $word . "دٸ";
}
break;
case "dc4":
- case "locative": #jatıs
+ case "locative": # jatıs
if ( in_array( $wordEnding, $Consonants ) ) {
if ( in_array( $wordLastVowel, $frontVowels ) ) {
$word = $word . "تە";
$word = $word . "تا";
}
} elseif ( in_array( $wordEnding, $allVowels ) || in_array( $wordEnding, $Sonorants ) ) {
- if ( in_array( $wordLastVowel, $frontVowels) ) {
+ if ( in_array( $wordLastVowel, $frontVowels ) ) {
$word = $word . "دە";
} elseif ( in_array( $wordLastVowel, $backVowels ) ) {
$word = $word . "دا";
}
break;
case "dc41":
- case "possessive locative": #täweldık + jatıs
+ case "possessive locative": # täweldık + jatıs
if ( in_array( $wordEnding, $firstPerson ) || in_array( $wordEnding, $secondPerson ) ) {
if ( in_array( $wordLastVowel, $frontVowels ) ) {
$word = $word . "دە";
$word = $word . "دا";
}
} elseif ( in_array( $wordEnding, $thirdPerson ) ) {
- if ( in_array( $wordLastVowel, $frontVowels) ) {
+ if ( in_array( $wordLastVowel, $frontVowels ) ) {
$word = $word . "ندە";
} elseif ( in_array( $wordLastVowel, $backVowels ) ) {
$word = $word . "ندا";
}
break;
case "dc5":
- case "ablative": #şığıs
+ case "ablative": # şığıs
if ( in_array( $wordEnding, $Consonants ) ) {
if ( in_array( $wordLastVowel, $frontVowels ) ) {
$word = $word . "تەن";
} elseif ( in_array( $wordLastVowel, $backVowels ) ) {
$word = $word . "تان";
}
- } elseif ( in_array($wordEnding, $allVowels ) || in_array($wordEnding, $Sonants ) || in_array($wordEnding, $Sibilants ) ) {
+ } elseif ( in_array( $wordEnding, $allVowels ) || in_array( $wordEnding, $Sonants ) || in_array( $wordEnding, $Sibilants ) ) {
if ( in_array( $wordLastVowel, $frontVowels ) ) {
$word = $word . "دەن";
} elseif ( in_array( $wordLastVowel, $backVowels ) ) {
$word = $word . "دان";
}
- } elseif ( in_array($wordEnding, $Nasals ) ) {
+ } elseif ( in_array( $wordEnding, $Nasals ) ) {
if ( in_array( $wordLastVowel, $frontVowels ) ) {
$word = $word . "نەن";
} elseif ( in_array( $wordLastVowel, $backVowels ) ) {
}
break;
case "dc51":
- case "possessive ablative": #täweldık + şığıs
+ case "possessive ablative": # täweldık + şığıs
if ( in_array( $wordEnding, $firstPerson ) || in_array( $wordEnding, $thirdPerson ) ) {
if ( in_array( $wordLastVowel, $frontVowels ) ) {
$word = $word . "نەن";
} elseif ( in_array( $wordLastVowel, $backVowels ) ) {
$word = $word . "نان";
}
- } elseif ( in_array($wordEnding, $secondPerson ) ) {
+ } elseif ( in_array( $wordEnding, $secondPerson ) ) {
if ( in_array( $wordLastVowel, $frontVowels ) ) {
$word = $word . "دەن";
} elseif ( in_array( $wordLastVowel, $backVowels ) ) {
}
break;
case "dc6":
- case "comitative": #kömektes
+ case "comitative": # kömektes
if ( in_array( $wordEnding, $Consonants ) ) {
$word = $word . "پەن";
} elseif ( in_array( $wordEnding, $allVowels ) || in_array( $wordEnding, $Nasals ) || in_array( $wordEnding, $Sonants ) ) {
}
break;
case "dc61":
- case "possessive comitative": #täweldık + kömektes
+ case "possessive comitative": # täweldık + kömektes
if ( in_array( $wordEnding, $Consonants ) ) {
$word = $word . "پەنەن";
} elseif ( in_array( $wordEnding, $allVowels ) || in_array( $wordEnding, $Nasals ) || in_array( $wordEnding, $Sonants ) ) {
$word = $word . "بەنەن";
}
break;
- default: #dc0 #nominative #ataw
+ default: # dc0 #nominative #ataw
}
return $word;
}
$ar = array();
// Put the word in a form we can play with since we're using UTF-8
- $ar = preg_split('//u', parent::lc($word), -1, PREG_SPLIT_NO_EMPTY);
+ $ar = preg_split( '//u', parent::lc( $word ), -1, PREG_SPLIT_NO_EMPTY );
// Here's an array with the order of the letters in the word reversed
// so we can find a match quicker *shrug*
*/
function commafy( $_ ) {
if ( !preg_match( '/^\d{1,4}$/', $_ ) ) {
- return strrev( (string)preg_replace( '/(\d{3})(?=\d)(?!\d*\.)/', '$1,', strrev($_) ) );
+ return strrev( (string)preg_replace( '/(\d{3})(?=\d)(?!\d*\.)/', '$1,', strrev( $_ ) ) );
} else {
return $_;
}
* @author Niklas Laxström
*/
class LanguageKm extends Language {
- function commafy($_) {
+ function commafy( $_ ) {
/* NO-op for Khmer. Cannot use
* $separatorTransformTable = array( ',' => '' )
* That would break when parsing and doing strstr '' => 'foo';
* Handle cases of (1, other, 0) or (1, other)
*/
function convertPlural( $count, $forms ) {
- if ( !count($forms) ) { return ''; }
+ if ( !count( $forms ) ) { return ''; }
$forms = $this->preConvertPlural( $forms, 3 );
if ( $count == 1 ) {
// changed on a subsequent page view.
// see http://lists.wikimedia.org/pipermail/wikitech-l/2006-January/021311.html
-require_once( dirname(__FILE__).'/../LanguageConverter.php' );
-require_once( dirname(__FILE__).'/LanguageKu_ku.php' );
+require_once( dirname( __FILE__ ) . '/../LanguageConverter.php' );
+require_once( dirname( __FILE__ ) . '/LanguageKu_ku.php' );
<?php
-require_once( dirname(__FILE__).'/../LanguageConverter.php' );
-require_once( dirname(__FILE__).'/LanguageKu_ku.php' );
+require_once( dirname( __FILE__ ) . '/../LanguageConverter.php' );
+require_once( dirname( __FILE__ ) . '/LanguageKu_ku.php' );
/** Kurdish
* converter routines
// و ك=> ku -- ist auch richtig
/* Doppel- und Halbvokale */
- 'ڵ' => 'll', #ll
- 'ڕ' => 'rr', #rr
+ 'ڵ' => 'll', # ll
+ 'ڕ' => 'rr', # rr
'ا' => 'a',
# 'ئێ' => 'ê', # initial e
'ە' => 'e',
# 'rr' => 'ڕ', # selbiges für doppel-r
/* Einzelne Großbuchstaben */
- //' C' => 'ج',
+ // ' C' => 'ج',
/* Vowels */
'a' => 'ا',
*/
function findVariantLink( &$link, &$nt, $ignoreOtherCond = false ) {
// check for user namespace
- if(is_object($nt)){
+ if ( is_object( $nt ) ) {
$ns = $nt->getNamespace();
- if($ns==NS_USER || $ns==NS_USER_TALK)
+ if ( $ns == NS_USER || $ns == NS_USER_TALK )
return;
}
- $oldlink=$link;
+ $oldlink = $link;
parent::findVariantLink( $link, $nt, $ignoreOtherCond );
- if( $this->getPreferredVariant() == $this->mMainLanguageCode )
- $link=$oldlink;
+ if ( $this->getPreferredVariant() == $this->mMainLanguageCode )
+ $link = $oldlink;
}
/*
* We want our external link captions to be converted in variants,
* so we return the original text instead -{$text}-, except for URLs
*/
- function markNoConversion($text, $noParse=false) {
- if($noParse || preg_match("/^https?:\/\/|ftp:\/\/|irc:\/\//",$text))
- return parent::markNoConversion($text);
+ function markNoConversion( $text, $noParse = false ) {
+ if ( $noParse || preg_match( "/^https?:\/\/|ftp:\/\/|irc:\/\//", $text ) )
+ return parent::markNoConversion( $text );
return $text;
}
* An ugly function wrapper for parsing Image titles
* (to prevent image name conversion)
*/
- function autoConvert($text, $toVariant=false) {
+ function autoConvert( $text, $toVariant = false ) {
global $wgTitle;
- if(is_object($wgTitle) && $wgTitle->getNameSpace()==NS_FILE){
+ if ( is_object( $wgTitle ) && $wgTitle->getNameSpace() == NS_FILE ) {
$imagename = $wgTitle->getNsText();
- if(preg_match("/^$imagename:/",$text)) return $text;
+ if ( preg_match( "/^$imagename:/", $text ) ) return $text;
}
- return parent::autoConvert($text,$toVariant);
+ return parent::autoConvert( $text, $toVariant );
}
/**
* It translates text into variant, specials:
* - ommiting roman numbers
*/
- function translate($text, $toVariant){
+ function translate( $text, $toVariant ) {
$breaks = '[^\w\x80-\xff]';
/* From Kazakh interface, maybe we need it later
return $ret;
*/
- if( !isset( $this->mTables[$toVariant] ) ) {
+ if ( !isset( $this->mTables[$toVariant] ) ) {
throw new MWException( "Broken variant table: " . implode( ',', array_keys( $this->mTables ) ) );
}
function commafy( $_ ) {
if ( !preg_match( '/^\d{1,4}$/', $_ ) ) {
- return strrev( (string)preg_replace( '/(\d{3})(?=\d)(?!\d*\.)/', '$1,', strrev($_) ) );
+ return strrev( (string)preg_replace( '/(\d{3})(?=\d)(?!\d*\.)/', '$1,', strrev( $_ ) ) );
} else {
return $_;
}
*/
function convertGrammar( $word, $case ) {
global $wgGrammarForms;
- if ( isset($wgGrammarForms['la'][$case][$word]) ) {
+ if ( isset( $wgGrammarForms['la'][$case][$word] ) ) {
return $wgGrammarForms['la'][$case][$word];
}
*/
function convertPlural( $count, $forms ) {
- if ( !count($forms) ) { return ''; }
+ if ( !count( $forms ) ) { return ''; }
$forms = $this->preConvertPlural( $forms, 2 );
- return ($count <= 1) ? $forms[0] : $forms[1];
+ return ( $count <= 1 ) ? $forms[0] : $forms[1];
}
}
3 - penkiolika (15) lapų
*/
function convertPlural( $count, $forms ) {
- if ( !count($forms) ) { return ''; }
+ if ( !count( $forms ) ) { return ''; }
- //if no number with word, then use $form[0] for singular and $form[1] for plural or zero
- if( count($forms) === 2 ) return $count == 1 ? $forms[0] : $forms[1];
+ // if no number with word, then use $form[0] for singular and $form[1] for plural or zero
+ if ( count( $forms ) === 2 ) return $count == 1 ? $forms[0] : $forms[1];
$forms = $this->preConvertPlural( $forms, 3 );
- if ($count%10==1 && $count%100!=11) return $forms[0];
- if ($count%10>=2 && ($count%100<10 || $count%100>=20)) return $forms[1];
+ if ( $count % 10 == 1 && $count % 100 != 11 ) return $forms[0];
+ if ( $count % 10 >= 2 && ( $count % 100 < 10 || $count % 100 >= 20 ) ) return $forms[1];
return $forms[2];
}
}
* @return String
*/
function convertPlural( $count, $forms ) {
- if ( !count($forms) ) { return ''; }
+ if ( !count( $forms ) ) { return ''; }
// FIXME: CLDR defines 3 plural forms instead of 2. Form for 0 is missing.
// http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/language_plural_rules.html#lv
* Use singular form for zero
*/
function convertPlural( $count, $forms ) {
- if ( !count($forms) ) { return ''; }
+ if ( !count( $forms ) ) { return ''; }
$forms = $this->preConvertPlural( $forms, 2 );
- return ($count <= 1) ? $forms[0] : $forms[1];
+ return ( $count <= 1 ) ? $forms[0] : $forms[1];
}
}
* http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/language_plural_rules.html#mk
*/
function convertPlural( $count, $forms ) {
- if ( !count($forms) ) { return ''; }
+ if ( !count( $forms ) ) { return ''; }
$forms = $this->preConvertPlural( $forms, 2 );
if ( $count % 10 === 1 && $count % 100 !== 11 ) {
class LanguageMl extends Language {
/**
- * Temporary hack for the issue described at
+ * Temporary hack for the issue described at
* http://permalink.gmane.org/gmane.science.linguistics.wikipedia.technical/46396
- * Convert Unicode 5.0 style Malayalam input to Unicode 5.1. Similar to
- * bug 9413. Also fixes miscellaneous problems due to mishandling of ZWJ,
+ * Convert Unicode 5.0 style Malayalam input to Unicode 5.1. Similar to
+ * bug 9413. Also fixes miscellaneous problems due to mishandling of ZWJ,
* e.g. bug 11162.
- *
- * FIXME: This is language-specific for now only to avoid the negative
+ *
+ * FIXME: This is language-specific for now only to avoid the negative
* performance impact of enabling it for all languages.
*/
function normalize( $s ) {
function convertPlural( $count, $forms ) {
// Plural rules per
// http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/language_plural_rules.html#mo
- if ( !count($forms) ) { return ''; }
+ if ( !count( $forms ) ) { return ''; }
$forms = $this->preConvertPlural( $forms, 3 );
class LanguageMt extends Language {
function convertPlural( $count, $forms ) {
- if ( !count($forms) ) { return ''; }
+ if ( !count( $forms ) ) { return ''; }
$forms = $this->preConvertPlural( $forms, 4 );
if ( $count === 1 ) $index = 0;
- elseif ( $count === 0 || ( $count%100>1 && $count%100<11) ) $index = 1;
- elseif ( $count%100>10 && $count%100<20 ) $index = 2;
+ elseif ( $count === 0 || ( $count % 100 > 1 && $count % 100 < 11 ) ) $index = 1;
+ elseif ( $count % 100 > 10 && $count % 100 < 20 ) $index = 2;
else $index = 3;
return $forms[$index];
}
*/
class LanguageMy extends Language {
- function commafy($_) {
+ function commafy( $_ ) {
/* NO-op. Cannot use
* $separatorTransformTable = array( ',' => '' )
* That would break when parsing and doing strstr '' => 'foo';
* Use singular form for zero
*/
function convertPlural( $count, $forms ) {
- if ( !count($forms) ) { return ''; }
+ if ( !count( $forms ) ) { return ''; }
$forms = $this->preConvertPlural( $forms, 2 );
- return ($count <= 1) ? $forms[0] : $forms[1];
+ return ( $count <= 1 ) ? $forms[0] : $forms[1];
}
}
*/
class LanguagePl extends Language {
function convertPlural( $count, $forms ) {
- if ( !count($forms) ) { return ''; }
+ if ( !count( $forms ) ) { return ''; }
$forms = $this->preConvertPlural( $forms, 3 );
$count = abs( $count );
if ( $count == 1 )
}
}
- function commafy($_) {
- if (!preg_match('/^\d{1,4}(.\d+)?$/',$_)) {
- return strrev((string)preg_replace('/(\d{3})(?=\d)(?!\d*\.)/','$1,',strrev($_)));
+ function commafy( $_ ) {
+ if ( !preg_match( '/^\d{1,4}(.\d+)?$/', $_ ) ) {
+ return strrev( (string)preg_replace( '/(\d{3})(?=\d)(?!\d*\.)/', '$1,', strrev( $_ ) ) );
} else {
return $_;
}
function convertPlural( $count, $forms ) {
// Plural rules per
// http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/language_plural_rules.html#ro
- if ( !count($forms) ) { return ''; }
+ if ( !count( $forms ) ) { return ''; }
$forms = $this->preConvertPlural( $forms, 3 );
# Invoked with {{grammar:case|word}}
function convertGrammar( $word, $case ) {
global $wgGrammarForms;
- if ( isset($wgGrammarForms['ru'][$case][$word]) ) {
+ if ( isset( $wgGrammarForms['ru'][$case][$word] ) ) {
return $wgGrammarForms['ru'][$case][$word];
}
# These rules are not perfect, but they are currently only used for site names so it doesn't
# matter if they are wrong sometimes. Just add a special case for your site name if necessary.
- #join and array_slice instead mb_substr
+ # join and array_slice instead mb_substr
$ar = array();
preg_match_all( '/./us', $word, $ar );
- if (!preg_match("/[a-zA-Z_]/us", $word))
+ if ( !preg_match( "/[a-zA-Z_]/us", $word ) )
switch ( $case ) {
- case 'genitive': #родительный падеж
- if ((join('',array_slice($ar[0],-4))=='вики') || (join('',array_slice($ar[0],-4))=='Вики'))
- {}
- elseif (join('',array_slice($ar[0],-1))=='ь')
- $word = join('',array_slice($ar[0],0,-1)).'я';
- elseif (join('',array_slice($ar[0],-2))=='ия')
- $word=join('',array_slice($ar[0],0,-2)).'ии';
- elseif (join('',array_slice($ar[0],-2))=='ка')
- $word=join('',array_slice($ar[0],0,-2)).'ки';
- elseif (join('',array_slice($ar[0],-2))=='ти')
- $word=join('',array_slice($ar[0],0,-2)).'тей';
- elseif (join('',array_slice($ar[0],-2))=='ды')
- $word=join('',array_slice($ar[0],0,-2)).'дов';
- elseif (join('',array_slice($ar[0],-3))=='ник')
- $word=join('',array_slice($ar[0],0,-3)).'ника';
+ case 'genitive': # родительный падеж
+ if ( ( join( '', array_slice( $ar[0], -4 ) ) == 'вики' ) || ( join( '', array_slice( $ar[0], -4 ) ) == 'Вики' ) )
+ { }
+ elseif ( join( '', array_slice( $ar[0], -1 ) ) == 'ь' )
+ $word = join( '', array_slice( $ar[0], 0, -1 ) ) . 'я';
+ elseif ( join( '', array_slice( $ar[0], -2 ) ) == 'ия' )
+ $word = join( '', array_slice( $ar[0], 0, -2 ) ) . 'ии';
+ elseif ( join( '', array_slice( $ar[0], -2 ) ) == 'ка' )
+ $word = join( '', array_slice( $ar[0], 0, -2 ) ) . 'ки';
+ elseif ( join( '', array_slice( $ar[0], -2 ) ) == 'ти' )
+ $word = join( '', array_slice( $ar[0], 0, -2 ) ) . 'тей';
+ elseif ( join( '', array_slice( $ar[0], -2 ) ) == 'ды' )
+ $word = join( '', array_slice( $ar[0], 0, -2 ) ) . 'дов';
+ elseif ( join( '', array_slice( $ar[0], -3 ) ) == 'ник' )
+ $word = join( '', array_slice( $ar[0], 0, -3 ) ) . 'ника';
break;
- case 'dative': #дательный падеж
- #stub
+ case 'dative': # дательный падеж
+ # stub
break;
- case 'accusative': #винительный падеж
- #stub
+ case 'accusative': # винительный падеж
+ # stub
break;
- case 'instrumental': #творительный падеж
- #stub
+ case 'instrumental': # творительный падеж
+ # stub
break;
- case 'prepositional': #предложный падеж
- #stub
+ case 'prepositional': # предложный падеж
+ # stub
break;
}
return $word;
*/
function convertPlural( $count, $forms ) {
- if ( !count($forms) ) { return ''; }
+ if ( !count( $forms ) ) { return ''; }
- //if no number with word, then use $form[0] for singular and $form[1] for plural or zero
- if( count($forms) === 2 ) return $count == 1 ? $forms[0] : $forms[1];
+ // if no number with word, then use $form[0] for singular and $form[1] for plural or zero
+ if ( count( $forms ) === 2 ) return $count == 1 ? $forms[0] : $forms[1];
// FIXME: CLDR defines 4 plural forms. Form with decimals missing.
// See http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/language_plural_rules.html#ru
$forms = $this->preConvertPlural( $forms, 3 );
- if ($count > 10 && floor(($count % 100) / 10) == 1) {
+ if ( $count > 10 && floor( ( $count % 100 ) / 10 ) == 1 ) {
return $forms[2];
} else {
- switch ($count % 10) {
+ switch ( $count % 10 ) {
case 1: return $forms[0];
case 2:
case 3:
* See manual of style at http://ru.wikipedia.org/wiki/Википедия:Оформление_статей
* So "1 234 567", "12 345" but "1234"
*/
- function commafy($_) {
- if (preg_match('/^-?\d{1,4}(\.\d*)?$/',$_)) {
+ function commafy( $_ ) {
+ if ( preg_match( '/^-?\d{1,4}(\.\d*)?$/', $_ ) ) {
return $_;
} else {
- return strrev((string)preg_replace('/(\d{3})(?=\d)(?!\d*\.)/','$1,',strrev($_)));
+ return strrev( (string)preg_replace( '/(\d{3})(?=\d)(?!\d*\.)/', '$1,', strrev( $_ ) ) );
}
}
}
*/
class LanguageSe extends Language {
function convertPlural( $count, $forms ) {
- if ( !count($forms) ) { return ''; }
+ if ( !count( $forms ) ) { return ''; }
// plural forms per http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/language_plural_rules.html#se
$forms = $this->preConvertPlural( $forms, 3 );
if ( $count == 1 ) {
$index = 0;
- } elseif( $count == 2 ) {
+ } elseif ( $count == 2 ) {
$index = 1;
} else {
$index = 2;
*/
class LanguageSh extends Language {
function convertPlural( $count, $forms ) {
- if ( !count($forms) ) { return ''; }
+ if ( !count( $forms ) ) { return ''; }
- //if no number with word, then use $form[0] for singular and $form[1] for plural or zero
- if( count($forms) === 2 ) return $count == 1 ? $forms[0] : $forms[1];
+ // if no number with word, then use $form[0] for singular and $form[1] for plural or zero
+ if ( count( $forms ) === 2 ) return $count == 1 ? $forms[0] : $forms[1];
// FIXME: CLDR defines 4 plural forms. Form with decimals missing.
// See http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/language_plural_rules.html#sh
$forms = $this->preConvertPlural( $forms, 3 );
- if ($count > 10 && floor(($count % 100) / 10) == 1) {
+ if ( $count > 10 && floor( ( $count % 100 ) / 10 ) == 1 ) {
return $forms[2];
} else {
- switch ($count % 10) {
+ switch ( $count % 10 ) {
case 1: return $forms[0];
case 2:
case 3:
*/
class LanguageSk extends Language {
function convertPlural( $count, $forms ) {
- if ( !count($forms) ) { return ''; }
+ if ( !count( $forms ) ) { return ''; }
$forms = $this->preConvertPlural( $forms, 3 );
if ( $count == 1 ) {
*/
function convertGrammar( $word, $case ) {
global $wgGrammarForms;
- if ( isset($wgGrammarForms['sl'][$case][$word]) ) {
+ if ( isset( $wgGrammarForms['sl'][$case][$word] ) ) {
return $wgGrammarForms['sl'][$case][$word];
}
}
function convertPlural( $count, $forms ) {
- if ( !count($forms) ) { return ''; }
+ if ( !count( $forms ) ) { return ''; }
$forms = $this->preConvertPlural( $forms, 5 );
if ( $count % 100 == 1 ) {
*/
class LanguageSma extends Language {
function convertPlural( $count, $forms ) {
- if ( !count($forms) ) { return ''; }
+ if ( !count( $forms ) ) { return ''; }
// plural forms per http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/language_plural_rules.html#sma
$forms = $this->preConvertPlural( $forms, 3 );
if ( $count == 1 ) {
$index = 1;
- } elseif( $count == 2 ) {
+ } elseif ( $count == 2 ) {
$index = 2;
} else {
$index = 3;
// changed on a subsequent page view.
// see http://lists.wikimedia.org/pipermail/wikitech-l/2006-January/021311.html
-require_once( dirname(__FILE__).'/LanguageSr_ec.php' );
-require_once( dirname(__FILE__).'/../LanguageConverter.php' );
+require_once( dirname( __FILE__ ) . '/LanguageSr_ec.php' );
+require_once( dirname( __FILE__ ) . '/../LanguageConverter.php' );
<?php
-require_once( dirname(__FILE__).'/../LanguageConverter.php' );
-require_once( dirname(__FILE__).'/LanguageSr_ec.php' );
-require_once( dirname(__FILE__).'/LanguageSr_el.php' );
+require_once( dirname( __FILE__ ) . '/../LanguageConverter.php' );
+require_once( dirname( __FILE__ ) . '/LanguageSr_ec.php' );
+require_once( dirname( __FILE__ ) . '/LanguageSr_el.php' );
/**
* There are two levels of conversion for Serbian: the script level
'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'=> 'НЈ'
+ 'DŽ' => 'Џ', 'd!ž' => 'дж', 'D!ž' => 'Дж', 'D!Ž' => 'ДЖ',
+ 'Lj' => 'Љ', 'l!j' => 'лј', 'L!j' => 'Лј', 'L!J' => 'ЛЈ',
+ 'Nj' => 'Њ', 'n!j' => 'нј', 'N!j' => 'Нј', 'N!J' => 'НЈ'
);
function loadDefaultTables() {
$this->mTables = array(
'sr-ec' => new ReplacementArray( $this->mToCyrillics ),
- 'sr-el' => new ReplacementArray( $this->mToLatin),
+ 'sr-el' => new ReplacementArray( $this->mToLatin ),
'sr' => new ReplacementArray()
);
}
update: delete all rule parsing because it's not used
currently, and just produces a couple of bugs
*/
- function parseManualRule($rule, $flags=array()) {
- if(in_array('T',$flags)){
- return parent::parseManualRule($rule, $flags);
+ function parseManualRule( $rule, $flags = array() ) {
+ if ( in_array( 'T', $flags ) ) {
+ return parent::parseManualRule( $rule, $flags );
}
// otherwise ignore all formatting
- foreach($this->mVariants as $v) {
+ foreach ( $this->mVariants as $v ) {
$carray[$v] = $rule;
}
*/
function findVariantLink( &$link, &$nt, $ignoreOtherCond = false ) {
// check for user namespace
- if(is_object($nt)){
+ if ( is_object( $nt ) ) {
$ns = $nt->getNamespace();
- if($ns==NS_USER || $ns==NS_USER_TALK)
+ if ( $ns == NS_USER || $ns == NS_USER_TALK )
return;
}
- $oldlink=$link;
+ $oldlink = $link;
parent::findVariantLink( $link, $nt, $ignoreOtherCond );
- if($this->getPreferredVariant()==$this->mMainLanguageCode)
- $link=$oldlink;
+ if ( $this->getPreferredVariant() == $this->mMainLanguageCode )
+ $link = $oldlink;
}
/*
* We want our external link captions to be converted in variants,
* so we return the original text instead -{$text}-, except for URLs
*/
- function markNoConversion($text, $noParse=false) {
- if($noParse || preg_match("/^https?:\/\/|ftp:\/\/|irc:\/\//",$text))
- return parent::markNoConversion($text);
+ function markNoConversion( $text, $noParse = false ) {
+ if ( $noParse || preg_match( "/^https?:\/\/|ftp:\/\/|irc:\/\//", $text ) )
+ return parent::markNoConversion( $text );
return $text;
}
* An ugly function wrapper for parsing Image titles
* (to prevent image name conversion)
*/
- function autoConvert($text, $toVariant=false) {
+ function autoConvert( $text, $toVariant = false ) {
global $wgTitle;
- if(is_object($wgTitle) && $wgTitle->getNameSpace()==NS_FILE){
+ if ( is_object( $wgTitle ) && $wgTitle->getNameSpace() == NS_FILE ) {
$imagename = $wgTitle->getNsText();
- if(preg_match("/^$imagename:/",$text)) return $text;
+ if ( preg_match( "/^$imagename:/", $text ) ) return $text;
}
- return parent::autoConvert($text,$toVariant);
+ return parent::autoConvert( $text, $toVariant );
}
/**
* It translates text into variant, specials:
* - ommiting roman numbers
*/
- function translate($text, $toVariant){
+ function translate( $text, $toVariant ) {
$breaks = '[^\w\x80-\xff]';
// regexp for roman numbers
$roman = 'M{0,4}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})';
- $reg = '/^'.$roman.'$|^'.$roman.$breaks.'|'.$breaks.$roman.'$|'.$breaks.$roman.$breaks.'/';
+ $reg = '/^' . $roman . '$|^' . $roman . $breaks . '|' . $breaks . $roman . '$|' . $breaks . $roman . $breaks . '/';
- $matches = preg_split($reg, $text, -1, PREG_SPLIT_OFFSET_CAPTURE);
+ $matches = preg_split( $reg, $text, -1, PREG_SPLIT_OFFSET_CAPTURE );
- $m = array_shift($matches);
- if( !isset( $this->mTables[$toVariant] ) ) {
+ $m = array_shift( $matches );
+ if ( !isset( $this->mTables[$toVariant] ) ) {
throw new MWException( "Broken variant table: " . implode( ',', array_keys( $this->mTables ) ) );
}
$ret = $this->mTables[$toVariant]->replace( $m[0] );
- $mstart = $m[1]+strlen($m[0]);
- foreach($matches as $m) {
- $ret .= substr($text, $mstart, $m[1]-$mstart);
- $ret .= parent::translate($m[0], $toVariant);
- $mstart = $m[1] + strlen($m[0]);
+ $mstart = $m[1] + strlen( $m[0] );
+ foreach ( $matches as $m ) {
+ $ret .= substr( $text, $mstart, $m[1] -$mstart );
+ $ret .= parent::translate( $m[0], $toVariant );
+ $mstart = $m[1] + strlen( $m[0] );
}
return $ret;
parent::__construct();
- $variants = array('sr', 'sr-ec', 'sr-el');
+ $variants = array( 'sr', 'sr-ec', 'sr-el' );
$variantfallbacks = array(
'sr' => 'sr-ec',
'sr-ec' => 'sr',
'S' => 'S', 'писмо' => 'S', 'pismo' => 'S',
'W' => 'W', 'реч' => 'W', 'reč' => 'W', 'ријеч' => 'W', 'riječ' => 'W'
);
- $this->mConverter = new SrConverter($this, 'sr', $variants, $variantfallbacks, $flags);
+ $this->mConverter = new SrConverter( $this, 'sr', $variants, $variantfallbacks, $flags );
$wgHooks['ArticleSaveComplete'][] = $this->mConverter;
}
function convertPlural( $count, $forms ) {
- if ( !count($forms) ) { return ''; }
+ if ( !count( $forms ) ) { return ''; }
- //if no number with word, then use $form[0] for singular and $form[1] for plural or zero
- if( count($forms) === 2 ) return $count == 1 ? $forms[0] : $forms[1];
+ // if no number with word, then use $form[0] for singular and $form[1] for plural or zero
+ if ( count( $forms ) === 2 ) return $count == 1 ? $forms[0] : $forms[1];
// FIXME: CLDR defines 4 plural forms. Form with decimals missing.
// See http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/language_plural_rules.html#ru
$forms = $this->preConvertPlural( $forms, 3 );
- if ($count > 10 && floor(($count % 100) / 10) == 1) {
+ if ( $count > 10 && floor( ( $count % 100 ) / 10 ) == 1 ) {
return $forms[2];
} else {
- switch ($count % 10) {
+ switch ( $count % 10 ) {
case 1: return $forms[0];
case 2:
case 3:
*/
class LanguageSr_ec extends Language {
function convertPlural( $count, $forms ) {
- if ( !count($forms) ) { return ''; }
+ if ( !count( $forms ) ) { return ''; }
$forms = $this->preConvertPlural( $forms, 3 );
- if ($count > 10 && floor(($count % 100) / 10) == 1) {
+ if ( $count > 10 && floor( ( $count % 100 ) / 10 ) == 1 ) {
return $forms[2];
} else {
- switch ($count % 10) {
+ switch ( $count % 10 ) {
case 1: return $forms[0];
case 2:
case 3:
// changed on a subsequent page view.
// see http://mail.wikipedia.org/pipermail/wikitech-l/2006-January/033660.html
-require_once( dirname(__FILE__).'/LanguageSr_ec.php' );
+require_once( dirname( __FILE__ ) . '/LanguageSr_ec.php' );
*/
class LanguageSr_el extends Language {
function convertPlural( $count, $forms ) {
- if ( !count($forms) ) { return ''; }
+ if ( !count( $forms ) ) { return ''; }
$forms = $this->preConvertPlural( $forms, 3 );
- if ($count > 10 && floor(($count % 100) / 10) == 1) {
+ if ( $count > 10 && floor( ( $count % 100 ) / 10 ) == 1 ) {
return $forms[2];
} else {
- switch ($count % 10) {
+ switch ( $count % 10 ) {
case 1: return $forms[0];
case 2:
case 3:
<?php
-require_once( dirname(__FILE__).'/../LanguageConverter.php' );
+require_once( dirname( __FILE__ ) . '/../LanguageConverter.php' );
/**
* Converts Tajiki to latin orthography
* Use singular form for zero
*/
function convertPlural( $count, $forms ) {
- if ( !count($forms) ) { return ''; }
+ if ( !count( $forms ) ) { return ''; }
$forms = $this->preConvertPlural( $forms, 2 );
- return ($count <= 1) ? $forms[0] : $forms[1];
+ return ( $count <= 1 ) ? $forms[0] : $forms[1];
}
}
* Use singular form for zero
*/
function convertPlural( $count, $forms ) {
- if ( !count($forms) ) { return ''; }
+ if ( !count( $forms ) ) { return ''; }
$forms = $this->preConvertPlural( $forms, 2 );
- return ($count <= 1) ? $forms[0] : $forms[1];
+ return ( $count <= 1 ) ? $forms[0] : $forms[1];
}
}
*/
class LanguageTr extends Language {
function ucfirst ( $string ) {
- if ( !empty($string) && $string[0] == 'i' ) {
+ if ( !empty( $string ) && $string[0] == 'i' ) {
return 'İ' . substr( $string, 1 );
} else {
return parent::ucfirst( $string );
*/
function convertGrammar( $word, $case ) {
global $wgGrammarForms;
- if ( isset($wgGrammarForms['tyv'][$case][$word]) ) {
+ if ( isset( $wgGrammarForms['tyv'][$case][$word] ) ) {
return $wgGrammarForms['tyv'][$case][$word];
}
// Set up some constants...
- $allVowels = array("е", "и", "э", "ө", "ү", "а", "ё", "о", "у", "ы", "ю", "я", "a", "e", "i", "o", "ö", "u", "ü", "y");
- $frontVowels = array("е", "и", "э", "ө", "ү", "e", "i", "ö", "ü");
- $backVowels = array("а", "ё", "о", "у", "ы", "ю", "я", "a", "o", "u", "y");
- $unroundFrontVowels = array("е", "и", "э", "e", "i");
- $roundFrontVowels = array("ө", "ү", "ö", "ü");
- $unroundBackVowels = array("а", "ы", "я", "a", "y");
- $roundBackVowels = array("ё", "о", "у", "ю", "o", "u");
- $voicedPhonemes = array("д", "б", "з", "ж", "г", "d", "b", "z", "g");
- $unvoicedPhonemes = array("т", "п", "с", "ш", "к", "ч", "х", "t", "p", "s", "k", "x");
- $directiveUnvoicedStems = array("т", "п", "с", "ш", "к", "ч", "х", "л", "м", "н", "ң", "t", "p", "s", "k", "x", "l", "m", "n", "ŋ");
- $directiveVoicedStems = array("д", "б", "з", "ж", "г", "р", "й", "d", "b", "z", "g", "r", "j");
+ $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*
+
+ $wordEnding = $ar[0][count( $ar[0] ) - 1]; // Here's the last letter in the word
+ $wordReversed = array_reverse( $ar[0] ); // Here's an array with the order of the letters in the word reversed so we can find a match quicker *shrug*
// Find the last vowel in the word
$wordLastVowel = NULL;
foreach ( $wordReversed as $xvalue ) {
foreach ( $allVowels as $yvalue ) {
- if ( strcmp($xvalue, $yvalue) == 0 ) {
+ if ( strcmp( $xvalue, $yvalue ) == 0 ) {
$wordLastVowel = $xvalue;
break;
} else {
// Now convert the word
switch ( $case ) {
case "genitive":
- if ( in_array($wordEnding, $unvoicedPhonemes) ) {
- if ( in_array($wordLastVowel, $roundFrontVowels) ) {
- $word = implode("",$ar[0]) . "түң";
- } elseif ( in_array($wordLastVowel, $unroundFrontVowels) ) {
- $word = implode("",$ar[0]) . "тиң";
- } elseif ( in_array($wordLastVowel, $roundBackVowels) ) {
- $word = implode("",$ar[0]) . "туң";
- } elseif ( in_array($wordLastVowel, $unroundBackVowels) ) {
- $word = implode("",$ar[0]) . "тың";
+ if ( in_array( $wordEnding, $unvoicedPhonemes ) ) {
+ if ( in_array( $wordLastVowel, $roundFrontVowels ) ) {
+ $word = implode( "", $ar[0] ) . "түң";
+ } elseif ( in_array( $wordLastVowel, $unroundFrontVowels ) ) {
+ $word = implode( "", $ar[0] ) . "тиң";
+ } elseif ( in_array( $wordLastVowel, $roundBackVowels ) ) {
+ $word = implode( "", $ar[0] ) . "туң";
+ } elseif ( in_array( $wordLastVowel, $unroundBackVowels ) ) {
+ $word = implode( "", $ar[0] ) . "тың";
} else {
}
- } elseif ( $wordEnding === "л" || $wordEnding === "l") {
- if ( in_array($wordLastVowel, $roundFrontVowels) ) {
- $word = implode("",$ar[0]) . "дүң";
- } elseif ( in_array($wordLastVowel, $unroundFrontVowels) ) {
- $word = implode("",$ar[0]) . "диң";
- } elseif ( in_array($wordLastVowel, $roundBackVowels) ) {
- $word = implode("",$ar[0]) . "дуң";
- } elseif ( in_array($wordLastVowel, $unroundBackVowels) ) {
- $word = implode("",$ar[0]) . "дың";
+ } elseif ( $wordEnding === "л" || $wordEnding === "l" ) {
+ if ( in_array( $wordLastVowel, $roundFrontVowels ) ) {
+ $word = implode( "", $ar[0] ) . "дүң";
+ } elseif ( in_array( $wordLastVowel, $unroundFrontVowels ) ) {
+ $word = implode( "", $ar[0] ) . "диң";
+ } elseif ( in_array( $wordLastVowel, $roundBackVowels ) ) {
+ $word = implode( "", $ar[0] ) . "дуң";
+ } elseif ( in_array( $wordLastVowel, $unroundBackVowels ) ) {
+ $word = implode( "", $ar[0] ) . "дың";
} else {
}
} else {
- if ( in_array($wordLastVowel, $roundFrontVowels) ) {
- $word = implode("",$ar[0]) . "нүң";
- } elseif ( in_array($wordLastVowel, $unroundFrontVowels) ) {
- $word = implode("",$ar[0]) . "ниң";
- } elseif ( in_array($wordLastVowel, $roundBackVowels) ) {
- $word = implode("",$ar[0]) . "нуң";
- } elseif ( in_array($wordLastVowel, $unroundBackVowels) ) {
- $word = implode("",$ar[0]) . "ның";
+ if ( in_array( $wordLastVowel, $roundFrontVowels ) ) {
+ $word = implode( "", $ar[0] ) . "нүң";
+ } elseif ( in_array( $wordLastVowel, $unroundFrontVowels ) ) {
+ $word = implode( "", $ar[0] ) . "ниң";
+ } elseif ( in_array( $wordLastVowel, $roundBackVowels ) ) {
+ $word = implode( "", $ar[0] ) . "нуң";
+ } elseif ( in_array( $wordLastVowel, $unroundBackVowels ) ) {
+ $word = implode( "", $ar[0] ) . "ның";
} else {
}
}
break;
case "dative":
- if ( in_array($wordEnding, $unvoicedPhonemes) ) {
- if ( in_array($wordLastVowel, $frontVowels) ) {
- $word = implode("",$ar[0]) . "ке";
- } elseif ( in_array($wordLastVowel, $backVowels) ) {
- $word = implode("",$ar[0]) . "ка";
+ if ( in_array( $wordEnding, $unvoicedPhonemes ) ) {
+ if ( in_array( $wordLastVowel, $frontVowels ) ) {
+ $word = implode( "", $ar[0] ) . "ке";
+ } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
+ $word = implode( "", $ar[0] ) . "ка";
} else {
}
} else {
- if ( in_array($wordLastVowel, $frontVowels) ) {
- $word = implode("",$ar[0]) . "ге";
- } elseif ( in_array($wordLastVowel, $backVowels) ) {
- $word = implode("",$ar[0]) . "га";
+ if ( in_array( $wordLastVowel, $frontVowels ) ) {
+ $word = implode( "", $ar[0] ) . "ге";
+ } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
+ $word = implode( "", $ar[0] ) . "га";
} else {
}
}
break;
case "accusative":
- if ( in_array($wordEnding, $unvoicedPhonemes) ) {
- if ( in_array($wordLastVowel, $roundFrontVowels) ) {
- $word = implode("",$ar[0]) . "тү";
- } elseif ( in_array($wordLastVowel, $unroundFrontVowels) ) {
- $word = implode("",$ar[0]) . "ти";
- } elseif ( in_array($wordLastVowel, $roundBackVowels) ) {
- $word = implode("",$ar[0]) . "ту";
- } elseif ( in_array($wordLastVowel, $unroundBackVowels) ) {
- $word = implode("",$ar[0]) . "ты";
+ if ( in_array( $wordEnding, $unvoicedPhonemes ) ) {
+ if ( in_array( $wordLastVowel, $roundFrontVowels ) ) {
+ $word = implode( "", $ar[0] ) . "тү";
+ } elseif ( in_array( $wordLastVowel, $unroundFrontVowels ) ) {
+ $word = implode( "", $ar[0] ) . "ти";
+ } elseif ( in_array( $wordLastVowel, $roundBackVowels ) ) {
+ $word = implode( "", $ar[0] ) . "ту";
+ } elseif ( in_array( $wordLastVowel, $unroundBackVowels ) ) {
+ $word = implode( "", $ar[0] ) . "ты";
} else {
}
- } elseif ( $wordEnding === "л" || $wordEnding === "l") {
- if ( in_array($wordLastVowel, $roundFrontVowels) ) {
- $word = implode("",$ar[0]) . "дү";
- } elseif ( in_array($wordLastVowel, $unroundFrontVowels) ) {
- $word = implode("",$ar[0]) . "ди";
- } elseif ( in_array($wordLastVowel, $roundBackVowels) ) {
- $word = implode("",$ar[0]) . "ду";
- } elseif ( in_array($wordLastVowel, $unroundBackVowels) ) {
- $word = implode("",$ar[0]) . "ды";
+ } elseif ( $wordEnding === "л" || $wordEnding === "l" ) {
+ if ( in_array( $wordLastVowel, $roundFrontVowels ) ) {
+ $word = implode( "", $ar[0] ) . "дү";
+ } elseif ( in_array( $wordLastVowel, $unroundFrontVowels ) ) {
+ $word = implode( "", $ar[0] ) . "ди";
+ } elseif ( in_array( $wordLastVowel, $roundBackVowels ) ) {
+ $word = implode( "", $ar[0] ) . "ду";
+ } elseif ( in_array( $wordLastVowel, $unroundBackVowels ) ) {
+ $word = implode( "", $ar[0] ) . "ды";
} else {
}
} else {
- if ( in_array($wordLastVowel, $roundFrontVowels) ) {
- $word = implode("",$ar[0]) . "нү";
- } elseif ( in_array($wordLastVowel, $unroundFrontVowels) ) {
- $word = implode("",$ar[0]) . "ни";
- } elseif ( in_array($wordLastVowel, $roundBackVowels) ) {
- $word = implode("",$ar[0]) . "ну";
- } elseif ( in_array($wordLastVowel, $unroundBackVowels) ) {
- $word = implode("",$ar[0]) . "ны";
+ if ( in_array( $wordLastVowel, $roundFrontVowels ) ) {
+ $word = implode( "", $ar[0] ) . "нү";
+ } elseif ( in_array( $wordLastVowel, $unroundFrontVowels ) ) {
+ $word = implode( "", $ar[0] ) . "ни";
+ } elseif ( in_array( $wordLastVowel, $roundBackVowels ) ) {
+ $word = implode( "", $ar[0] ) . "ну";
+ } elseif ( in_array( $wordLastVowel, $unroundBackVowels ) ) {
+ $word = implode( "", $ar[0] ) . "ны";
} else {
}
}
break;
case "locative":
- if ( in_array($wordEnding, $unvoicedPhonemes) ) {
- if ( in_array($wordLastVowel, $frontVowels) ) {
- $word = implode("",$ar[0]) . "те";
- } elseif ( in_array($wordLastVowel, $backVowels) ) {
- $word = implode("",$ar[0]) . "та";
+ if ( in_array( $wordEnding, $unvoicedPhonemes ) ) {
+ if ( in_array( $wordLastVowel, $frontVowels ) ) {
+ $word = implode( "", $ar[0] ) . "те";
+ } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
+ $word = implode( "", $ar[0] ) . "та";
} else {
}
} else {
- if ( in_array($wordLastVowel, $frontVowels) ) {
- $word = implode("",$ar[0]) . "де";
- } elseif ( in_array($wordLastVowel, $backVowels) ) {
- $word = implode("",$ar[0]) . "да";
+ if ( in_array( $wordLastVowel, $frontVowels ) ) {
+ $word = implode( "", $ar[0] ) . "де";
+ } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
+ $word = implode( "", $ar[0] ) . "да";
} else {
}
}
break;
case "ablative":
- if ( in_array($wordEnding, $unvoicedPhonemes) ) {
- if ( in_array($wordLastVowel, $frontVowels) ) {
- $word = implode("",$ar[0]) . "тен";
- } elseif ( in_array($wordLastVowel, $backVowels) ) {
- $word = implode("",$ar[0]) . "тан";
+ if ( in_array( $wordEnding, $unvoicedPhonemes ) ) {
+ if ( in_array( $wordLastVowel, $frontVowels ) ) {
+ $word = implode( "", $ar[0] ) . "тен";
+ } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
+ $word = implode( "", $ar[0] ) . "тан";
} else {
}
} else {
- if ( in_array($wordLastVowel, $frontVowels) ) {
- $word = implode("",$ar[0]) . "ден";
- } elseif ( in_array($wordLastVowel, $backVowels) ) {
- $word = implode("",$ar[0]) . "дан";
+ if ( in_array( $wordLastVowel, $frontVowels ) ) {
+ $word = implode( "", $ar[0] ) . "ден";
+ } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
+ $word = implode( "", $ar[0] ) . "дан";
} else {
}
}
break;
case "directive1":
- if ( in_array($wordEnding, $directiveVoicedStems) ) {
- $word = implode("",$ar[0]) . "же";
- } elseif ( in_array($wordEnding, $directiveUnvoicedStems) ) {
- $word = implode("",$ar[0]) . "че";
+ if ( in_array( $wordEnding, $directiveVoicedStems ) ) {
+ $word = implode( "", $ar[0] ) . "же";
+ } elseif ( in_array( $wordEnding, $directiveUnvoicedStems ) ) {
+ $word = implode( "", $ar[0] ) . "че";
} else {
}
break;
case "directive2":
- if ( in_array($wordEnding, $unvoicedPhonemes) ) {
- if ( in_array($wordLastVowel, $roundFrontVowels) ) {
- $word = implode("",$ar[0]) . "түве";
- } elseif ( in_array($wordLastVowel, $unroundFrontVowels) ) {
- $word = implode("",$ar[0]) . "тиве";
- } elseif ( in_array($wordLastVowel, $roundBackVowels) ) {
- $word = implode("",$ar[0]) . "туве";
- } elseif ( in_array($wordLastVowel, $unroundBackVowels) ) {
- $word = implode("",$ar[0]) . "тыве";
+ if ( in_array( $wordEnding, $unvoicedPhonemes ) ) {
+ if ( in_array( $wordLastVowel, $roundFrontVowels ) ) {
+ $word = implode( "", $ar[0] ) . "түве";
+ } elseif ( in_array( $wordLastVowel, $unroundFrontVowels ) ) {
+ $word = implode( "", $ar[0] ) . "тиве";
+ } elseif ( in_array( $wordLastVowel, $roundBackVowels ) ) {
+ $word = implode( "", $ar[0] ) . "туве";
+ } elseif ( in_array( $wordLastVowel, $unroundBackVowels ) ) {
+ $word = implode( "", $ar[0] ) . "тыве";
} else {
}
} else {
- if ( in_array($wordLastVowel, $roundFrontVowels) ) {
- $word = implode("",$ar[0]) . "дүве";
- } elseif ( in_array($wordLastVowel, $unroundFrontVowels) ) {
- $word = implode("",$ar[0]) . "диве";
- } elseif ( in_array($wordLastVowel, $roundBackVowels) ) {
- $word = implode("",$ar[0]) . "дуве";
- } elseif ( in_array($wordLastVowel, $unroundBackVowels) ) {
- $word = implode("",$ar[0]) . "дыве";
+ if ( in_array( $wordLastVowel, $roundFrontVowels ) ) {
+ $word = implode( "", $ar[0] ) . "дүве";
+ } elseif ( in_array( $wordLastVowel, $unroundFrontVowels ) ) {
+ $word = implode( "", $ar[0] ) . "диве";
+ } elseif ( in_array( $wordLastVowel, $roundBackVowels ) ) {
+ $word = implode( "", $ar[0] ) . "дуве";
+ } elseif ( in_array( $wordLastVowel, $unroundBackVowels ) ) {
+ $word = implode( "", $ar[0] ) . "дыве";
} else {
}
}
# Invoked with {{grammar:case|word}}
function convertGrammar( $word, $case ) {
global $wgGrammarForms;
- if ( isset($wgGrammarForms['uk'][$case][$word]) ) {
+ if ( isset( $wgGrammarForms['uk'][$case][$word] ) ) {
return $wgGrammarForms['uk'][$case][$word];
}
# These rules are not perfect, but they are currently only used for site names so it doesn't
# matter if they are wrong sometimes. Just add a special case for your site name if necessary.
- #join and array_slice instead mb_substr
+ # join and array_slice instead mb_substr
$ar = array();
preg_match_all( '/./us', $word, $ar );
- if (!preg_match("/[a-zA-Z_]/us", $word))
+ if ( !preg_match( "/[a-zA-Z_]/us", $word ) )
switch ( $case ) {
- case 'genitive': #родовий відмінок
- if ((join('',array_slice($ar[0],-4))=='вікі') || (join('',array_slice($ar[0],-4))=='Вікі'))
- {}
- elseif (join('',array_slice($ar[0],-1))=='ь')
- $word = join('',array_slice($ar[0],0,-1)).'я';
- elseif (join('',array_slice($ar[0],-2))=='ія')
- $word=join('',array_slice($ar[0],0,-2)).'ії';
- elseif (join('',array_slice($ar[0],-2))=='ка')
- $word=join('',array_slice($ar[0],0,-2)).'ки';
- elseif (join('',array_slice($ar[0],-2))=='ти')
- $word=join('',array_slice($ar[0],0,-2)).'тей';
- elseif (join('',array_slice($ar[0],-2))=='ди')
- $word=join('',array_slice($ar[0],0,-2)).'дів';
- elseif (join('',array_slice($ar[0],-3))=='ник')
- $word=join('',array_slice($ar[0],0,-3)).'ника';
+ case 'genitive': # родовий відмінок
+ if ( ( join( '', array_slice( $ar[0], -4 ) ) == 'вікі' ) || ( join( '', array_slice( $ar[0], -4 ) ) == 'Вікі' ) )
+ { }
+ elseif ( join( '', array_slice( $ar[0], -1 ) ) == 'ь' )
+ $word = join( '', array_slice( $ar[0], 0, -1 ) ) . 'я';
+ elseif ( join( '', array_slice( $ar[0], -2 ) ) == 'ія' )
+ $word = join( '', array_slice( $ar[0], 0, -2 ) ) . 'ії';
+ elseif ( join( '', array_slice( $ar[0], -2 ) ) == 'ка' )
+ $word = join( '', array_slice( $ar[0], 0, -2 ) ) . 'ки';
+ elseif ( join( '', array_slice( $ar[0], -2 ) ) == 'ти' )
+ $word = join( '', array_slice( $ar[0], 0, -2 ) ) . 'тей';
+ elseif ( join( '', array_slice( $ar[0], -2 ) ) == 'ди' )
+ $word = join( '', array_slice( $ar[0], 0, -2 ) ) . 'дів';
+ elseif ( join( '', array_slice( $ar[0], -3 ) ) == 'ник' )
+ $word = join( '', array_slice( $ar[0], 0, -3 ) ) . 'ника';
break;
- case 'dative': #давальний відмінок
- #stub
+ case 'dative': # давальний відмінок
+ # stub
break;
- case 'accusative': #знахідний відмінок
- if ((join('',array_slice($ar[0],-4))=='вікі') || (join('',array_slice($ar[0],-4))=='Вікі'))
- {}
- elseif (join('',array_slice($ar[0],-2))=='ія')
- $word=join('',array_slice($ar[0],0,-2)).'ію';
+ case 'accusative': # знахідний відмінок
+ if ( ( join( '', array_slice( $ar[0], -4 ) ) == 'вікі' ) || ( join( '', array_slice( $ar[0], -4 ) ) == 'Вікі' ) )
+ { }
+ elseif ( join( '', array_slice( $ar[0], -2 ) ) == 'ія' )
+ $word = join( '', array_slice( $ar[0], 0, -2 ) ) . 'ію';
break;
- case 'instrumental': #орудний відмінок
- #stub
+ case 'instrumental': # орудний відмінок
+ # stub
break;
- case 'prepositional': #місцевий відмінок
- #stub
+ case 'prepositional': # місцевий відмінок
+ # stub
break;
}
return $word;
}
function convertPlural( $count, $forms ) {
- if ( !count($forms) ) { return ''; }
+ if ( !count( $forms ) ) { return ''; }
- //if no number with word, then use $form[0] for singular and $form[1] for plural or zero
- if( count($forms) === 2 ) return $count == 1 ? $forms[0] : $forms[1];
+ // if no number with word, then use $form[0] for singular and $form[1] for plural or zero
+ if ( count( $forms ) === 2 ) return $count == 1 ? $forms[0] : $forms[1];
// FIXME: CLDR defines 4 plural forms. Form for decimals is missing/
// See http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/language_plural_rules.html#uk
$forms = $this->preConvertPlural( $forms, 3 );
- if ($count > 10 && floor(($count % 100) / 10) == 1) {
+ if ( $count > 10 && floor( ( $count % 100 ) / 10 ) == 1 ) {
return $forms[2];
} else {
- switch ($count % 10) {
+ switch ( $count % 10 ) {
case 1: return $forms[0];
case 2:
case 3:
* Ukrainian numeric format is "12 345,67" but "1234,56"
*/
- function commafy($_) {
- if (!preg_match('/^\d{1,4}$/',$_)) {
- return strrev((string)preg_replace('/(\d{3})(?=\d)(?!\d*\.)/','$1,',strrev($_)));
+ function commafy( $_ ) {
+ if ( !preg_match( '/^\d{1,4}$/', $_ ) ) {
+ return strrev( (string)preg_replace( '/(\d{3})(?=\d)(?!\d*\.)/', '$1,', strrev( $_ ) ) );
} else {
return $_;
}
* Use singular form for zero
*/
function convertPlural( $count, $forms ) {
- if ( !count($forms) ) { return ''; }
+ if ( !count( $forms ) ) { return ''; }
$forms = $this->preConvertPlural( $forms, 2 );
- return ($count <= 1) ? $forms[0] : $forms[1];
+ return ( $count <= 1 ) ? $forms[0] : $forms[1];
}
- ###
- ### Dates in Walloon are "1î d' <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
- ###
+ ## #
+ ## # 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 ) {
if ( $adj ) { $ts = $this->userAdjust( $ts, $tc ); }
$datePreference = $this->dateFormat( $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);
+ $d = substr( $ts, 0, 4 ) . '-' . substr( $ts, 4, 2 ) . '-' . substr( $ts, 6, 2 );
return $d;
}
# dd/mm/YYYY format
if ( $datePreference == 'walloon short' ) {
- $d = substr($ts, 6, 2). '/' . substr($ts, 4, 2). '/' .substr($ts, 0, 4);
+ $d = substr( $ts, 6, 2 ) . '/' . substr( $ts, 4, 2 ) . '/' . substr( $ts, 0, 4 );
return $d;
}
# we output this in all other cases
$m = substr( $ts, 4, 2 );
$n = substr( $ts, 6, 2 );
- if ($n == 1) {
+ if ( $n == 1 ) {
$d = "1î d' " . $this->getMonthName( $m ) .
" " . substr( $ts, 0, 4 );
- } else if ($n == 2 || $n == 3 || $n == 20 || $n == 22 || $n == 23) {
- $d = (0 + $n) . " d' " . $this->getMonthName( $m ) .
+ } else if ( $n == 2 || $n == 3 || $n == 20 || $n == 22 || $n == 23 ) {
+ $d = ( 0 + $n ) . " d' " . $this->getMonthName( $m ) .
" " . substr( $ts, 0, 4 );
- } else if ($m == 4 || $m == 8 || $m == 10) {
- $d = (0 + $n) . " d' " . $this->getMonthName( $m ) .
+ } else if ( $m == 4 || $m == 8 || $m == 10 ) {
+ $d = ( 0 + $n ) . " d' " . $this->getMonthName( $m ) .
" " . substr( $ts, 0, 4 );
} else {
- $d = (0 + $n) . " di " . $this->getMonthName( $m ) .
+ $d = ( 0 + $n ) . " di " . $this->getMonthName( $m ) .
" " . substr( $ts, 0, 4 );
}
return $d;
$s = self::insertSpace( $string, $reg );
return $s;
}
-
+
function normalizeForSearch( $string ) {
wfProfileIn( __METHOD__ );
// changed on a subsequent page view.
// see http://lists.wikimedia.org/pipermail/wikitech-l/2006-January/021311.html
-require_once( dirname(__FILE__).'/LanguageZh_hans.php' );
-require_once( dirname(__FILE__).'/../LanguageConverter.php' );
+require_once( dirname( __FILE__ ) . '/LanguageZh_hans.php' );
+require_once( dirname( __FILE__ ) . '/../LanguageConverter.php' );
<?php
-require_once( dirname(__FILE__).'/../LanguageConverter.php' );
-require_once( dirname(__FILE__).'/LanguageZh_hans.php' );
+require_once( dirname( __FILE__ ) . '/../LanguageConverter.php' );
+require_once( dirname( __FILE__ ) . '/LanguageZh_hans.php' );
/**
* @ingroup Language
*/
class ZhConverter extends LanguageConverter {
- function __construct($langobj, $maincode,
- $variants=array(),
- $variantfallbacks=array(),
+ function __construct( $langobj, $maincode,
+ $variants = array(),
+ $variantfallbacks = array(),
$flags = array(),
$manualLevel = array() ) {
$this->mDescCodeSep = ':';
$this->mDescVarSep = ';';
- parent::__construct($langobj, $maincode,
+ parent::__construct( $langobj, $maincode,
$variants,
$variantfallbacks,
$flags,
- $manualLevel);
+ $manualLevel );
$names = array(
'zh' => '原文',
'zh-hans' => '简体',
'zh-sg' => '新加坡',
'zh-my' => '大马',
);
- $this->mVariantNames = array_merge($this->mVariantNames,$names);
+ $this->mVariantNames = array_merge( $this->mVariantNames, $names );
}
function loadDefaultTables() {
- require( dirname(__FILE__)."/../../includes/ZhConversion.php" );
+ require( dirname( __FILE__ ) . "/../../includes/ZhConversion.php" );
$this->mTables = array(
'zh-hans' => new ReplacementArray( $zh2Hans ),
'zh-hant' => new ReplacementArray( $zh2Hant ),
- 'zh-cn' => new ReplacementArray( array_merge($zh2Hans, $zh2CN) ),
- 'zh-hk' => new ReplacementArray( array_merge($zh2Hant, $zh2HK) ),
- 'zh-mo' => new ReplacementArray( array_merge($zh2Hant, $zh2HK) ),
- 'zh-my' => new ReplacementArray( array_merge($zh2Hans, $zh2SG) ),
- 'zh-sg' => new ReplacementArray( array_merge($zh2Hans, $zh2SG) ),
- 'zh-tw' => new ReplacementArray( array_merge($zh2Hant, $zh2TW) ),
+ 'zh-cn' => new ReplacementArray( array_merge( $zh2Hans, $zh2CN ) ),
+ 'zh-hk' => new ReplacementArray( array_merge( $zh2Hant, $zh2HK ) ),
+ 'zh-mo' => new ReplacementArray( array_merge( $zh2Hant, $zh2HK ) ),
+ 'zh-my' => new ReplacementArray( array_merge( $zh2Hans, $zh2SG ) ),
+ 'zh-sg' => new ReplacementArray( array_merge( $zh2Hans, $zh2SG ) ),
+ 'zh-tw' => new ReplacementArray( array_merge( $zh2Hant, $zh2TW ) ),
'zh' => new ReplacementArray
);
}
to mark anything.
$noParse is there for compatibility with LanguageConvert::markNoConversion
*/
- function markNoConversion($text, $noParse = false) {
+ function markNoConversion( $text, $noParse = false ) {
return $text;
}
global $wgHooks;
parent::__construct();
- $variants = array('zh','zh-hans','zh-hant','zh-cn','zh-hk','zh-mo','zh-my','zh-sg','zh-tw');
-
+ $variants = array( 'zh', 'zh-hans', 'zh-hant', 'zh-cn', 'zh-hk', 'zh-mo', 'zh-my', 'zh-sg', 'zh-tw' );
+
$variantfallbacks = array(
- 'zh' => array('zh-hans','zh-hant','zh-cn','zh-tw','zh-hk','zh-sg','zh-mo','zh-my'),
- 'zh-hans' => array('zh-cn','zh-sg','zh-my'),
- 'zh-hant' => array('zh-tw','zh-hk','zh-mo'),
- 'zh-cn' => array('zh-hans','zh-sg','zh-my'),
- 'zh-sg' => array('zh-hans','zh-cn','zh-my'),
- 'zh-my' => array('zh-hans','zh-sg','zh-cn'),
- 'zh-tw' => array('zh-hant','zh-hk','zh-mo'),
- 'zh-hk' => array('zh-hant','zh-mo','zh-tw'),
- 'zh-mo' => array('zh-hant','zh-hk','zh-tw'),
+ 'zh' => array( 'zh-hans', 'zh-hant', 'zh-cn', 'zh-tw', 'zh-hk', 'zh-sg', 'zh-mo', 'zh-my' ),
+ 'zh-hans' => array( 'zh-cn', 'zh-sg', 'zh-my' ),
+ 'zh-hant' => array( 'zh-tw', 'zh-hk', 'zh-mo' ),
+ 'zh-cn' => array( 'zh-hans', 'zh-sg', 'zh-my' ),
+ 'zh-sg' => array( 'zh-hans', 'zh-cn', 'zh-my' ),
+ 'zh-my' => array( 'zh-hans', 'zh-sg', 'zh-cn' ),
+ 'zh-tw' => array( 'zh-hant', 'zh-hk', 'zh-mo' ),
+ 'zh-hk' => array( 'zh-hant', 'zh-mo', 'zh-tw' ),
+ 'zh-mo' => array( 'zh-hant', 'zh-hk', 'zh-tw' ),
);
- $ml=array(
+ $ml = array(
'zh' => 'disable',
'zh-hans' => 'unidirectional',
'zh-hant' => 'unidirectional',
$this->mConverter = new ZhConverter( $this, 'zh',
$variants, $variantfallbacks,
array(),
- $ml);
+ $ml );
$wgHooks['ArticleSaveComplete'][] = $this->mConverter;
}
function segmentForDiff( $text ) {
return preg_replace(
"/([\\xc0-\\xff][\\x80-\\xbf]*)/e",
- "' ' .\"$1\"", $text);
+ "' ' .\"$1\"", $text );
}
function unsegmentForDiff( $text ) {
return preg_replace(
"/ ([\\xc0-\\xff][\\x80-\\xbf]*)/e",
- "\"$1\"", $text);
+ "\"$1\"", $text );
}
/**
$terms = implode( '|', $termsArray );
$terms = self::convertDoubleWidth( $terms );
$terms = implode( '|', $this->mConverter->autoConvertToAllVariants( $terms ) );
- $ret = array_unique( explode('|', $terms) );
+ $ret = array_unique( explode( '|', $terms ) );
return $ret;
}
}