Merged localisation-work branch:
[lhc/web/wiklou.git] / languages / LanguageFi.php
1 <?php
2 /** Finnish (Suomi)
3 *
4 * @package MediaWiki
5 * @subpackage Language
6 *
7 * @author Niklas Laxström
8 */
9 class LanguageFi extends Language {
10 /**
11 * Avoid grouping whole numbers between 0 to 9999
12 */
13 function commafy($_) {
14 if (!preg_match('/^\d{1,4}$/',$_)) {
15 return strrev((string)preg_replace('/(\d{3})(?=\d)(?!\d*\.)/','$1,',strrev($_)));
16 } else {
17 return $_;
18 }
19 }
20
21 # Convert from the nominative form of a noun to some other case
22 # Invoked with {{GRAMMAR:case|word}}
23 function convertGrammar( $word, $case ) {
24 global $wgGrammarForms;
25 if ( isset($wgGrammarForms['fi'][$case][$word]) ) {
26 return $wgGrammarForms['fi'][$case][$word];
27 }
28
29 # These rules are not perfect, but they are currently only used for site names so it doesn't
30 # matter if they are wrong sometimes. Just add a special case for your site name if necessary.
31 switch ( $case ) {
32 case 'genitive':
33 if ( $word == 'Wikisitaatit' ) {
34 $word = 'Wikisitaattien';
35 } else {
36 $word .= 'n';
37 }
38 break;
39 case 'elative':
40 if ( $word == 'Wikisitaatit' ) {
41 $word = 'Wikisitaateista';
42 } else {
43 if ( mb_substr($word, -1) == 'y' ) {
44 $word .= 'stä';
45 } else {
46 $word .= 'sta';
47 }
48 }
49 break;
50 case 'partitive':
51 if ( $word == 'Wikisitaatit' ) {
52 $word = 'Wikisitaatteja';
53 } else {
54 if ( mb_substr($word, -1) == 'y' ) {
55 $word .= 'ä';
56 } else {
57 $word .= 'a';
58 }
59 }
60 break;
61 case 'illative':
62 # Double the last letter and add 'n'
63 # mb_substr has a compatibility function in GlobalFunctions.php
64 if ( $word == 'Wikisitaatit' ) {
65 $word = 'Wikisitaatteihin';
66 } else {
67 $word = $word . mb_substr($word,-1) . 'n';
68 }
69 break;
70 case 'inessive':
71 if ( $word == 'Wikisitaatit' ) {
72 $word = 'Wikisitaateissa';
73 } else {
74 if ( mb_substr($word, -1) == 'y' ) {
75 $word .= 'ssä';
76 } else {
77 $word .= 'ssa';
78 }
79 }
80 break;
81
82 }
83 return $word;
84 }
85
86 function translateBlockExpiry( $str ) {
87 /*
88 'ago', 'now', 'today', 'this', 'next',
89 'first', 'third', 'fourth', 'fifth', 'sixth', 'seventh', 'eighth', 'ninth', 'tenth', 'eleventh', 'twelfth',
90 'tomorrow', 'yesterday'
91
92 $months = 'january:tammikuu,february:helmikuu,march:maaliskuu,april:huhtikuu,may:toukokuu,june:kesäkuu,' .
93 'july:heinäkuu,august:elokuu,september:syyskuu,october:lokakuu,november:marraskuu,december:joulukuu,' .
94 'jan:tammikuu,feb:helmikuu,mar:maaliskuu,apr:huhtikuu,jun:kesäkuu,jul:heinäkuu,aug:elokuu,sep:syyskuu,'.
95 'oct:lokakuu,nov:marraskuu,dec:joulukuu,sept:syyskuu';
96 */
97 $weekds = array(
98 'monday' => 'maanantai',
99 'tuesday' => 'tiistai',
100 'wednesday' => 'keskiviikko',
101 'thursay' => 'torstai',
102 'friday' => 'perjantai',
103 'saturday' => 'lauantai',
104 'sunday' => 'sunnuntai',
105 'mon' => 'ma',
106 'tue' => 'ti',
107 'tues' => 'ti',
108 'wed' => 'ke',
109 'wednes' => 'ke',
110 'thu' => 'to',
111 'thur' => 'to',
112 'thurs' => 'to',
113 'fri' => 'pe',
114 'sat' => 'la',
115 'sun' => 'su',
116 'next' => 'seuraava',
117 'tomorrow' => 'huomenna',
118 'ago' => 'sitten',
119 'seconds' => 'sekuntia',
120 'second' => 'sekunti',
121 'secs' => 's',
122 'sec' => 's',
123 'minutes' => 'minuuttia',
124 'minute' => 'minuutti',
125 'mins' => 'min',
126 'min' => 'min',
127 'days' => 'päivää',
128 'day' => 'päivä',
129 'hours' => 'tuntia',
130 'hour' => 'tunti',
131 'weeks' => 'viikkoa',
132 'week' => 'viikko',
133 'fortnights' => 'tuplaviikkoa',
134 'fortnight' => 'tuplaviikko',
135 'months' => 'kuukautta',
136 'month' => 'kuukausi',
137 'years' => 'vuotta',
138 'year' => 'vuosi',
139 'infinite' => 'ikuisesti',
140 'indefinite' => 'ikuisesti'
141 );
142
143 $final = '';
144 $tokens = explode ( ' ', $str);
145 foreach( $tokens as $item ) {
146 if ( !is_numeric($item) ) {
147 if ( count ( explode( '-', $item ) ) == 3 && strlen($item) == 10 ) {
148 list( $yyyy, $mm, $dd ) = explode( '-', $item );
149 $final .= ' ' . $this->date( "{$yyyy}{$mm}{$dd}00000000");
150 continue;
151 }
152 if( isset( $weekds[$item] ) ) {
153 $final .= ' ' . $weekds[$item];
154 continue;
155 }
156 }
157
158 $final .= ' ' . $item;
159 }
160 return '<span class="blockexpiry" title="' . htmlspecialchars($str). '">”' . trim( $final ) . '”</span>';
161 }
162
163 }
164
165 ?>