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