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