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