protected function addYearly(Rule $rule)
{
$interval = $rule->getInterval();
$byMonth = $rule->getByMonth();
$byMonthDay = $rule->getByMonthDay();
$byDay = $rule->getByDay();
$byYearDay = $rule->getByYearDay();
$byWeekNum = $rule->getByWeekNumber();
if (!empty($byMonth) && count($byMonth) > 1 && $interval == 1) {
$this->addFragment($this->translator->trans('every_month_list'));
} else {
$this->addFragment($this->translator->trans($this->isPlural($interval) ? 'every %count% years' : 'every year', array('count' => $interval)));
}
if (count($byMonth) <= 1 && empty($byMonthDay) && empty($byDay) && empty($byYearDay) && empty($byWeekNum)) {
$this->addFragment($this->translator->trans('on'));
$monthNum = count($byMonth) ? $byMonth[0] : $rule->getStartDate()->format('n');
$this->addFragment($this->translator->trans('day_month', array('month' => $monthNum, 'day' => $rule->getStartDate()->format('d'))));
} elseif (!empty($byMonth)) {
if ($interval != 1) {
$this->addFragment($this->translator->trans('in_month'));
}
$this->addByMonth($rule);
}
if (!empty($byMonthDay)) {
$this->addByMonthDay($rule);
$this->addFragment($this->translator->trans('of_the_month'));
} else {
if (!empty($byDay)) {
$this->addByDay($rule);
}
}
if (!empty($byYearDay)) {
$this->addFragment($this->translator->trans('on the'));
$this->addFragment($this->getByYearDayAsText($byYearDay));
$this->addFragment($this->translator->trans('day'));
}
if (!empty($byWeekNum)) {
$this->addFragment($this->translator->trans('in_week'));
$this->addFragment($this->translator->trans($this->isPlural(count($byWeekNum)) ? 'weeks' : 'week'));
$this->addFragment($this->getByWeekNumberAsText($byWeekNum));
}
if (empty($byMonthDay) && empty($byYearDay) && empty($byDay) && !empty($byWeekNum)) {
$this->addDayOfWeek($rule);
}
}