Merge "Added release notes for 'ContentHandler::runLegacyHooks' removal"
[mediawiki.git] / languages / classes / LanguageFi.php
blob338853683cde9fbecc80f0cd2af387a8aa4b033f
1 <?php
2 /**
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
20 * @file
21 * @author Niklas Laxström
22 * @ingroup Language
25 /**
26 * Finnish (Suomi)
28 * @ingroup Language
30 class LanguageFi extends Language {
31 /**
32 * Convert from the nominative form of a noun to some other case
33 * Invoked with {{grammar:case|word}}
35 * @param string $word
36 * @param string $case
37 * @return string
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.
48 # wovel harmony flag
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 ) ) {
56 $aou = false;
59 # append i after final consonant
60 if ( preg_match( '/[bcdfghjklmnpqrstvwxz]$/i', $word ) ) {
61 $word .= 'i';
64 switch ( $case ) {
65 case 'genitive':
66 $word .= 'n';
67 break;
68 case 'elative':
69 $word .= ( $aou ? 'sta' : 'stä' );
70 break;
71 case 'partitive':
72 $word .= ( $aou ? 'a' : 'ä' );
73 break;
74 case 'illative':
75 # Double the last letter and add 'n'
76 $word = $word . mb_substr( $word, -1 ) . 'n';
77 break;
78 case 'inessive':
79 $word .= ( $aou ? 'ssa' : 'ssä' );
80 break;
82 return $word;
85 /**
86 * @param string $str
87 * @param User $user User object to use timezone from or null for $wgUser
88 * @return string
90 function translateBlockExpiry( $str, User $user = null ) {
92 'ago', 'now', 'today', 'this', 'next',
93 'first', 'third', 'fourth', 'fifth', 'sixth', 'seventh', 'eighth', 'ninth',
94 'tenth', 'eleventh', 'twelfth',
95 'tomorrow', 'yesterday'
97 $months = 'january:tammikuu,february:helmikuu,march:maaliskuu,april:huhtikuu,' .
98 'may:toukokuu,june:kesäkuu,july:heinäkuu,august:elokuu,september:syyskuu,' .
99 'october:lokakuu,november:marraskuu,december:joulukuu,' .
100 'jan:tammikuu,feb:helmikuu,mar:maaliskuu,apr:huhtikuu,jun:kesäkuu,' .
101 'jul:heinäkuu,aug:elokuu,sep:syyskuu,oct:lokakuu,nov:marraskuu,' .
102 dec:joulukuu,sept:syyskuu';
104 $weekds = [
105 'monday' => 'maanantai',
106 'tuesday' => 'tiistai',
107 'wednesday' => 'keskiviikko',
108 'thursday' => 'torstai',
109 'friday' => 'perjantai',
110 'saturday' => 'lauantai',
111 'sunday' => 'sunnuntai',
112 'mon' => 'ma',
113 'tue' => 'ti',
114 'tues' => 'ti',
115 'wed' => 'ke',
116 'wednes' => 'ke',
117 'thu' => 'to',
118 'thur' => 'to',
119 'thurs' => 'to',
120 'fri' => 'pe',
121 'sat' => 'la',
122 'sun' => 'su',
123 'next' => 'seuraava',
124 'tomorrow' => 'huomenna',
125 'ago' => 'sitten',
126 'seconds' => 'sekuntia',
127 'second' => 'sekunti',
128 'secs' => 's',
129 'sec' => 's',
130 'minutes' => 'minuuttia',
131 'minute' => 'minuutti',
132 'mins' => 'min',
133 'min' => 'min',
134 'days' => 'päivää',
135 'day' => 'päivä',
136 'hours' => 'tuntia',
137 'hour' => 'tunti',
138 'weeks' => 'viikkoa',
139 'week' => 'viikko',
140 'fortnights' => 'tuplaviikkoa',
141 'fortnight' => 'tuplaviikko',
142 'months' => 'kuukautta',
143 'month' => 'kuukausi',
144 'years' => 'vuotta',
145 'year' => 'vuosi',
146 'infinite' => 'ikuisesti',
147 'indefinite' => 'ikuisesti'
150 $final = '';
151 $tokens = explode( ' ', $str );
152 foreach ( $tokens as $item ) {
153 if ( !is_numeric( $item ) ) {
154 if ( count( explode( '-', $item ) ) == 3 && strlen( $item ) == 10 ) {
155 list( $yyyy, $mm, $dd ) = explode( '-', $item );
156 $final .= ' ' . $this->date( "{$yyyy}{$mm}{$dd}000000" );
157 continue;
159 if ( isset( $weekds[$item] ) ) {
160 $final .= ' ' . $weekds[$item];
161 continue;
165 $final .= ' ' . $item;
168 return htmlspecialchars( trim( $final ) );