* Cleaned up formatNum usage in langfiles
[lhc/web/wiklou.git] / languages / LanguageFi.php
1 <?php
2 /** Finnish (Suomi)
3 *
4 * @package MediaWiki
5 * @subpackage Language
6 */
7
8 require_once( 'LanguageUtf8.php' );
9
10 # Revised 2005-12-24 for MediaWiki 1.6dev -- Nikerabbit
11
12 /* private */ $wgNamespaceNamesFi = array(
13 NS_MEDIA => 'Media',
14 NS_SPECIAL => 'Toiminnot',
15 NS_MAIN => '',
16 NS_TALK => 'Keskustelu',
17 NS_USER => 'Käyttäjä',
18 NS_USER_TALK => 'Keskustelu_käyttäjästä',
19 NS_PROJECT => $wgMetaNamespace,
20 NS_PROJECT_TALK => FALSE, # Set in constructor
21 NS_IMAGE => 'Kuva',
22 NS_IMAGE_TALK => 'Keskustelu_kuvasta',
23 NS_MEDIAWIKI => 'MediaWiki',
24 NS_MEDIAWIKI_TALK => 'MediaWiki_talk',
25 NS_TEMPLATE => 'Malline',
26 NS_TEMPLATE_TALK => 'Keskustelu_mallineesta',
27 NS_HELP => 'Ohje',
28 NS_HELP_TALK => 'Keskustelu_ohjeesta',
29 NS_CATEGORY => 'Luokka',
30 NS_CATEGORY_TALK => 'Keskustelu_luokasta'
31
32 ) + $wgNamespaceNamesEn;
33
34 /* private */ $wgQuickbarSettingsFi = array(
35 'Ei mitään', 'Tekstin mukana, vasen', 'Tekstin mukana, oikea', 'Pysyen vasemmalla'
36 );
37
38 /* private */ $wgSkinNamesFi = array(
39 'standard' => 'Perus',
40 'cologneblue' => 'Kölnin sininen',
41 'myskin' => 'Oma tyylisivu'
42 ) + $wgSkinNamesEn;
43
44 /* private */ $wgDateFormatsFi = array(
45 MW_DATE_DEFAULT => 'Ei valintaa',
46 1 => '15. tammikuuta 2001 kello 16.12',
47 2 => '15. tammikuuta 2001 kello 16:12:34',
48 3 => '15.1.2001 16.12',
49 MW_DATE_ISO => '2001-01-15 16:12:34'
50 );
51
52 /* private */ $wgBookstoreListFi = array(
53 'Akateeminen kirjakauppa' => 'http://www.akateeminen.com/search/tuotetieto.asp?tuotenro=$1',
54 'Bookplus' => 'http://www.bookplus.fi/product.php?isbn=$1',
55 'Helsingin yliopiston kirjasto' => 'http://pandora.lib.hel.fi/cgi-bin/mhask/monihask.py?volname=&author=&keyword=&ident=$1&submit=Hae&engine_helka=ON',
56 'Pääkaupunkiseudun kirjastot' => 'http://www.helmet.fi/search*fin/i?SEARCH=$1',
57 'Tampereen seudun kirjastot' => 'http://pandora.lib.hel.fi/cgi-bin/mhask/monihask.py?volname=&author=&keyword=&ident=$1-1&lang=kaikki&mat_type=kaikki&submit=Hae&engine_tampere=ON'
58 ) + $wgBookstoreListEn;
59
60 # Current practices (may be changed if not good ones)
61 # Refer namespaces with the English name or 'Project' in case of project namespace
62 # Avoid any hard coded references to any particular subject which may not apply everywhere, e.g. artikkeli, wikipedia
63 # Don't use participial phrases (lauseenkastikkeita) incorrectly
64 # Avoid unnecessary parenthesis, quotes and html code
65 #
66
67 if (!$wgCachedMessageArrays) {
68 require_once('MessagesFi.php');
69 }
70
71 #-------------------------------------------------------------------
72 # Translated messages
73 #-------------------------------------------------------------------
74
75
76
77 #--------------------------------------------------------------------------
78 # Internationalisation code
79 #--------------------------------------------------------------------------
80
81 class LanguageFi extends LanguageUtf8 {
82 function LanguageFi() {
83 global $wgNamespaceNamesFi, $wgMetaNamespace;
84 LanguageUtf8::LanguageUtf8();
85 $wgNamespaceNamesFi[NS_PROJECT_TALK] = 'Keskustelu_' . $this->convertGrammar( $wgMetaNamespace, 'elative' );
86 }
87
88 function getBookstoreList () {
89 global $wgBookstoreListFi ;
90 return $wgBookstoreListFi ;
91 }
92
93 function getNamespaces() {
94 global $wgNamespaceNamesFi;
95 return $wgNamespaceNamesFi;
96 }
97
98 function getQuickbarSettings() {
99 global $wgQuickbarSettingsFi;
100 return $wgQuickbarSettingsFi;
101 }
102
103 function getSkinNames() {
104 global $wgSkinNamesFi;
105 return $wgSkinNamesFi;
106 }
107
108 function getDateFormats() {
109 global $wgDateFormatsFi;
110 return $wgDateFormatsFi;
111 }
112
113 /**
114 * See Language.php for documentation
115 */
116 function date( $ts, $adj = false, $format = true, $timecorrection = false ) {
117 if ( $adj ) { $ts = $this->userAdjust( $ts, $timecorrection ); }
118
119 $yyyy = substr( $ts, 0, 4 );
120 $mm = substr( $ts, 4, 2 );
121 $m = 0 + $mm;
122 $mmmm = $this->getMonthName( $mm ) . 'ta';
123 $dd = substr( $ts, 6, 2 );
124 $d = 0 + $dd;
125
126 $datePreference = $this->dateFormat($format);
127 switch( $datePreference ) {
128 case '3': return "$d.$m.$yyyy";
129 case MW_DATE_ISO: return "$yyyy-$mm-$dd";
130 default: return "$d. $mmmm $yyyy";
131 }
132 }
133
134 /**
135 * See Language.php for documentation
136 */
137 function time( $ts, $adj = false, $format = true, $timecorrection = false ) {
138 if ( $adj ) { $ts = $this->userAdjust( $ts, $timecorrection ); }
139
140 $hh = substr( $ts, 8, 2 );
141 $mm = substr( $ts, 10, 2 );
142 $ss = substr( $ts, 12, 2 );
143
144 $datePreference = $this->dateFormat($format);
145 switch( $datePreference ) {
146 case '2':
147 case MW_DATE_ISO: return "$hh:$mm:$ss";
148 default: return "$hh.$mm";
149 }
150 }
151
152 /**
153 * See Language.php for documentation
154 */
155 function timeanddate( $ts, $adj = false, $format = true, $timecorrection = false) {
156 $date = $this->date( $ts, $adj, $format, $timecorrection );
157 $time = $this->time( $ts, $adj, $format, $timecorrection );
158
159 $datePreference = $this->dateFormat($format);
160 switch( $datePreference ) {
161 case '3':
162 case MW_DATE_ISO: return "$date $time";
163 default: return "$date kello $time";
164 }
165 }
166
167 function getMessage( $key ) {
168 global $wgAllMessagesFi;
169 if( isset( $wgAllMessagesFi[$key] ) ) {
170 return $wgAllMessagesFi[$key];
171 } else {
172 return parent::getMessage( $key );
173 }
174 }
175
176 /**
177 * Finnish numeric formatting is 123 456,78.
178 */
179 function separatorTransformTable() {
180 return array(',' => "\xc2\xa0", '.' => ',' );
181 }
182
183 /**
184 * Avoid grouping whole numbers between 0 to 9999
185 */
186 function commafy($_) {
187 if (!preg_match('/^\d{1,4}$/',$_)) {
188 return strrev((string)preg_replace('/(\d{3})(?=\d)(?!\d*\.)/','$1,',strrev($_)));
189 } else {
190 return $_;
191 }
192 }
193
194 # Convert from the nominative form of a noun to some other case
195 # Invoked with {{GRAMMAR:case|word}}
196 function convertGrammar( $word, $case ) {
197 # These rules are not perfect, but they are currently only used for site names so it doesn't
198 # matter if they are wrong sometimes. Just add a special case for your site name if necessary.
199 switch ( $case ) {
200 case 'genitive':
201 if ( $word == 'Wikisitaatit' ) {
202 $word = 'Wikisitaattien';
203 } else {
204 $word .= 'n';
205 }
206 break;
207 case 'elative':
208 if ( $word == 'Wikisitaatit' ) {
209 $word = 'Wikisitaateista';
210 } else {
211 if ( mb_substr($word, -1) == 'y' ) {
212 $word .= 'stä';
213 } else {
214 $word .= 'sta';
215 }
216 }
217 break;
218 case 'partitive':
219 if ( $word == 'Wikisitaatit' ) {
220 $word = 'Wikisitaatteja';
221 } else {
222 if ( mb_substr($word, -1) == 'y' ) {
223 $word .= 'ä';
224 } else {
225 $word .= 'a';
226 }
227 }
228 break;
229 case 'illative':
230 # Double the last letter and add 'n'
231 # mb_substr has a compatibility function in GlobalFunctions.php
232 if ( $word == 'Wikisitaatit' ) {
233 $word = 'Wikisitaatteihin';
234 } else {
235 $word = $word . mb_substr($word,-1) . 'n';
236 }
237 break;
238 case 'inessive':
239 if ( $word == 'Wikisitaatit' ) {
240 $word = 'Wikisitaateissa';
241 } else {
242 if ( mb_substr($word, -1) == 'y' ) {
243 $word .= 'ssä';
244 } else {
245 $word .= 'ssa';
246 }
247 }
248 break;
249
250 }
251 return $word;
252 }
253
254 function translateBlockExpiry( $str ) {
255 /*
256 'ago', 'now', 'today', 'this', 'next',
257 'first', 'third', 'fourth', 'fifth', 'sixth', 'seventh', 'eighth', 'ninth', 'tenth', 'eleventh', 'twelfth',
258 'tomorrow', 'yesterday'
259
260 $months = 'january:tammikuu,february:helmikuu,march:maaliskuu,april:huhtikuu,may:toukokuu,june:kesäkuu,' .
261 'july:heinäkuu,august:elokuu,september:syyskuu,october:lokakuu,november:marraskuu,december:joulukuu,' .
262 'jan:tammikuu,feb:helmikuu,mar:maaliskuu,apr:huhtikuu,jun:kesäkuu,jul:heinäkuu,aug:elokuu,sep:syyskuu,'.
263 'oct:lokakuu,nov:marraskuu,dec:joulukuu,sept:syyskuu';
264 */
265 $weekds = array(
266 'monday' => 'maanantai',
267 'tuesday' => 'tiistai',
268 'wednesday' => 'keskiviikko',
269 'thursay' => 'torstai',
270 'friday' => 'perjantai',
271 'saturday' => 'lauantai',
272 'sunday' => 'sunnuntai',
273 'mon' => 'ma',
274 'tue' => 'ti',
275 'tues' => 'ti',
276 'wed' => 'ke',
277 'wednes' => 'ke',
278 'thu' => 'to',
279 'thur' => 'to',
280 'thurs' => 'to',
281 'fri' => 'pe',
282 'sat' => 'la',
283 'sun' => 'su',
284 'next' => 'seuraava',
285 'tomorrow' => 'huomenna',
286 'ago' => 'sitten',
287 'seconds' => 'sekuntia',
288 'second' => 'sekunti',
289 'secs' => 's',
290 'sec' => 's',
291 'minutes' => 'minuuttia',
292 'minute' => 'minuutti',
293 'mins' => 'min',
294 'min' => 'min',
295 'days' => 'päivää',
296 'day' => 'päivä',
297 'hours' => 'tuntia',
298 'hour' => 'tunti',
299 'weeks' => 'viikkoa',
300 'week' => 'viikko',
301 'fortnights' => 'tuplaviikkoa',
302 'fortnight' => 'tuplaviikko',
303 'months' => 'kuukautta',
304 'month' => 'kuukausi',
305 'years' => 'vuotta',
306 'year' => 'vuosi',
307 'infinite' => 'ikuisesti',
308 'indefinite' => 'ikuisesti'
309 );
310
311 $final = '';
312 $tokens = explode ( ' ', $str);
313 foreach( $tokens as $item ) {
314 if ( !is_numeric($item) ) {
315 if ( count ( explode( '-', $item ) ) == 3 && strlen($item) == 10 ) {
316 list( $yyyy, $mm, $dd ) = explode( '-', $item );
317 $final .= ' ' . $this->date( "{$yyyy}{$mm}{$dd}00000000");
318 continue;
319 }
320 if( isset( $weekds[$item] ) ) {
321 $final .= ' ' . $weekds[$item];
322 continue;
323 }
324 }
325
326 $final .= ' ' . $item;
327 }
328 return '<span class="blockexpiry" title="' . htmlspecialchars($str). '">”' . trim( $final ) . '”</span>';
329 }
330 }
331
332 ?>