8fc254996d18d19283d24b116ec9f5ee522df3d2
[lhc/web/wiklou.git] / languages / classes / 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
32 # wovel harmony flag
33 $aou = preg_match( '/[aou][^äöy]*$/i', $word );
34
35 # append i after final consonant
36 if ( preg_match( '/[bcdfghjklmnpqrstvwxz]$/i', $word ) )
37 $word .= 'i';
38
39 switch ( $case ) {
40 case 'genitive':
41 $word .= 'n';
42 break;
43 case 'elative':
44 $word .= ($aou ? 'sta' : 'stä');
45 break;
46 case 'partitive':
47 $word .= ($aou ? 'a' : 'ä');
48 break;
49 case 'illative':
50 # Double the last letter and add 'n'
51 # mb_substr has a compatibility function in GlobalFunctions.php
52 $word = $word . mb_substr($word, -1) . 'n';
53 break;
54 case 'inessive':
55 $word .= ($aou ? 'ssa' : 'ssä');
56 break;
57 }
58 return $word;
59 }
60
61 function translateBlockExpiry( $str ) {
62 /*
63 'ago', 'now', 'today', 'this', 'next',
64 'first', 'third', 'fourth', 'fifth', 'sixth', 'seventh', 'eighth', 'ninth', 'tenth', 'eleventh', 'twelfth',
65 'tomorrow', 'yesterday'
66
67 $months = 'january:tammikuu,february:helmikuu,march:maaliskuu,april:huhtikuu,may:toukokuu,june:kesäkuu,' .
68 'july:heinäkuu,august:elokuu,september:syyskuu,october:lokakuu,november:marraskuu,december:joulukuu,' .
69 'jan:tammikuu,feb:helmikuu,mar:maaliskuu,apr:huhtikuu,jun:kesäkuu,jul:heinäkuu,aug:elokuu,sep:syyskuu,'.
70 'oct:lokakuu,nov:marraskuu,dec:joulukuu,sept:syyskuu';
71 */
72 $weekds = array(
73 'monday' => 'maanantai',
74 'tuesday' => 'tiistai',
75 'wednesday' => 'keskiviikko',
76 'thursay' => 'torstai',
77 'friday' => 'perjantai',
78 'saturday' => 'lauantai',
79 'sunday' => 'sunnuntai',
80 'mon' => 'ma',
81 'tue' => 'ti',
82 'tues' => 'ti',
83 'wed' => 'ke',
84 'wednes' => 'ke',
85 'thu' => 'to',
86 'thur' => 'to',
87 'thurs' => 'to',
88 'fri' => 'pe',
89 'sat' => 'la',
90 'sun' => 'su',
91 'next' => 'seuraava',
92 'tomorrow' => 'huomenna',
93 'ago' => 'sitten',
94 'seconds' => 'sekuntia',
95 'second' => 'sekunti',
96 'secs' => 's',
97 'sec' => 's',
98 'minutes' => 'minuuttia',
99 'minute' => 'minuutti',
100 'mins' => 'min',
101 'min' => 'min',
102 'days' => 'päivää',
103 'day' => 'päivä',
104 'hours' => 'tuntia',
105 'hour' => 'tunti',
106 'weeks' => 'viikkoa',
107 'week' => 'viikko',
108 'fortnights' => 'tuplaviikkoa',
109 'fortnight' => 'tuplaviikko',
110 'months' => 'kuukautta',
111 'month' => 'kuukausi',
112 'years' => 'vuotta',
113 'year' => 'vuosi',
114 'infinite' => 'ikuisesti',
115 'indefinite' => 'ikuisesti'
116 );
117
118 $final = '';
119 $tokens = explode ( ' ', $str);
120 foreach( $tokens as $item ) {
121 if ( !is_numeric($item) ) {
122 if ( count ( explode( '-', $item ) ) == 3 && strlen($item) == 10 ) {
123 list( $yyyy, $mm, $dd ) = explode( '-', $item );
124 $final .= ' ' . $this->date( "{$yyyy}{$mm}{$dd}00000000");
125 continue;
126 }
127 if( isset( $weekds[$item] ) ) {
128 $final .= ' ' . $weekds[$item];
129 continue;
130 }
131 }
132
133 $final .= ' ' . $item;
134 }
135 return '<span class="blockexpiry" title="' . htmlspecialchars($str). '">”' . trim( $final ) . '”</span>';
136 }
137
138 }
139
140 ?>