3 * Finnish (Suomi) specific code.
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.
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.
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
21 * @author Niklas Laxström
30 class LanguageFi
extends Language
{
32 * Convert from the nominative form of a noun to some other case
33 * Invoked with {{grammar:case|word}}
39 function convertGrammar( $word, $case ) {
40 global $wgGrammarForms;
41 if ( isset( $wgGrammarForms['fi'][$case][$word] ) ) {
42 return $wgGrammarForms['fi'][$case][$word];
45 # These rules don't cover the whole language.
46 # They are used only for site names.
49 $aou = preg_match( '/[aou][^äöy]*$/i', $word );
51 # The flag should be false for compounds where the last word has only neutral vowels (e/i).
52 # The general case cannot be handled without a dictionary, but there's at least one notable
53 # special case we should check for:
55 if ( preg_match( '/wiki$/i', $word ) ) {
59 # append i after final consonant
60 if ( preg_match( '/[bcdfghjklmnpqrstvwxz]$/i', $word ) ) {
69 $word .= ( $aou ?
'sta' : 'stä' );
72 $word .= ( $aou ?
'a' : 'ä' );
75 # Double the last letter and add 'n'
76 $word = $word . mb_substr( $word, -1 ) . 'n';
79 $word .= ( $aou ?
'ssa' : 'ssä' );
87 * @param User $user User object to use timezone from or null for $wgUser
88 * @param int $now Current timestamp, for formatting relative block durations
91 function translateBlockExpiry( $str, User
$user = null, $now = 0 ) {
93 'ago', 'now', 'today', 'this', 'next',
94 'first', 'third', 'fourth', 'fifth', 'sixth', 'seventh', 'eighth', 'ninth',
95 'tenth', 'eleventh', 'twelfth',
96 'tomorrow', 'yesterday'
98 $months = 'january:tammikuu,february:helmikuu,march:maaliskuu,april:huhtikuu,' .
99 'may:toukokuu,june:kesäkuu,july:heinäkuu,august:elokuu,september:syyskuu,' .
100 'october:lokakuu,november:marraskuu,december:joulukuu,' .
101 'jan:tammikuu,feb:helmikuu,mar:maaliskuu,apr:huhtikuu,jun:kesäkuu,' .
102 'jul:heinäkuu,aug:elokuu,sep:syyskuu,oct:lokakuu,nov:marraskuu,' .
103 dec:joulukuu,sept:syyskuu';
106 'monday' => 'maanantai',
107 'tuesday' => 'tiistai',
108 'wednesday' => 'keskiviikko',
109 'thursday' => 'torstai',
110 'friday' => 'perjantai',
111 'saturday' => 'lauantai',
112 'sunday' => 'sunnuntai',
124 'next' => 'seuraava',
125 'tomorrow' => 'huomenna',
127 'seconds' => 'sekuntia',
128 'second' => 'sekunti',
131 'minutes' => 'minuuttia',
132 'minute' => 'minuutti',
139 'weeks' => 'viikkoa',
141 'fortnights' => 'tuplaviikkoa',
142 'fortnight' => 'tuplaviikko',
143 'months' => 'kuukautta',
144 'month' => 'kuukausi',
147 'infinite' => 'ikuisesti',
148 'indefinite' => 'ikuisesti'
152 $tokens = explode( ' ', $str );
153 foreach ( $tokens as $item ) {
154 if ( !is_numeric( $item ) ) {
155 if ( count( explode( '-', $item ) ) == 3 && strlen( $item ) == 10 ) {
156 list( $yyyy, $mm, $dd ) = explode( '-', $item );
157 $final .= ' ' . $this->date( "{$yyyy}{$mm}{$dd}000000" );
160 if ( isset( $weekds[$item] ) ) {
161 $final .= ' ' . $weekds[$item];
166 $final .= ' ' . $item;
169 return htmlspecialchars( trim( $final ) );