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