MediaWiki REL1_39
LanguageFi.php
Go to the documentation of this file.
1<?php
25
31class LanguageFi extends Language {
40 public function convertGrammar( $word, $case ) {
41 $grammarForms =
42 MediaWikiServices::getInstance()->getMainConfig()->get( MainConfigNames::GrammarForms );
43 if ( isset( $grammarForms['fi'][$case][$word] ) ) {
44 return $grammarForms['fi'][$case][$word];
45 }
46
47 # These rules don't cover the whole language.
48 # They are used only for site names.
49
50 # wovel harmony flag
51 $aou = preg_match( '/[aou][^äöy]*$/i', $word );
52
53 # The flag should be false for compounds where the last word has only neutral vowels (e/i).
54 # The general case cannot be handled without a dictionary, but there's at least one notable
55 # special case we should check for:
56
57 if ( preg_match( '/wiki$/i', $word ) ) {
58 $aou = false;
59 }
60
61 # append i after final consonant
62 if ( preg_match( '/[bcdfghjklmnpqrstvwxz]$/i', $word ) ) {
63 $word .= 'i';
64 }
65
66 switch ( $case ) {
67 case 'genitive':
68 $word .= 'n';
69 break;
70 case 'elative':
71 $word .= ( $aou ? 'sta' : 'stä' );
72 break;
73 case 'partitive':
74 $word .= ( $aou ? 'a' : 'ä' );
75 break;
76 case 'illative':
77 # Double the last letter and add 'n'
78 $word .= mb_substr( $word, -1 ) . 'n';
79 break;
80 case 'inessive':
81 $word .= ( $aou ? 'ssa' : 'ssä' );
82 break;
83 }
84 return $word;
85 }
86
93 public function translateBlockExpiry( $str, UserIdentity $user = null, $now = 0 ) {
94 /*
95 'ago', 'now', 'today', 'this', 'next',
96 'first', 'third', 'fourth', 'fifth', 'sixth', 'seventh', 'eighth', 'ninth',
97 'tenth', 'eleventh', 'twelfth',
98 'tomorrow', 'yesterday'
99
100 $months = 'january:tammikuu,february:helmikuu,march:maaliskuu,april:huhtikuu,' .
101 'may:toukokuu,june:kesäkuu,july:heinäkuu,august:elokuu,september:syyskuu,' .
102 'october:lokakuu,november:marraskuu,december:joulukuu,' .
103 'jan:tammikuu,feb:helmikuu,mar:maaliskuu,apr:huhtikuu,jun:kesäkuu,' .
104 'jul:heinäkuu,aug:elokuu,sep:syyskuu,oct:lokakuu,nov:marraskuu,' .
105 dec:joulukuu,sept:syyskuu';
106 */
107 $weekds = [
108 'monday' => 'maanantai',
109 'tuesday' => 'tiistai',
110 'wednesday' => 'keskiviikko',
111 'thursday' => 'torstai',
112 'friday' => 'perjantai',
113 'saturday' => 'lauantai',
114 'sunday' => 'sunnuntai',
115 'mon' => 'ma',
116 'tue' => 'ti',
117 'tues' => 'ti',
118 'wed' => 'ke',
119 'wednes' => 'ke',
120 'thu' => 'to',
121 'thur' => 'to',
122 'thurs' => 'to',
123 'fri' => 'pe',
124 'sat' => 'la',
125 'sun' => 'su',
126 'next' => 'seuraava',
127 'tomorrow' => 'huomenna',
128 'ago' => 'sitten',
129 'seconds' => 'sekuntia',
130 'second' => 'sekunti',
131 'secs' => 's',
132 'sec' => 's',
133 'minutes' => 'minuuttia',
134 'minute' => 'minuutti',
135 'mins' => 'min',
136 'min' => 'min',
137 'days' => 'päivää',
138 'day' => 'päivä',
139 'hours' => 'tuntia',
140 'hour' => 'tunti',
141 'weeks' => 'viikkoa',
142 'week' => 'viikko',
143 'fortnights' => 'tuplaviikkoa',
144 'fortnight' => 'tuplaviikko',
145 'months' => 'kuukautta',
146 'month' => 'kuukausi',
147 'years' => 'vuotta',
148 'year' => 'vuosi',
149 'infinite' => 'ikuinen',
150 'indefinite' => 'ikuinen',
151 'infinity' => 'ikuinen'
152 ];
153
154 $final = '';
155 $tokens = explode( ' ', $str );
156 foreach ( $tokens as $item ) {
157 if ( !is_numeric( $item ) ) {
158 if ( count( explode( '-', $item ) ) == 3 && strlen( $item ) == 10 ) {
159 list( $yyyy, $mm, $dd ) = explode( '-', $item );
160 $final .= ' ' . $this->date( "{$yyyy}{$mm}{$dd}000000" );
161 continue;
162 }
163 if ( isset( $weekds[$item] ) ) {
164 $final .= ' ' . $weekds[$item];
165 continue;
166 }
167 }
168
169 $final .= ' ' . $item;
170 }
171
172 return trim( $final );
173 }
174}
Finnish (Suomi)
convertGrammar( $word, $case)
Convert from the nominative form of a noun to some other case Invoked with {{grammar:case|word}}.
translateBlockExpiry( $str, UserIdentity $user=null, $now=0)
Base class for language-specific code.
Definition Language.php:53
date( $ts, $adj=false, $format=true, $timecorrection=false)
A class containing constants representing the names of configuration variables.
Service locator for MediaWiki core services.
Interface for objects representing user identity.