Merge "Revert "Revert "Show a "(blocked)" hint on Special:ListUsers/ActiveUsers"""
[lhc/web/wiklou.git] / languages / classes / LanguageFi.php
1 <?php
2 /**
3 * Finnish (Suomi) specific code.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
19 *
20 * @file
21 * @author Niklas Laxström
22 * @ingroup Language
23 */
24
25 /**
26 * Finnish (Suomi)
27 *
28 * @ingroup Language
29 */
30 class LanguageFi extends Language {
31
32 /**
33 * Convert from the nominative form of a noun to some other case
34 * Invoked with {{grammar:case|word}}
35 *
36 * @param $word string
37 * @param $case string
38 * @return string
39 */
40 function convertGrammar( $word, $case ) {
41 global $wgGrammarForms;
42 if ( isset( $wgGrammarForms['fi'][$case][$word] ) ) {
43 return $wgGrammarForms['fi'][$case][$word];
44 }
45
46 # These rules are not perfect, but they are currently only used for site names so it doesn't
47 # matter if they are wrong sometimes. Just add a special case for your site name if necessary.
48
49 # wovel harmony flag
50 $aou = preg_match( '/[aou][^äöy]*$/i', $word );
51
52 # The flag should be false for compounds where the last word has only neutral vowels (e/i).
53 # The general case cannot be handled without a dictionary, but there's at least one notable
54 # special case we should check for:
55
56 if ( preg_match( '/wiki$/i', $word ) )
57 $aou = false;
58
59 # append i after final consonant
60 if ( preg_match( '/[bcdfghjklmnpqrstvwxz]$/i', $word ) )
61 $word .= 'i';
62
63 switch ( $case ) {
64 case 'genitive':
65 $word .= 'n';
66 break;
67 case 'elative':
68 $word .= ( $aou ? 'sta' : 'stä' );
69 break;
70 case 'partitive':
71 $word .= ( $aou ? 'a' : 'ä' );
72 break;
73 case 'illative':
74 # Double the last letter and add 'n'
75 # mb_substr has a compatibility function in GlobalFunctions.php
76 $word = $word . mb_substr( $word, -1 ) . 'n';
77 break;
78 case 'inessive':
79 $word .= ( $aou ? 'ssa' : 'ssä' );
80 break;
81 }
82 return $word;
83 }
84
85 /**
86 * @param $str string
87 * @param $forContent bool
88 * @return string
89 */
90 function translateBlockExpiry( $str, $forContent = false ) {
91 /*
92 'ago', 'now', 'today', 'this', 'next',
93 'first', 'third', 'fourth', 'fifth', 'sixth', 'seventh', 'eighth', 'ninth', 'tenth', 'eleventh', 'twelfth',
94 'tomorrow', 'yesterday'
95
96 $months = 'january:tammikuu,february:helmikuu,march:maaliskuu,april:huhtikuu,may:toukokuu,june:kesäkuu,' .
97 'july:heinäkuu,august:elokuu,september:syyskuu,october:lokakuu,november:marraskuu,december:joulukuu,' .
98 'jan:tammikuu,feb:helmikuu,mar:maaliskuu,apr:huhtikuu,jun:kesäkuu,jul:heinäkuu,aug:elokuu,sep:syyskuu,'.
99 'oct:lokakuu,nov:marraskuu,dec:joulukuu,sept:syyskuu';
100 */
101 $weekds = array(
102 'monday' => 'maanantai',
103 'tuesday' => 'tiistai',
104 'wednesday' => 'keskiviikko',
105 'thursday' => 'torstai',
106 'friday' => 'perjantai',
107 'saturday' => 'lauantai',
108 'sunday' => 'sunnuntai',
109 'mon' => 'ma',
110 'tue' => 'ti',
111 'tues' => 'ti',
112 'wed' => 'ke',
113 'wednes' => 'ke',
114 'thu' => 'to',
115 'thur' => 'to',
116 'thurs' => 'to',
117 'fri' => 'pe',
118 'sat' => 'la',
119 'sun' => 'su',
120 'next' => 'seuraava',
121 'tomorrow' => 'huomenna',
122 'ago' => 'sitten',
123 'seconds' => 'sekuntia',
124 'second' => 'sekunti',
125 'secs' => 's',
126 'sec' => 's',
127 'minutes' => 'minuuttia',
128 'minute' => 'minuutti',
129 'mins' => 'min',
130 'min' => 'min',
131 'days' => 'päivää',
132 'day' => 'päivä',
133 'hours' => 'tuntia',
134 'hour' => 'tunti',
135 'weeks' => 'viikkoa',
136 'week' => 'viikko',
137 'fortnights' => 'tuplaviikkoa',
138 'fortnight' => 'tuplaviikko',
139 'months' => 'kuukautta',
140 'month' => 'kuukausi',
141 'years' => 'vuotta',
142 'year' => 'vuosi',
143 'infinite' => 'ikuisesti',
144 'indefinite' => 'ikuisesti'
145 );
146
147 $final = '';
148 $tokens = explode ( ' ', $str );
149 foreach ( $tokens as $item ) {
150 if ( !is_numeric( $item ) ) {
151 if ( count ( explode( '-', $item ) ) == 3 && strlen( $item ) == 10 ) {
152 list( $yyyy, $mm, $dd ) = explode( '-', $item );
153 $final .= ' ' . $this->date( "{$yyyy}{$mm}{$dd}000000" );
154 continue;
155 }
156 if ( isset( $weekds[$item] ) ) {
157 $final .= ' ' . $weekds[$item];
158 continue;
159 }
160 }
161
162 $final .= ' ' . $item;
163 }
164
165 return htmlspecialchars( trim( $final ) );
166 }
167 }