merged master after 1.20wmf3
[lhc/web/wiklou.git] / languages / classes / LanguageFi.php
1 <?php
2
3 /** Finnish (Suomi)
4 *
5 * @ingroup Language
6 *
7 * @author Niklas Laxström
8 */
9 class LanguageFi extends Language {
10
11 /**
12 * Convert from the nominative form of a noun to some other case
13 * Invoked with {{grammar:case|word}}
14 *
15 * @param $word string
16 * @param $case string
17 * @return string
18 */
19 function convertGrammar( $word, $case ) {
20 global $wgGrammarForms;
21 if ( isset( $wgGrammarForms['fi'][$case][$word] ) ) {
22 return $wgGrammarForms['fi'][$case][$word];
23 }
24
25 # These rules are not perfect, but they are currently only used for site names so it doesn't
26 # matter if they are wrong sometimes. Just add a special case for your site name if necessary.
27
28 # wovel harmony flag
29 $aou = preg_match( '/[aou][^äöy]*$/i', $word );
30
31 # The flag should be false for compounds where the last word has only neutral vowels (e/i).
32 # The general case cannot be handled without a dictionary, but there's at least one notable
33 # special case we should check for:
34
35 if ( preg_match( '/wiki$/i', $word ) )
36 $aou = false;
37
38 # append i after final consonant
39 if ( preg_match( '/[bcdfghjklmnpqrstvwxz]$/i', $word ) )
40 $word .= 'i';
41
42 switch ( $case ) {
43 case 'genitive':
44 $word .= 'n';
45 break;
46 case 'elative':
47 $word .= ( $aou ? 'sta' : 'stä' );
48 break;
49 case 'partitive':
50 $word .= ( $aou ? 'a' : 'ä' );
51 break;
52 case 'illative':
53 # Double the last letter and add 'n'
54 # mb_substr has a compatibility function in GlobalFunctions.php
55 $word = $word . mb_substr( $word, -1 ) . 'n';
56 break;
57 case 'inessive':
58 $word .= ( $aou ? 'ssa' : 'ssä' );
59 break;
60 }
61 return $word;
62 }
63
64 /**
65 * @param $str string
66 * @param $forContent bool
67 * @return string
68 */
69 function translateBlockExpiry( $str, $forContent = false ) {
70 /*
71 'ago', 'now', 'today', 'this', 'next',
72 'first', 'third', 'fourth', 'fifth', 'sixth', 'seventh', 'eighth', 'ninth', 'tenth', 'eleventh', 'twelfth',
73 'tomorrow', 'yesterday'
74
75 $months = 'january:tammikuu,february:helmikuu,march:maaliskuu,april:huhtikuu,may:toukokuu,june:kesäkuu,' .
76 'july:heinäkuu,august:elokuu,september:syyskuu,october:lokakuu,november:marraskuu,december:joulukuu,' .
77 'jan:tammikuu,feb:helmikuu,mar:maaliskuu,apr:huhtikuu,jun:kesäkuu,jul:heinäkuu,aug:elokuu,sep:syyskuu,'.
78 'oct:lokakuu,nov:marraskuu,dec:joulukuu,sept:syyskuu';
79 */
80 $weekds = array(
81 'monday' => 'maanantai',
82 'tuesday' => 'tiistai',
83 'wednesday' => 'keskiviikko',
84 'thursday' => 'torstai',
85 'friday' => 'perjantai',
86 'saturday' => 'lauantai',
87 'sunday' => 'sunnuntai',
88 'mon' => 'ma',
89 'tue' => 'ti',
90 'tues' => 'ti',
91 'wed' => 'ke',
92 'wednes' => 'ke',
93 'thu' => 'to',
94 'thur' => 'to',
95 'thurs' => 'to',
96 'fri' => 'pe',
97 'sat' => 'la',
98 'sun' => 'su',
99 'next' => 'seuraava',
100 'tomorrow' => 'huomenna',
101 'ago' => 'sitten',
102 'seconds' => 'sekuntia',
103 'second' => 'sekunti',
104 'secs' => 's',
105 'sec' => 's',
106 'minutes' => 'minuuttia',
107 'minute' => 'minuutti',
108 'mins' => 'min',
109 'min' => 'min',
110 'days' => 'päivää',
111 'day' => 'päivä',
112 'hours' => 'tuntia',
113 'hour' => 'tunti',
114 'weeks' => 'viikkoa',
115 'week' => 'viikko',
116 'fortnights' => 'tuplaviikkoa',
117 'fortnight' => 'tuplaviikko',
118 'months' => 'kuukautta',
119 'month' => 'kuukausi',
120 'years' => 'vuotta',
121 'year' => 'vuosi',
122 'infinite' => 'ikuisesti',
123 'indefinite' => 'ikuisesti'
124 );
125
126 $final = '';
127 $tokens = explode ( ' ', $str );
128 foreach ( $tokens as $item ) {
129 if ( !is_numeric( $item ) ) {
130 if ( count ( explode( '-', $item ) ) == 3 && strlen( $item ) == 10 ) {
131 list( $yyyy, $mm, $dd ) = explode( '-', $item );
132 $final .= ' ' . $this->date( "{$yyyy}{$mm}{$dd}000000" );
133 continue;
134 }
135 if ( isset( $weekds[$item] ) ) {
136 $final .= ' ' . $weekds[$item];
137 continue;
138 }
139 }
140
141 $final .= ' ' . $item;
142 }
143
144 return htmlspecialchars( trim( $final ) );
145 }
146 }