* Entries in $wgGrammarForms should apply to one language only
[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 # Internationalisation code
73 #--------------------------------------------------------------------------
74
75 class LanguageFi extends LanguageUtf8 {
76 function LanguageFi() {
77 global $wgNamespaceNamesFi, $wgMetaNamespace;
78 LanguageUtf8::LanguageUtf8();
79 $wgNamespaceNamesFi[NS_PROJECT_TALK] = 'Keskustelu_' . $this->convertGrammar( $wgMetaNamespace, 'elative' );
80 }
81
82 function getBookstoreList () {
83 global $wgBookstoreListFi ;
84 return $wgBookstoreListFi ;
85 }
86
87 function getNamespaces() {
88 global $wgNamespaceNamesFi;
89 return $wgNamespaceNamesFi;
90 }
91
92 function getQuickbarSettings() {
93 global $wgQuickbarSettingsFi;
94 return $wgQuickbarSettingsFi;
95 }
96
97 function getSkinNames() {
98 global $wgSkinNamesFi;
99 return $wgSkinNamesFi;
100 }
101
102 function getDateFormats() {
103 global $wgDateFormatsFi;
104 return $wgDateFormatsFi;
105 }
106
107 /**
108 * See Language.php for documentation
109 */
110 function date( $ts, $adj = false, $format = true, $timecorrection = false ) {
111 if ( $adj ) { $ts = $this->userAdjust( $ts, $timecorrection ); }
112
113 $yyyy = substr( $ts, 0, 4 );
114 $mm = substr( $ts, 4, 2 );
115 $m = 0 + $mm;
116 $mmmm = $this->getMonthName( $mm ) . 'ta';
117 $dd = substr( $ts, 6, 2 );
118 $d = 0 + $dd;
119
120 $datePreference = $this->dateFormat($format);
121 switch( $datePreference ) {
122 case '3': return "$d.$m.$yyyy";
123 case MW_DATE_ISO: return "$yyyy-$mm-$dd";
124 default: return "$d. $mmmm $yyyy";
125 }
126 }
127
128 /**
129 * See Language.php for documentation
130 */
131 function time( $ts, $adj = false, $format = true, $timecorrection = false ) {
132 if ( $adj ) { $ts = $this->userAdjust( $ts, $timecorrection ); }
133
134 $hh = substr( $ts, 8, 2 );
135 $mm = substr( $ts, 10, 2 );
136 $ss = substr( $ts, 12, 2 );
137
138 $datePreference = $this->dateFormat($format);
139 switch( $datePreference ) {
140 case '2':
141 case MW_DATE_ISO: return "$hh:$mm:$ss";
142 default: return "$hh.$mm";
143 }
144 }
145
146 /**
147 * See Language.php for documentation
148 */
149 function timeanddate( $ts, $adj = false, $format = true, $timecorrection = false) {
150 $date = $this->date( $ts, $adj, $format, $timecorrection );
151 $time = $this->time( $ts, $adj, $format, $timecorrection );
152
153 $datePreference = $this->dateFormat($format);
154 switch( $datePreference ) {
155 case '3':
156 case MW_DATE_ISO: return "$date $time";
157 default: return "$date kello $time";
158 }
159 }
160
161 function getMessage( $key ) {
162 global $wgAllMessagesFi;
163 if( isset( $wgAllMessagesFi[$key] ) ) {
164 return $wgAllMessagesFi[$key];
165 } else {
166 return parent::getMessage( $key );
167 }
168 }
169
170 /**
171 * Finnish numeric formatting is 123 456,78.
172 */
173 function separatorTransformTable() {
174 return array(',' => "\xc2\xa0", '.' => ',' );
175 }
176
177 /**
178 * Avoid grouping whole numbers between 0 to 9999
179 */
180 function commafy($_) {
181 if (!preg_match('/^\d{1,4}$/',$_)) {
182 return strrev((string)preg_replace('/(\d{3})(?=\d)(?!\d*\.)/','$1,',strrev($_)));
183 } else {
184 return $_;
185 }
186 }
187
188 function linkTrail() {
189 return '/^([a-zäö]+)(.*)$/sDu';
190 }
191
192
193 # Convert from the nominative form of a noun to some other case
194 # Invoked with {{GRAMMAR:case|word}}
195 function convertGrammar( $word, $case ) {
196 global $wgGrammarForms;
197 if ( isset($wgGrammarForms['fi'][$case][$word]) ) {
198 return $wgGrammarForms['fi'][$case][$word];
199 }
200
201 # These rules are not perfect, but they are currently only used for site names so it doesn't
202 # matter if they are wrong sometimes. Just add a special case for your site name if necessary.
203 switch ( $case ) {
204 case 'genitive':
205 if ( $word == 'Wikisitaatit' ) {
206 $word = 'Wikisitaattien';
207 } else {
208 $word .= 'n';
209 }
210 break;
211 case 'elative':
212 if ( $word == 'Wikisitaatit' ) {
213 $word = 'Wikisitaateista';
214 } else {
215 if ( mb_substr($word, -1) == 'y' ) {
216 $word .= 'stä';
217 } else {
218 $word .= 'sta';
219 }
220 }
221 break;
222 case 'partitive':
223 if ( $word == 'Wikisitaatit' ) {
224 $word = 'Wikisitaatteja';
225 } else {
226 if ( mb_substr($word, -1) == 'y' ) {
227 $word .= 'ä';
228 } else {
229 $word .= 'a';
230 }
231 }
232 break;
233 case 'illative':
234 # Double the last letter and add 'n'
235 # mb_substr has a compatibility function in GlobalFunctions.php
236 if ( $word == 'Wikisitaatit' ) {
237 $word = 'Wikisitaatteihin';
238 } else {
239 $word = $word . mb_substr($word,-1) . 'n';
240 }
241 break;
242 case 'inessive':
243 if ( $word == 'Wikisitaatit' ) {
244 $word = 'Wikisitaateissa';
245 } else {
246 if ( mb_substr($word, -1) == 'y' ) {
247 $word .= 'ssä';
248 } else {
249 $word .= 'ssa';
250 }
251 }
252 break;
253
254 }
255 return $word;
256 }
257
258 function translateBlockExpiry( $str ) {
259 /*
260 'ago', 'now', 'today', 'this', 'next',
261 'first', 'third', 'fourth', 'fifth', 'sixth', 'seventh', 'eighth', 'ninth', 'tenth', 'eleventh', 'twelfth',
262 'tomorrow', 'yesterday'
263
264 $months = 'january:tammikuu,february:helmikuu,march:maaliskuu,april:huhtikuu,may:toukokuu,june:kesäkuu,' .
265 'july:heinäkuu,august:elokuu,september:syyskuu,october:lokakuu,november:marraskuu,december:joulukuu,' .
266 'jan:tammikuu,feb:helmikuu,mar:maaliskuu,apr:huhtikuu,jun:kesäkuu,jul:heinäkuu,aug:elokuu,sep:syyskuu,'.
267 'oct:lokakuu,nov:marraskuu,dec:joulukuu,sept:syyskuu';
268 */
269 $weekds = array(
270 'monday' => 'maanantai',
271 'tuesday' => 'tiistai',
272 'wednesday' => 'keskiviikko',
273 'thursay' => 'torstai',
274 'friday' => 'perjantai',
275 'saturday' => 'lauantai',
276 'sunday' => 'sunnuntai',
277 'mon' => 'ma',
278 'tue' => 'ti',
279 'tues' => 'ti',
280 'wed' => 'ke',
281 'wednes' => 'ke',
282 'thu' => 'to',
283 'thur' => 'to',
284 'thurs' => 'to',
285 'fri' => 'pe',
286 'sat' => 'la',
287 'sun' => 'su',
288 'next' => 'seuraava',
289 'tomorrow' => 'huomenna',
290 'ago' => 'sitten',
291 'seconds' => 'sekuntia',
292 'second' => 'sekunti',
293 'secs' => 's',
294 'sec' => 's',
295 'minutes' => 'minuuttia',
296 'minute' => 'minuutti',
297 'mins' => 'min',
298 'min' => 'min',
299 'days' => 'päivää',
300 'day' => 'päivä',
301 'hours' => 'tuntia',
302 'hour' => 'tunti',
303 'weeks' => 'viikkoa',
304 'week' => 'viikko',
305 'fortnights' => 'tuplaviikkoa',
306 'fortnight' => 'tuplaviikko',
307 'months' => 'kuukautta',
308 'month' => 'kuukausi',
309 'years' => 'vuotta',
310 'year' => 'vuosi',
311 'infinite' => 'ikuisesti',
312 'indefinite' => 'ikuisesti'
313 );
314
315 $final = '';
316 $tokens = explode ( ' ', $str);
317 foreach( $tokens as $item ) {
318 if ( !is_numeric($item) ) {
319 if ( count ( explode( '-', $item ) ) == 3 && strlen($item) == 10 ) {
320 list( $yyyy, $mm, $dd ) = explode( '-', $item );
321 $final .= ' ' . $this->date( "{$yyyy}{$mm}{$dd}00000000");
322 continue;
323 }
324 if( isset( $weekds[$item] ) ) {
325 $final .= ' ' . $weekds[$item];
326 continue;
327 }
328 }
329
330 $final .= ' ' . $item;
331 }
332 return '<span class="blockexpiry" title="' . htmlspecialchars($str). '">”' . trim( $final ) . '”</span>';
333 }
334
335 }
336
337 ?>