]> scripts.mit.edu Git - autoinstalls/mediawiki.git/blob - languages/classes/LanguageFi.php
MediaWiki 1.17.0
[autoinstalls/mediawiki.git] / languages / classes / LanguageFi.php
1 <?php
2
3 /** Finnish (Suomi)
4  *
5  * @ingroup Language
6  *
7  * @author Niklas Laxström
8  */
9 class LanguageFi extends Language {
10
11         # Convert from the nominative form of a noun to some other case
12         # Invoked with {{GRAMMAR:case|word}}
13         function convertGrammar( $word, $case ) {
14                 global $wgGrammarForms;
15                 if ( isset( $wgGrammarForms['fi'][$case][$word] ) ) {
16                         return $wgGrammarForms['fi'][$case][$word];
17                 }
18
19                 # These rules are not perfect, but they are currently only used for site names so it doesn't
20                 # matter if they are wrong sometimes. Just add a special case for your site name if necessary.
21
22                 # wovel harmony flag
23                 $aou = preg_match( '/[aou][^äöy]*$/i', $word );
24
25                 # The flag should be false for compounds where the last word has only neutral vowels (e/i).
26                 # The general case cannot be handled without a dictionary, but there's at least one notable
27                 # special case we should check for:
28
29                 if ( preg_match( '/wiki$/i', $word ) )
30                         $aou = false;
31
32                 # append i after final consonant
33                 if ( preg_match( '/[bcdfghjklmnpqrstvwxz]$/i', $word ) )
34                         $word .= 'i';
35
36                 switch ( $case ) {
37                         case 'genitive':
38                                 $word .= 'n';
39                                 break;
40                         case 'elative':
41                                 $word .= ( $aou ? 'sta' : 'stä' );
42                                 break;
43                         case 'partitive':
44                                 $word .= ( $aou ? 'a' : 'ä' );
45                                 break;
46                         case 'illative':
47                                 # Double the last letter and add 'n'
48                                 # mb_substr has a compatibility function in GlobalFunctions.php
49                                 $word = $word . mb_substr( $word, -1 ) . 'n';
50                                 break;
51                         case 'inessive':
52                                 $word .= ( $aou ? 'ssa' : 'ssä' );
53                                 break;
54                 }
55                 return $word;
56         }
57
58         function translateBlockExpiry( $str, $forContent = false ) {
59                 /*
60                         'ago', 'now', 'today', 'this', 'next',
61                         'first', 'third', 'fourth', 'fifth', 'sixth', 'seventh', 'eighth', 'ninth', 'tenth', 'eleventh', 'twelfth',
62                         'tomorrow', 'yesterday'
63
64                         $months = 'january:tammikuu,february:helmikuu,march:maaliskuu,april:huhtikuu,may:toukokuu,june:kesäkuu,' .
65                                 'july:heinäkuu,august:elokuu,september:syyskuu,october:lokakuu,november:marraskuu,december:joulukuu,' .
66                                 'jan:tammikuu,feb:helmikuu,mar:maaliskuu,apr:huhtikuu,jun:kesäkuu,jul:heinäkuu,aug:elokuu,sep:syyskuu,'.
67                                 'oct:lokakuu,nov:marraskuu,dec:joulukuu,sept:syyskuu';
68                 */
69                 $weekds = array(
70                         'monday' => 'maanantai',
71                         'tuesday' => 'tiistai',
72                         'wednesday' => 'keskiviikko',
73                         'thursay' => 'torstai',
74                         'friday' => 'perjantai',
75                         'saturday' => 'lauantai',
76                         'sunday' => 'sunnuntai',
77                         'mon' => 'ma',
78                         'tue' => 'ti',
79                         'tues' => 'ti',
80                         'wed' => 'ke',
81                         'wednes' => 'ke',
82                         'thu' => 'to',
83                         'thur' => 'to',
84                         'thurs' => 'to',
85                         'fri' => 'pe',
86                         'sat' => 'la',
87                         'sun' => 'su',
88                         'next' => 'seuraava',
89                         'tomorrow' => 'huomenna',
90                         'ago' => 'sitten',
91                         'seconds' => 'sekuntia',
92                         'second' => 'sekunti',
93                         'secs' => 's',
94                         'sec' => 's',
95                         'minutes' => 'minuuttia',
96                         'minute' => 'minuutti',
97                         'mins' => 'min',
98                         'min' => 'min',
99                         'days' => 'päivää',
100                         'day' => 'päivä',
101                         'hours' => 'tuntia',
102                         'hour' => 'tunti',
103                         'weeks' => 'viikkoa',
104                         'week' => 'viikko',
105                         'fortnights' => 'tuplaviikkoa',
106                         'fortnight' => 'tuplaviikko',
107                         'months' => 'kuukautta',
108                         'month' => 'kuukausi',
109                         'years' => 'vuotta',
110                         'year' => 'vuosi',
111                         'infinite' => 'ikuisesti',
112                         'indefinite' => 'ikuisesti'
113                 );
114
115                 $final = '';
116                 $tokens = explode ( ' ', $str );
117                 foreach ( $tokens as $item ) {
118                         if ( !is_numeric( $item ) ) {
119                                 if ( count ( explode( '-', $item ) ) == 3 && strlen( $item ) == 10 ) {
120                                         list( $yyyy, $mm, $dd ) = explode( '-', $item );
121                                         $final .= ' ' . $this->date( "{$yyyy}{$mm}{$dd}000000" );
122                                         continue;
123                                 }
124                                 if ( isset( $weekds[$item] ) ) {
125                                         $final .= ' ' . $weekds[$item];
126                                         continue;
127                                 }
128                         }
129
130                         $final .= ' ' . $item;
131                 }
132
133                 return htmlspecialchars( trim( $final ) );
134         }
135 }