2004-02-18 02:15:00 +00:00
|
|
|
<?php
|
2012-06-06 20:42:13 +00:00
|
|
|
/**
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
2006-06-11 21:45:19 +00:00
|
|
|
*
|
2012-06-06 20:42:13 +00:00
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
|
*
|
|
|
|
|
* @file
|
2006-06-11 21:45:19 +00:00
|
|
|
* @author Niklas Laxström
|
2012-06-06 20:42:13 +00:00
|
|
|
*/
|
|
|
|
|
|
2024-09-27 20:18:58 +00:00
|
|
|
use MediaWiki\Language\Language;
|
2022-04-13 15:28:26 +00:00
|
|
|
use MediaWiki\MainConfigNames;
|
2022-01-06 18:44:56 +00:00
|
|
|
use MediaWiki\MediaWikiServices;
|
2021-03-10 19:51:13 +00:00
|
|
|
use MediaWiki\User\UserIdentity;
|
|
|
|
|
|
2012-06-06 20:42:13 +00:00
|
|
|
/**
|
|
|
|
|
* Finnish (Suomi)
|
|
|
|
|
*
|
2022-06-22 22:37:31 +00:00
|
|
|
* @ingroup Languages
|
2005-04-09 15:16:34 +00:00
|
|
|
*/
|
2006-07-26 07:15:39 +00:00
|
|
|
class LanguageFi extends Language {
|
2019-10-11 18:44:16 +00:00
|
|
|
public function convertGrammar( $word, $case ) {
|
2022-04-13 15:28:26 +00:00
|
|
|
$grammarForms =
|
|
|
|
|
MediaWikiServices::getInstance()->getMainConfig()->get( MainConfigNames::GrammarForms );
|
2022-01-06 18:44:56 +00:00
|
|
|
if ( isset( $grammarForms['fi'][$case][$word] ) ) {
|
|
|
|
|
return $grammarForms['fi'][$case][$word];
|
2006-05-25 14:31:28 +00:00
|
|
|
}
|
|
|
|
|
|
2015-09-26 15:35:14 +00:00
|
|
|
# These rules don't cover the whole language.
|
|
|
|
|
# They are used only for site names.
|
2006-12-17 23:44:40 +00:00
|
|
|
|
2023-10-02 12:55:39 +00:00
|
|
|
# vowel harmony flag
|
2006-12-17 23:44:40 +00:00
|
|
|
$aou = preg_match( '/[aou][^äöy]*$/i', $word );
|
|
|
|
|
|
2007-02-10 22:03:31 +00:00
|
|
|
# The flag should be false for compounds where the last word has only neutral vowels (e/i).
|
|
|
|
|
# The general case cannot be handled without a dictionary, but there's at least one notable
|
|
|
|
|
# special case we should check for:
|
|
|
|
|
|
2013-04-17 19:10:02 +00:00
|
|
|
if ( preg_match( '/wiki$/i', $word ) ) {
|
2007-02-10 22:03:31 +00:00
|
|
|
$aou = false;
|
2013-04-17 19:10:02 +00:00
|
|
|
}
|
2007-02-10 22:03:31 +00:00
|
|
|
|
2006-12-17 23:44:40 +00:00
|
|
|
# append i after final consonant
|
2013-04-17 19:10:02 +00:00
|
|
|
if ( preg_match( '/[bcdfghjklmnpqrstvwxz]$/i', $word ) ) {
|
2006-12-17 23:44:40 +00:00
|
|
|
$word .= 'i';
|
2013-04-17 19:10:02 +00:00
|
|
|
}
|
2006-12-17 23:44:40 +00:00
|
|
|
|
2005-08-15 19:27:58 +00:00
|
|
|
switch ( $case ) {
|
|
|
|
|
case 'genitive':
|
2006-12-17 23:44:40 +00:00
|
|
|
$word .= 'n';
|
|
|
|
|
break;
|
2005-08-15 19:27:58 +00:00
|
|
|
case 'elative':
|
2010-07-29 09:43:18 +00:00
|
|
|
$word .= ( $aou ? 'sta' : 'stä' );
|
2005-08-15 19:27:58 +00:00
|
|
|
break;
|
|
|
|
|
case 'partitive':
|
2010-07-29 09:43:18 +00:00
|
|
|
$word .= ( $aou ? 'a' : 'ä' );
|
2005-08-15 19:27:58 +00:00
|
|
|
break;
|
|
|
|
|
case 'illative':
|
|
|
|
|
# Double the last letter and add 'n'
|
2017-05-01 17:18:38 +00:00
|
|
|
$word .= mb_substr( $word, -1 ) . 'n';
|
2005-08-15 19:27:58 +00:00
|
|
|
break;
|
|
|
|
|
case 'inessive':
|
2010-07-29 09:43:18 +00:00
|
|
|
$word .= ( $aou ? 'ssa' : 'ssä' );
|
2005-08-15 19:27:58 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return $word;
|
|
|
|
|
}
|
2005-08-12 17:18:53 +00:00
|
|
|
|
2011-05-29 16:32:05 +00:00
|
|
|
/**
|
2014-04-17 13:31:28 +00:00
|
|
|
* @param string $str
|
2021-03-10 19:51:13 +00:00
|
|
|
* @param UserIdentity|null $user User object to use timezone from or null, ignored
|
2017-01-18 13:08:28 +00:00
|
|
|
* @param int $now Current timestamp, for formatting relative block durations
|
2011-05-29 16:32:05 +00:00
|
|
|
* @return string
|
|
|
|
|
*/
|
2024-10-16 18:58:33 +00:00
|
|
|
public function translateBlockExpiry( $str, ?UserIdentity $user = null, $now = 0 ) {
|
2005-09-09 17:46:21 +00:00
|
|
|
/*
|
|
|
|
|
'ago', 'now', 'today', 'this', 'next',
|
2014-04-21 18:43:15 +00:00
|
|
|
'first', 'third', 'fourth', 'fifth', 'sixth', 'seventh', 'eighth', 'ninth',
|
|
|
|
|
'tenth', 'eleventh', 'twelfth',
|
2005-09-09 17:46:21 +00:00
|
|
|
'tomorrow', 'yesterday'
|
|
|
|
|
|
2014-04-21 18:43:15 +00:00
|
|
|
$months = 'january:tammikuu,february:helmikuu,march:maaliskuu,april:huhtikuu,' .
|
|
|
|
|
'may:toukokuu,june:kesäkuu,july:heinäkuu,august:elokuu,september:syyskuu,' .
|
|
|
|
|
'october:lokakuu,november:marraskuu,december:joulukuu,' .
|
|
|
|
|
'jan:tammikuu,feb:helmikuu,mar:maaliskuu,apr:huhtikuu,jun:kesäkuu,' .
|
|
|
|
|
'jul:heinäkuu,aug:elokuu,sep:syyskuu,oct:lokakuu,nov:marraskuu,' .
|
|
|
|
|
dec:joulukuu,sept:syyskuu';
|
2005-08-27 16:35:10 +00:00
|
|
|
*/
|
2016-02-17 09:09:32 +00:00
|
|
|
$weekds = [
|
2005-09-09 17:46:21 +00:00
|
|
|
'monday' => 'maanantai',
|
|
|
|
|
'tuesday' => 'tiistai',
|
|
|
|
|
'wednesday' => 'keskiviikko',
|
2012-05-12 21:08:56 +00:00
|
|
|
'thursday' => 'torstai',
|
2005-09-09 17:46:21 +00:00
|
|
|
'friday' => 'perjantai',
|
|
|
|
|
'saturday' => 'lauantai',
|
|
|
|
|
'sunday' => 'sunnuntai',
|
|
|
|
|
'mon' => 'ma',
|
|
|
|
|
'tue' => 'ti',
|
|
|
|
|
'tues' => 'ti',
|
|
|
|
|
'wed' => 'ke',
|
|
|
|
|
'wednes' => 'ke',
|
|
|
|
|
'thu' => 'to',
|
|
|
|
|
'thur' => 'to',
|
|
|
|
|
'thurs' => 'to',
|
|
|
|
|
'fri' => 'pe',
|
|
|
|
|
'sat' => 'la',
|
|
|
|
|
'sun' => 'su',
|
|
|
|
|
'next' => 'seuraava',
|
|
|
|
|
'tomorrow' => 'huomenna',
|
|
|
|
|
'ago' => 'sitten',
|
|
|
|
|
'seconds' => 'sekuntia',
|
|
|
|
|
'second' => 'sekunti',
|
|
|
|
|
'secs' => 's',
|
|
|
|
|
'sec' => 's',
|
|
|
|
|
'minutes' => 'minuuttia',
|
|
|
|
|
'minute' => 'minuutti',
|
|
|
|
|
'mins' => 'min',
|
|
|
|
|
'min' => 'min',
|
|
|
|
|
'days' => 'päivää',
|
|
|
|
|
'day' => 'päivä',
|
|
|
|
|
'hours' => 'tuntia',
|
|
|
|
|
'hour' => 'tunti',
|
|
|
|
|
'weeks' => 'viikkoa',
|
|
|
|
|
'week' => 'viikko',
|
|
|
|
|
'fortnights' => 'tuplaviikkoa',
|
|
|
|
|
'fortnight' => 'tuplaviikko',
|
|
|
|
|
'months' => 'kuukautta',
|
|
|
|
|
'month' => 'kuukausi',
|
|
|
|
|
'years' => 'vuotta',
|
|
|
|
|
'year' => 'vuosi',
|
2020-04-01 16:02:09 +00:00
|
|
|
'infinite' => 'ikuinen',
|
|
|
|
|
'indefinite' => 'ikuinen',
|
|
|
|
|
'infinity' => 'ikuinen'
|
2016-02-17 09:09:32 +00:00
|
|
|
];
|
2005-09-09 17:46:21 +00:00
|
|
|
|
2005-08-27 16:35:10 +00:00
|
|
|
$final = '';
|
2015-06-16 19:06:19 +00:00
|
|
|
$tokens = explode( ' ', $str );
|
2010-07-29 09:43:18 +00:00
|
|
|
foreach ( $tokens as $item ) {
|
|
|
|
|
if ( !is_numeric( $item ) ) {
|
2015-06-16 19:06:19 +00:00
|
|
|
if ( count( explode( '-', $item ) ) == 3 && strlen( $item ) == 10 ) {
|
2005-08-27 16:35:10 +00:00
|
|
|
[ $yyyy, $mm, $dd ] = explode( '-', $item );
|
2011-02-26 08:19:21 +00:00
|
|
|
$final .= ' ' . $this->date( "{$yyyy}{$mm}{$dd}000000" );
|
2005-08-27 16:35:10 +00:00
|
|
|
continue;
|
|
|
|
|
}
|
2010-07-29 09:43:18 +00:00
|
|
|
if ( isset( $weekds[$item] ) ) {
|
2005-09-09 17:46:21 +00:00
|
|
|
$final .= ' ' . $weekds[$item];
|
|
|
|
|
continue;
|
2005-08-27 16:35:10 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2005-09-09 17:46:21 +00:00
|
|
|
$final .= ' ' . $item;
|
2005-08-27 16:35:10 +00:00
|
|
|
}
|
2007-05-22 15:11:17 +00:00
|
|
|
|
2020-12-07 14:40:26 +00:00
|
|
|
return trim( $final );
|
2005-08-27 16:35:10 +00:00
|
|
|
}
|
2003-11-28 10:00:23 +00:00
|
|
|
}
|