1
0
mirror of https://github.com/rlanvin/php-rrule.git synced 2025-02-17 06:54:15 +01:00

Fix double space bugs with 'and'

This commit is contained in:
rlanvin 2021-07-04 16:21:53 +02:00
parent d118a932fc
commit f77c9644c6
4 changed files with 73 additions and 68 deletions

View File

@ -6,10 +6,12 @@
- Added Swedish translation [#96](https://github.com/rlanvin/php-rrule/pull/96/)
- Added `bin/review_translations.php` as a helper for translators and contributors
- Added Hebrew translation [#95](https://github.com/rlanvin/php-rrule/pull/95)
### Fixed
- Fix Finnish translation [#94](https://github.com/rlanvin/php-rrule/issues/94)
- Update French translation
- Update German translation
## [2.2.2] - 2021-01-09

View File

@ -2246,28 +2246,36 @@ class RRule implements RRuleInterface
));
$parts['bymonthday'][] = $tmp;
}
$parts['bymonthday'] = implode(' '.$i18n['and'],$parts['bymonthday']);
// because the 'on the Xth day' strings start with the space, and the "and" ends with a space
// it's necessary to collapse double spaces into one
// this behaviour was introduced in https://github.com/rlanvin/php-rrule/pull/95
$parts['bymonthday'] = str_replace(' ',' ',implode(' '.$i18n['and'],$parts['bymonthday']));
}
if (not_empty($this->rule['BYDAY'])) {
$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'];
$selector = 'weekdays';
$days_names = $i18n['weekdays'];
$prefix = '';
if (!empty($i18n['shorten_weekdays_in_list']) && count($tmp) > 1) {
// special case for Hebrew (and possibly other languages)
// see https://github.com/rlanvin/php-rrule/pull/95 for the reasoning
$selector = 'weekdays_shortened_for_list';
$prefix = $i18n['shorten_weekdays_days'];
}
foreach ($tmp as & $value) {
$value = $daysnames[$value];
$value = $i18n[$selector][$value];
}
$prefix = $shorten_weekdays_in_list ? $i18n['shorten_weekdays_days'] : "";
$parts['byweekday'][] = strtr(self::i18nSelect($i18n['byweekday'], count($tmp)), array(
'%{weekdays}' => $prefix . self::i18nList($tmp, $i18n['and'])
));
}
if ($this->byweekday_nth) {
$tmp = $this->byweekday_nth;
foreach ($tmp as & $value) {

View File

@ -1,17 +1,12 @@
<?php
/**
* Translation file for English language.
*
* Most strings can be an array, with a value as the key. The system will
* pick the translation corresponding to the key. The key "else" will be picked
* if no matching value is found. This is useful for plurals.
* Translation file for Hebrew language.
*
* Licensed under the MIT license.
*
* For the full copyright and license information, please view the LICENSE file.
*
* @author Rémi Lanvin <remi@cloudconnected.fr>
* @link https://github.com/rlanvin/php-rrule
*/
return array(