diff --git a/lib/BirthdayCalendarGenerator.php b/lib/BirthdayCalendarGenerator.php index 9c2c7b839..26c62e401 100644 --- a/lib/BirthdayCalendarGenerator.php +++ b/lib/BirthdayCalendarGenerator.php @@ -45,6 +45,13 @@ class BirthdayCalendarGenerator { */ protected $defaultYear = 1900; + /** + * Output format for the SUMMARY. + * + * @var string + */ + protected $format = '%1$s\'s Birthday'; + /** * Creates the generator. * @@ -121,6 +128,19 @@ function setTimeZone(DateTimeZone $timeZone) { } + /** + * Sets the output format for the SUMMARY + * + * @param string $format + * + * @return void + */ + function setFormat($format) { + + $this->format = $format; + + } + /** * Parses the input data and returns a VCALENDAR. * @@ -163,7 +183,7 @@ function getResult() { // Create event. $event = $calendar->add('VEVENT', [ - 'SUMMARY' => $object->FN->getValue() .'\'s Birthday', + 'SUMMARY' => sprintf($this->format, $object->FN->getValue()), 'DTSTART' => new \DateTime($object->BDAY->getValue(), $this->timeZone), 'RRULE' => 'FREQ=YEARLY', 'TRANSP' => 'TRANSPARENT', @@ -181,6 +201,4 @@ function getResult() { } - - } diff --git a/tests/VObject/BirthdayCalendarGeneratorTest.php b/tests/VObject/BirthdayCalendarGeneratorTest.php index b612c3b1a..3108ba6f8 100644 --- a/tests/VObject/BirthdayCalendarGeneratorTest.php +++ b/tests/VObject/BirthdayCalendarGeneratorTest.php @@ -317,4 +317,43 @@ function testVcardStringWithNoBirthday() { } + function testVcardStringWithValidBirthdayLocalized() { + + $input = <<generator->setObjects($input); + $this->generator->setFormat('%1$s\'s Geburtstag'); + $output = $this->generator->getResult(); + + $this->assertVObjEquals( + $expected, + $output + ); + + // Reset to default format + $this->generator->setFormat('%1$s\'s Birthday'); + + } + }