Skip to content

Commit

Permalink
fix(appointments): properly localise the calendar events
Browse files Browse the repository at this point in the history
Signed-off-by: Anna Larch <anna@nextcloud.com>
  • Loading branch information
miaulalala committed Jul 15, 2024
1 parent e3c000f commit 74df703
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions lib/Service/Appointments/BookingCalendarWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
use OCP\Calendar\ICreateFromString;
use OCP\Calendar\IManager;
use OCP\IConfig;
use OCP\IL10N;
use OCP\IUserManager;
use OCP\L10N\IFactory;
use OCP\Security\ISecureRandom;
use RuntimeException;
use Sabre\VObject\Component\VCalendar;
Expand All @@ -33,22 +33,19 @@ class BookingCalendarWriter {

/** @var ISecureRandom */
private $random;
/** @var IL10N */
private $l10n;

private TimezoneGenerator $timezoneGenerator;

public function __construct(IConfig $config,
IManager $manager,
IUserManager $userManager,
ISecureRandom $random,
IL10N $l10n,
TimezoneGenerator $timezoneGenerator) {
TimezoneGenerator $timezoneGenerator,
private IFactory $l10nFactory) {
$this->config = $config;
$this->manager = $manager;
$this->userManager = $userManager;
$this->random = $random;
$this->l10n = $l10n;
$this->timezoneGenerator = $timezoneGenerator;
}

Expand Down Expand Up @@ -93,12 +90,15 @@ public function write(AppointmentConfig $config,
throw new RuntimeException('Organizer not registered user for this instance');
}

$lang = $this->config->getUserValue($organizer->getUID(), 'core', 'lang', null);
$l10n = $this->l10nFactory->get('calendar', $lang);

$vcalendar = new VCalendar([
'CALSCALE' => 'GREGORIAN',
'VERSION' => '2.0',
'VEVENT' => [
// TRANSLATORS Title for event appoinment, first the attendee name, then the appointment name
'SUMMARY' => $this->l10n->t('%1$s - %2$s', [$displayName, $config->getName()]),
'SUMMARY' => $l10n->t('%1$s - %2$s', [$displayName, $config->getName()]),
'STATUS' => 'CONFIRMED',
'DTSTART' => $start,
'DTEND' => $start->setTimestamp($start->getTimestamp() + ($config->getLength()))
Expand Down Expand Up @@ -176,7 +176,7 @@ public function write(AppointmentConfig $config,
}

if ($config->getPreparationDuration() !== 0) {
$string = $this->l10n->t('Prepare for %s', [$config->getName()]);
$string = $l10n->t('Prepare for %s', [$config->getName()]);
$prepStart = $start->setTimestamp($start->getTimestamp() - $config->getPreparationDuration());
$prepCalendar = new VCalendar([
'CALSCALE' => 'GREGORIAN',
Expand Down Expand Up @@ -207,7 +207,7 @@ public function write(AppointmentConfig $config,
}

if ($config->getFollowupDuration() !== 0) {
$string = $this->l10n->t('Follow up for %s', [$config->getName()]);
$string = $l10n->t('Follow up for %s', [$config->getName()]);
$followupStart = $start->setTimestamp($start->getTimestamp() + $config->getLength());
$followUpEnd = $followupStart->setTimestamp($followupStart->getTimestamp() + $config->getFollowupDuration());
$followUpCalendar = new VCalendar([
Expand Down

0 comments on commit 74df703

Please sign in to comment.