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