MediaWiki  REL1_20
LanguageFi.php
Go to the documentation of this file.
00001 <?php
00030 class LanguageFi extends Language {
00031 
00040         function convertGrammar( $word, $case ) {
00041                 global $wgGrammarForms;
00042                 if ( isset( $wgGrammarForms['fi'][$case][$word] ) ) {
00043                         return $wgGrammarForms['fi'][$case][$word];
00044                 }
00045 
00046                 # These rules are not perfect, but they are currently only used for site names so it doesn't
00047                 # matter if they are wrong sometimes. Just add a special case for your site name if necessary.
00048 
00049                 # wovel harmony flag
00050                 $aou = preg_match( '/[aou][^äöy]*$/i', $word );
00051 
00052                 # The flag should be false for compounds where the last word has only neutral vowels (e/i).
00053                 # The general case cannot be handled without a dictionary, but there's at least one notable
00054                 # special case we should check for:
00055 
00056                 if ( preg_match( '/wiki$/i', $word ) )
00057                         $aou = false;
00058 
00059                 # append i after final consonant
00060                 if ( preg_match( '/[bcdfghjklmnpqrstvwxz]$/i', $word ) )
00061                         $word .= 'i';
00062 
00063                 switch ( $case ) {
00064                         case 'genitive':
00065                                 $word .= 'n';
00066                                 break;
00067                         case 'elative':
00068                                 $word .= ( $aou ? 'sta' : 'stä' );
00069                                 break;
00070                         case 'partitive':
00071                                 $word .= ( $aou ? 'a' : 'ä' );
00072                                 break;
00073                         case 'illative':
00074                                 # Double the last letter and add 'n'
00075                                 # mb_substr has a compatibility function in GlobalFunctions.php
00076                                 $word = $word . mb_substr( $word, -1 ) . 'n';
00077                                 break;
00078                         case 'inessive':
00079                                 $word .= ( $aou ? 'ssa' : 'ssä' );
00080                                 break;
00081                 }
00082                 return $word;
00083         }
00084 
00090         function translateBlockExpiry( $str, $forContent = false ) {
00091                 /*
00092                         'ago', 'now', 'today', 'this', 'next',
00093                         'first', 'third', 'fourth', 'fifth', 'sixth', 'seventh', 'eighth', 'ninth', 'tenth', 'eleventh', 'twelfth',
00094                         'tomorrow', 'yesterday'
00095 
00096                         $months = 'january:tammikuu,february:helmikuu,march:maaliskuu,april:huhtikuu,may:toukokuu,june:kesäkuu,' .
00097                                 'july:heinäkuu,august:elokuu,september:syyskuu,october:lokakuu,november:marraskuu,december:joulukuu,' .
00098                                 'jan:tammikuu,feb:helmikuu,mar:maaliskuu,apr:huhtikuu,jun:kesäkuu,jul:heinäkuu,aug:elokuu,sep:syyskuu,'.
00099                                 'oct:lokakuu,nov:marraskuu,dec:joulukuu,sept:syyskuu';
00100                 */
00101                 $weekds = array(
00102                         'monday' => 'maanantai',
00103                         'tuesday' => 'tiistai',
00104                         'wednesday' => 'keskiviikko',
00105                         'thursay' => 'torstai',
00106                         'friday' => 'perjantai',
00107                         'saturday' => 'lauantai',
00108                         'sunday' => 'sunnuntai',
00109                         'mon' => 'ma',
00110                         'tue' => 'ti',
00111                         'tues' => 'ti',
00112                         'wed' => 'ke',
00113                         'wednes' => 'ke',
00114                         'thu' => 'to',
00115                         'thur' => 'to',
00116                         'thurs' => 'to',
00117                         'fri' => 'pe',
00118                         'sat' => 'la',
00119                         'sun' => 'su',
00120                         'next' => 'seuraava',
00121                         'tomorrow' => 'huomenna',
00122                         'ago' => 'sitten',
00123                         'seconds' => 'sekuntia',
00124                         'second' => 'sekunti',
00125                         'secs' => 's',
00126                         'sec' => 's',
00127                         'minutes' => 'minuuttia',
00128                         'minute' => 'minuutti',
00129                         'mins' => 'min',
00130                         'min' => 'min',
00131                         'days' => 'päivää',
00132                         'day' => 'päivä',
00133                         'hours' => 'tuntia',
00134                         'hour' => 'tunti',
00135                         'weeks' => 'viikkoa',
00136                         'week' => 'viikko',
00137                         'fortnights' => 'tuplaviikkoa',
00138                         'fortnight' => 'tuplaviikko',
00139                         'months' => 'kuukautta',
00140                         'month' => 'kuukausi',
00141                         'years' => 'vuotta',
00142                         'year' => 'vuosi',
00143                         'infinite' => 'ikuisesti',
00144                         'indefinite' => 'ikuisesti'
00145                 );
00146 
00147                 $final = '';
00148                 $tokens = explode ( ' ', $str );
00149                 foreach ( $tokens as $item ) {
00150                         if ( !is_numeric( $item ) ) {
00151                                 if ( count ( explode( '-', $item ) ) == 3 && strlen( $item ) == 10 ) {
00152                                         list( $yyyy, $mm, $dd ) = explode( '-', $item );
00153                                         $final .= ' ' . $this->date( "{$yyyy}{$mm}{$dd}000000" );
00154                                         continue;
00155                                 }
00156                                 if ( isset( $weekds[$item] ) ) {
00157                                         $final .= ' ' . $weekds[$item];
00158                                         continue;
00159                                 }
00160                         }
00161 
00162                         $final .= ' ' . $item;
00163                 }
00164 
00165                 return htmlspecialchars( trim( $final ) );
00166         }
00167 }