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