LanguageFi.php 3.7 KB

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