MediaWiki  REL1_19
LanguageBe_tarask.php
Go to the documentation of this file.
00001 <?php
00012 class LanguageBe_tarask extends Language {
00027         function convertPlural( $count, $forms ) {
00028                 if ( !count( $forms ) ) { return ''; }
00029 
00030                 // If the actual number is not mentioned in the expression, then just two forms are enough:
00031                 // singular for $count == 1
00032                 // plural   for $count != 1
00033                 // For example, "This user belongs to {{PLURAL:$1|one group|several groups}}."
00034                 if ( count( $forms ) === 2 ) return $count == 1 ? $forms[0] : $forms[1];
00035 
00036                 // @todo FIXME: CLDR defines 4 plural forms instead of 3
00037                 //        http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/language_plural_rules.html
00038                 $forms = $this->preConvertPlural( $forms, 3 );
00039 
00040                 if ( $count > 10 && floor( ( $count % 100 ) / 10 ) == 1 ) {
00041                         return $forms[2];
00042                 } else {
00043                         switch ( $count % 10 ) {
00044                                 case 1:  return $forms[0];
00045                                 case 2:
00046                                 case 3:
00047                                 case 4:  return $forms[1];
00048                                 default: return $forms[2];
00049                         }
00050                 }
00051         }
00052 
00063         function normalizeForSearch( $string ) {
00064                 wfProfileIn( __METHOD__ );
00065 
00066                 # MySQL fulltext index doesn't grok utf-8, so we
00067                 # need to fold cases and convert to hex
00068 
00069                 # Replacing apostrophe sign U+2019 with U+0027
00070                 $s = preg_replace( '/\xe2\x80\x99/', '\'', $string );
00071 
00072                 $s = parent::normalizeForSearch( $s );
00073 
00074                 wfProfileOut( __METHOD__ );
00075                 return $s;
00076         }
00077 
00086         function commafy( $_ ) {
00087                 if ( preg_match( '/^-?\d{1,4}(\.\d*)?$/', $_ ) ) {
00088                         return $_;
00089                 } else {
00090                         return strrev( (string)preg_replace( '/(\d{3})(?=\d)(?!\d*\.)/', '$1,', strrev( $_ ) ) );
00091                 }
00092         }
00093 }