MediaWiki master
LanguageFi.php
Go to the documentation of this file.
1<?php
26
32class LanguageFi extends Language {
33 public function convertGrammar( $word, $case ) {
34 $grammarForms =
35 MediaWikiServices::getInstance()->getMainConfig()->get( MainConfigNames::GrammarForms );
36 if ( isset( $grammarForms['fi'][$case][$word] ) ) {
37 return $grammarForms['fi'][$case][$word];
38 }
39
40 # These rules don't cover the whole language.
41 # They are used only for site names.
42
43 # vowel harmony flag
44 $aou = preg_match( '/[aou][^äöy]*$/i', $word );
45
46 # The flag should be false for compounds where the last word has only neutral vowels (e/i).
47 # The general case cannot be handled without a dictionary, but there's at least one notable
48 # special case we should check for:
49
50 if ( preg_match( '/wiki$/i', $word ) ) {
51 $aou = false;
52 }
53
54 # append i after final consonant
55 if ( preg_match( '/[bcdfghjklmnpqrstvwxz]$/i', $word ) ) {
56 $word .= 'i';
57 }
58
59 switch ( $case ) {
60 case 'genitive':
61 $word .= 'n';
62 break;
63 case 'elative':
64 $word .= ( $aou ? 'sta' : 'stä' );
65 break;
66 case 'partitive':
67 $word .= ( $aou ? 'a' : 'ä' );
68 break;
69 case 'illative':
70 # Double the last letter and add 'n'
71 $word .= mb_substr( $word, -1 ) . 'n';
72 break;
73 case 'inessive':
74 $word .= ( $aou ? 'ssa' : 'ssä' );
75 break;
76 }
77 return $word;
78 }
79
86 public function translateBlockExpiry( $str, ?UserIdentity $user = null, $now = 0 ) {
87 /*
88 'ago', 'now', 'today', 'this', 'next',
89 'first', 'third', 'fourth', 'fifth', 'sixth', 'seventh', 'eighth', 'ninth',
90 'tenth', 'eleventh', 'twelfth',
91 'tomorrow', 'yesterday'
92
93 $months = 'january:tammikuu,february:helmikuu,march:maaliskuu,april:huhtikuu,' .
94 'may:toukokuu,june:kesäkuu,july:heinäkuu,august:elokuu,september:syyskuu,' .
95 'october:lokakuu,november:marraskuu,december:joulukuu,' .
96 'jan:tammikuu,feb:helmikuu,mar:maaliskuu,apr:huhtikuu,jun:kesäkuu,' .
97 'jul:heinäkuu,aug:elokuu,sep:syyskuu,oct:lokakuu,nov:marraskuu,' .
98 dec:joulukuu,sept:syyskuu';
99 */
100 $weekds = [
101 'monday' => 'maanantai',
102 'tuesday' => 'tiistai',
103 'wednesday' => 'keskiviikko',
104 'thursday' => 'torstai',
105 'friday' => 'perjantai',
106 'saturday' => 'lauantai',
107 'sunday' => 'sunnuntai',
108 'mon' => 'ma',
109 'tue' => 'ti',
110 'tues' => 'ti',
111 'wed' => 'ke',
112 'wednes' => 'ke',
113 'thu' => 'to',
114 'thur' => 'to',
115 'thurs' => 'to',
116 'fri' => 'pe',
117 'sat' => 'la',
118 'sun' => 'su',
119 'next' => 'seuraava',
120 'tomorrow' => 'huomenna',
121 'ago' => 'sitten',
122 'seconds' => 'sekuntia',
123 'second' => 'sekunti',
124 'secs' => 's',
125 'sec' => 's',
126 'minutes' => 'minuuttia',
127 'minute' => 'minuutti',
128 'mins' => 'min',
129 'min' => 'min',
130 'days' => 'päivää',
131 'day' => 'päivä',
132 'hours' => 'tuntia',
133 'hour' => 'tunti',
134 'weeks' => 'viikkoa',
135 'week' => 'viikko',
136 'fortnights' => 'tuplaviikkoa',
137 'fortnight' => 'tuplaviikko',
138 'months' => 'kuukautta',
139 'month' => 'kuukausi',
140 'years' => 'vuotta',
141 'year' => 'vuosi',
142 'infinite' => 'ikuinen',
143 'indefinite' => 'ikuinen',
144 'infinity' => 'ikuinen'
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 [ $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 trim( $final );
166 }
167}
Finnish (Suomi)
translateBlockExpiry( $str, ?UserIdentity $user=null, $now=0)
convertGrammar( $word, $case)
Grammatical transformations, needed for inflected languages Invoked by putting {{grammar:case|word}} ...
Base class for language-specific code.
Definition Language.php:80
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.