en.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <?php
  2. // sunday first as date('w') is zero-based on sunday
  3. $days = array(
  4. 'Sunday',
  5. 'Monday',
  6. 'Tuesday',
  7. 'Wednesday',
  8. 'Thursday',
  9. 'Friday',
  10. 'Saturday',
  11. );
  12. $months = array(
  13. 'January',
  14. 'February',
  15. 'March',
  16. 'April',
  17. 'May',
  18. 'June',
  19. 'July',
  20. 'August',
  21. 'September',
  22. 'October',
  23. 'November',
  24. 'December',
  25. );
  26. return array(
  27. 'Unable to fully convert this rrule to text.' => 'Unable to fully convert this rrule to text.',
  28. 'for %count% times' => 'for %count% times',
  29. 'for one time' => 'once',
  30. '(~ approximate)' => '(~ approximate)',
  31. 'until %date%' => 'until %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' => 'and',
  41. 'or' => 'or',
  42. 'in_month' => 'in', // e.g. weekly in January, May and August
  43. 'in_week' => 'in', // e.g. yearly in week 3
  44. 'on' => 'on', // e.g. every day on Tuesday, Wednesday and Friday
  45. 'the_for_monthday' => 'the', // e.g. monthly on Tuesday the 1st
  46. 'the_for_weekday' => 'the', // e.g. monthly on the 4th Monday
  47. 'on the' => 'on the', // e.g. every year on the 1st and 200th day
  48. 'of_the_month' => 'of the month', // e.g. every year on the 2nd or 3rd of the month
  49. 'every %count% years' => 'every %count% years',
  50. 'every year' => 'yearly',
  51. 'every_month_list' => 'every', // e.g. every January, May and August
  52. 'every %count% months' => 'every %count% months',
  53. 'every month' => 'monthly',
  54. 'every %count% weeks' => 'every %count% weeks',
  55. 'every week' => 'weekly',
  56. 'every %count% days' => 'every %count% days',
  57. 'every day' => 'daily',
  58. 'every %count% hours' => 'every %count% hours',
  59. 'every hour' => 'hourly',
  60. 'last' => 'last', // e.g. 2nd last Friday
  61. 'days' => 'days',
  62. 'day' => 'day',
  63. 'weeks' => 'weeks',
  64. 'week' => 'week',
  65. 'hours' => 'hours',
  66. 'hour' => 'hour',
  67. // formats a number with a prefix e.g. every year on the 1st and 200th day
  68. // negative numbers should be handled as in '5th to the last' or 'last'
  69. //
  70. // if has_negatives is true in the params, it is good form to add 'day' after
  71. // each number, as in: 'every month on the 5th day or 2nd to the last day' or
  72. // it may be confusing like 'every month on the 5th or 2nd to the last day'
  73. 'ordinal_number' => function ($str, $params) {
  74. $number = $params['number'];
  75. $ends = array('th', 'st', 'nd', 'rd', 'th', 'th', 'th', 'th', 'th', 'th');
  76. $suffix = '';
  77. $isNegative = $number < 0;
  78. if ($number == -1) {
  79. $abbreviation = 'last';
  80. } else {
  81. if ($isNegative) {
  82. $number = abs($number);
  83. $suffix = ' to the last';
  84. }
  85. if (($number % 100) >= 11 && ($number % 100) <= 13) {
  86. $abbreviation = $number.'th';
  87. } else {
  88. $abbreviation = $number.$ends[$number % 10];
  89. }
  90. }
  91. if (!empty($params['has_negatives'])) {
  92. $suffix .= ' day';
  93. }
  94. return $abbreviation . $suffix;
  95. },
  96. );