sv.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <?php
  2. // sunday first as date('w') is zero-based on sunday
  3. $days = array(
  4. 'Söndag',
  5. 'Måndag',
  6. 'Tisdag',
  7. 'Onsdag',
  8. 'Torsdag',
  9. 'Fredag',
  10. 'Lördag',
  11. );
  12. $months = array(
  13. 'Januari',
  14. 'Februari',
  15. 'Mars',
  16. 'April',
  17. 'Maj',
  18. 'Juni',
  19. 'Juli',
  20. 'Augusti',
  21. 'September',
  22. 'Oktober',
  23. 'November',
  24. 'December',
  25. );
  26. return array(
  27. 'Unable to fully convert this rrule to text.' => 'Kunde inte konvertera denna rrule till text.',
  28. 'for %count% times' => '%count% gånger',
  29. 'for one time' => 'en gång',
  30. '(~ approximate)' => '(~ ungefärlig)',
  31. 'until %date%' => 't.o.m. %date%', // e.g. every year until July 4, 2014
  32. 'day_date' => function ($str, $params) use ($days, $months) { // outputs a day date, e.g. July 4, 2014
  33. return $months[date('n', $params['date']) - 1] . ' '. date('j, Y', $params['date']);
  34. },
  35. 'day_month' => function ($str, $params) use ($days, $months) { // outputs a day month, e.g. July 4
  36. return $months[$params['month'] - 1].' '.$params['day'];
  37. },
  38. 'day_names' => $days,
  39. 'month_names' => $months,
  40. 'and' => 'och',
  41. 'or' => 'eller',
  42. 'in_month' => 'i', // e.g. weekly in January, May and August
  43. 'in_week' => 'i', // e.g. yearly in week 3
  44. 'on' => 'på', // e.g. every day on Tuesday, Wednesday and Friday
  45. 'the_for_monthday' => 'den', // e.g. monthly on Tuesday the 1st
  46. 'the_for_weekday' => 'den', // e.g. monthly on the 4th Monday
  47. 'on the' => 'på den', // e.g. every year on the 1st and 200th day
  48. 'of_the_month' => 'i månaden', // e.g. every year on the 2nd or 3rd of the month
  49. 'every %count% years' => 'varje %count% år',
  50. 'every year' => 'årligen',
  51. 'every_month_list' => 'varje', // e.g. every January, May and August
  52. 'every %count% months' => 'varje %count% månad',
  53. 'every month' => 'månadsvis',
  54. 'every %count% weeks' => 'varje %count% vecka',
  55. 'every week' => 'veckovis',
  56. 'every %count% days' => 'varje %count% dag',
  57. 'every day' => 'dagligen',
  58. 'last' => 'sista', // e.g. 2nd last Friday
  59. 'days' => 'dagar',
  60. 'day' => 'dag',
  61. 'weeks' => 'veckor',
  62. 'week' => 'vecka',
  63. // formats a number with a prefix e.g. every year on the 1st and 200th day
  64. // negative numbers should be handled as in '5th to the last' or 'last'
  65. //
  66. // if has_negatives is true in the params, it is good form to add 'day' after
  67. // each number, as in: 'every month on the 5th day or 2nd to the last day' or
  68. // it may be confusing like 'every month on the 5th or 2nd to the last day'
  69. 'ordinal_number' => function ($str, $params) {
  70. $number = $params['number'];
  71. $ends = array(':e', ':a', ':a', ':e', ':e', ':e', ':e', ':e', ':e', ':e');
  72. $suffix = '';
  73. $isNegative = $number < 0;
  74. if ($number == -1) {
  75. $abbreviation = 'last';
  76. } else {
  77. if ($isNegative) {
  78. $number = abs($number);
  79. $suffix = ' to the last';
  80. }
  81. if (($number % 100) >= 11 && ($number % 100) <= 13) {
  82. $abbreviation = $number.'th';
  83. } else {
  84. $abbreviation = $number.$ends[$number % 10];
  85. }
  86. }
  87. if (!empty($params['has_negatives'])) {
  88. $suffix .= ' dag';
  89. }
  90. return $abbreviation . $suffix;
  91. },
  92. );