From d118a932fce3ef63597b53f1460bcd77952cbed7 Mon Sep 17 00:00:00 2001 From: roikedem Date: Mon, 12 Apr 2021 11:59:55 +0300 Subject: [PATCH] Add Hebrew translation i18n add he, remove automatic space after "and" add shortened weekdays names for lists --- src/RRule.php | 14 +++- src/i18n/de.php | 4 +- src/i18n/en.php | 4 +- src/i18n/es.php | 2 +- src/i18n/fi.php | 4 +- src/i18n/fr.php | 4 +- src/i18n/he.php | 186 ++++++++++++++++++++++++++++++++++++++++++++++++ src/i18n/it.php | 2 +- src/i18n/nl.php | 2 +- 9 files changed, 208 insertions(+), 14 deletions(-) create mode 100644 src/i18n/he.php diff --git a/src/RRule.php b/src/RRule.php index c1068eb..5a5c594 100755 --- a/src/RRule.php +++ b/src/RRule.php @@ -1934,7 +1934,7 @@ class RRule implements RRuleInterface if (count($array) > 1) { $last = array_splice($array, -1); return sprintf( - '%s %s %s', + '%s %s%s', implode(', ',$array), $and, implode('',$last) @@ -2253,11 +2253,19 @@ class RRule implements RRuleInterface $parts['byweekday'] = array(); if ($this->byweekday) { $tmp = $this->byweekday; + $shorten_weekdays_in_list = !empty($i18n['shorten_weekdays_in_list']) && count($tmp) > 1; + if ($shorten_weekdays_in_list) { + $daysnames = $i18n['weekdays_shortened_for_list']; + } + else { + $daysnames = $i18n['weekdays']; + } foreach ($tmp as & $value) { - $value = $i18n['weekdays'][$value]; + $value = $daysnames[$value]; } + $prefix = $shorten_weekdays_in_list ? $i18n['shorten_weekdays_days'] : ""; $parts['byweekday'][] = strtr(self::i18nSelect($i18n['byweekday'], count($tmp)), array( - '%{weekdays}' => self::i18nList($tmp, $i18n['and']) + '%{weekdays}' => $prefix . self::i18nList($tmp, $i18n['and']) )); } if ($this->byweekday_nth) { diff --git a/src/i18n/de.php b/src/i18n/de.php index bbb0f17..52c8166 100755 --- a/src/i18n/de.php +++ b/src/i18n/de.php @@ -50,7 +50,7 @@ return array( '1' => ', einmalig', 'else' => ', %{count} Mal insgesamt' ), - 'and' => 'und', + 'and' => 'und ', 'x_of_the_y' => array( 'yearly' => '%{x} des Jahres', // e.g. the first Monday of the year, or the first day of the year 'monthly' => '%{x} des Monats', @@ -147,4 +147,4 @@ return array( '-2' => 'die vorletzte', 'else' => 'die %{n}. letzte' ) -); \ No newline at end of file +); diff --git a/src/i18n/en.php b/src/i18n/en.php index f22729e..8b87495 100755 --- a/src/i18n/en.php +++ b/src/i18n/en.php @@ -52,7 +52,7 @@ return array( '1' => ', one time', 'else' => ', %{count} times' ), - 'and' => 'and', + 'and' => 'and ', 'x_of_the_y' => array( 'yearly' => '%{x} of the year', // e.g. the first Monday of the year, or the first day of the year 'monthly' => '%{x} of the month', @@ -164,4 +164,4 @@ return array( '-3' => 'the antepenultimate', 'else' => 'the %{n}th to the last' ) -); \ No newline at end of file +); diff --git a/src/i18n/es.php b/src/i18n/es.php index 73b09ad..dd159a1 100644 --- a/src/i18n/es.php +++ b/src/i18n/es.php @@ -45,7 +45,7 @@ return array( '1' => ', una vez', 'else' => ', %{count} veces' ), - 'and' => 'y', + 'and' => 'y ', 'x_of_the_y' => array( 'yearly' => '%{x} del año', // e.g. the first Monday of the year, or the first day of the year 'monthly' => '%{x} del mes', diff --git a/src/i18n/fi.php b/src/i18n/fi.php index 6a300ce..16a38d0 100755 --- a/src/i18n/fi.php +++ b/src/i18n/fi.php @@ -52,7 +52,7 @@ return array( '1' => ', kerran', 'else' => ', %{count} kertaa' ), - 'and' => 'ja', + 'and' => 'ja ', 'x_of_the_y' => array( 'yearly' => '%{x} vuodessa', // e.g. the first Monday of the year, or the first day of the year 'monthly' => '%{x} kuukaudessa', @@ -133,4 +133,4 @@ return array( '-1' => 'viimeinen', 'else' => '%{n}:ksi viimeinen' ) -); \ No newline at end of file +); diff --git a/src/i18n/fr.php b/src/i18n/fr.php index c4033f8..87fe6cb 100755 --- a/src/i18n/fr.php +++ b/src/i18n/fr.php @@ -50,7 +50,7 @@ return array( '1' => ', une fois', 'else' => ', %{count} fois' ), - 'and' => 'et', + 'and' => 'et ', 'x_of_the_y' => array( 'yearly' => '%{x} de l\'année', // e.g. the first Monday of the year, or the first day of the year 'monthly' => '%{x} du mois', @@ -152,4 +152,4 @@ return array( '-3' => 'l\'antépénultième', 'else' => 'la %{n}e en partant de la fin' ) -); \ No newline at end of file +); diff --git a/src/i18n/he.php b/src/i18n/he.php new file mode 100644 index 0000000..748b6e6 --- /dev/null +++ b/src/i18n/he.php @@ -0,0 +1,186 @@ + + * @link https://github.com/rlanvin/php-rrule + */ +return array( + 'yearly' => array( + '1' => 'כל שנה', + 'else' => 'כל %{interval} שנים' + ), + 'monthly' => array( + '1' => 'monthly', + 'else' => 'every %{interval} months' + ), + 'weekly' => array( + '1' => 'כל שבוע', + '2' => 'פעם בשבועיים', + 'else' => 'כל %{interval} שבועות' + ), + 'daily' => array( + '1' => 'כל יום', + '2' => 'פעם ביומיים', + 'else' => 'כל %{interval} ימים' + ), + 'hourly' => array( + '1' => 'כל שעה', + 'else' => 'כל %{interval} שעות' + ), + 'minutely' => array( + '1' => 'כל דקה', + 'else' => 'כל %{interval} דקות' + ), + 'secondly' => array( + '1' => 'כל שניה', + 'else' => 'כל %{interval} שניות' + ), + 'dtstart' => ', החל מ%{date}', + 'infinite' => ', לעד', + 'until' => ', עד %{date}', + 'count' => array( + '1' => ', פעם אחת', + 'else' => ', %{count} פעמים' + ), + 'and' => 'ו', + 'x_of_the_y' => array( + 'yearly' => '%{x} בשנה', // e.g. the first Monday of the year, or the first day of the year + 'monthly' => '%{x} בחודש', + ), + 'bymonth' => ' ב%{months}', + 'months' => array( + 1 => 'ינואר', + 2 => 'פברואר', + 3 => 'מארס', + 4 => 'אפריל', + 5 => 'מאי', + 6 => 'יוני', + 7 => 'יולי', + 8 => 'אוגוסט', + 9 => 'ספטמבר', + 10 => 'אוקטובר', + 11 => 'נובמבר', + 12 => 'דצמבר', + ), + 'byweekday' => ' ב%{weekdays}', + 'weekdays' => array( + 1 => "יום ב'", + 2 => "יום ג'", + 3 => "יום ד'", + 4 => "יום ה'", + 5 => "יום ו'", + 6 => "שבת", + 7 => "יום א'", + ), + 'shorten_weekdays_in_list' => true, + 'shorten_weekdays_days' => 'ימים ', + 'weekdays_shortened_for_list' => array( + 1 => "שני", + 2 => "שלישי", + 3 => "רביעי", + 4 => "חמישי", + 5 => "שישי", + 6 => "שבת", + 7 => "ראשון", + ), + 'nth_weekday' => array( + '1' => '%{weekday} הראשון', // e.g. the first Monday + '2' => '%{weekday} השני', + '3' => '%{weekday} השלישי', + '4' => '%{weekday} הרביעי', + '5' => '%{weekday} החמישי', + '6' => '%{weekday} השישי', + '7' => '%{weekday} השביעי', + '8' => '%{weekday} השמיני', + '9' => '%{weekday} התשיעי', + '10' => '%{weekday} העשירי', + 'else' => '%{weekday} ה-%{n}' + ), + '-nth_weekday' => array( + '-1' => '%{weekday} האחרון', // e.g. the last Monday + '-2' => '%{weekday} לפני האחרון', + 'else' => '%{weekday} ה-%{n} לפני האחרון' + ), + 'byweekno' => array( + '1' => ' בשבוע %{weeks}', + 'else' => ' בשבוע מספר %{weeks}' + ), + 'nth_weekno' => '%{n}', + 'bymonthday' => ' ב%{monthdays}', + 'nth_monthday' => array( + 'else' => 'ה-%{n}' + ), + '-nth_monthday' => array( + '-1' => 'היום האחרון', + '-2' => 'היום הלפני-אחרון', + 'else' => 'היום ה-%{n} מהסוף' + ), + 'byyearday' => array( + '1' => ' ביום%{yeardays}', + 'else' => ' בימים %{yeardays}' + ), + 'nth_yearday' => array( + '1' => 'הראשון', + '2' => 'השני', + '3' => 'השלישי', + '4' => 'הרביעי', + '5' => 'החמישי', + '6' => 'השישי', + '7' => 'השביעי', + '8' => 'השמיני', + '9' => 'התשיעי', + '10' => 'העשירי', + 'else' => 'ה-%{n}' + ), + '-nth_yearday' => array( + '-1' => 'האחרון', + '-2' => 'לפני האחרון', + '-3' => 'שניים לפני האחרון', + 'else' => 'ה %{n} מהסוף' + ), + 'byhour' => array( + '1' => ' ב%{hours}', + 'else' => ' ב%{hours}' + ), + 'nth_hour' => '%{n}', + 'byminute' => array( + '1' => ' בדקה %{minutes}', + 'else' => ' בדקות %{minutes}' + ), + 'nth_minute' => '%{n}', + 'bysecond' => array( + '1' => ' בשניה %{seconds}', + 'else' => ' בשניות %{seconds}' + ), + 'nth_second' => '%{n}', + 'bysetpos' => ', אבל רק %{setpos} פעמים בסדרה זו', + 'nth_setpos' => array( + '1' => 'הראשון', + '2' => 'השני', + '3' => 'השלישי', + '4' => 'הרביעי', + '5' => 'החמישי', + '6' => 'השישי', + '7' => 'השביעי', + '8' => 'השמיני', + '9' => 'התשיעי', + '10' => 'העשירי', + 'else' => 'ה-%{n}' + ), + '-nth_setpos' => array( + '-1' => 'האחרון', + '-2' => 'לפני האחרון', + '-3' => 'שניים לפני האחרון', + 'else' => 'ה %{n} מהסוף' + ) +); diff --git a/src/i18n/it.php b/src/i18n/it.php index 86d4145..ff0d729 100644 --- a/src/i18n/it.php +++ b/src/i18n/it.php @@ -44,7 +44,7 @@ return array( '1' => ', una volta', 'else' => ', %{count} volte' ), - 'and' => 'e', + 'and' => 'e ', 'x_of_the_y' => array( 'yearly' => '%{x} dell\'anno', // e.g. the first Monday of the year, or the first day of the year 'monthly' => '%{x} del mese', diff --git a/src/i18n/nl.php b/src/i18n/nl.php index 045f5ad..28b742f 100755 --- a/src/i18n/nl.php +++ b/src/i18n/nl.php @@ -52,7 +52,7 @@ return array( '1' => ', één keer', 'else' => ', %{count} keren' ), - 'and' => 'en', + 'and' => 'en ', 'x_of_the_y' => array( 'yearly' => '%{x} van het jaar', // e.g. the first Monday of the year, or the first day of the year 'monthly' => '%{x} van de maand',