MediaWiki 1.42.0
LanguageFi.php
Go to the documentation of this file.
1<?php
25
31class 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
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}
Finnish (Suomi)
convertGrammar( $word, $case)
Grammatical transformations, needed for inflected languages Invoked by putting {{grammar:case|word}} ...
translateBlockExpiry( $str, UserIdentity $user=null, $now=0)
Base class for language-specific code.
Definition Language.php:63
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.