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 authored and backportbot[bot] committed Jul 15, 2024
1 parent 3eef94e commit 159856c
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 @@ -33,8 +33,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 @@ -52,22 +52,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 @@ -112,12 +109,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 @@ -195,7 +195,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 @@ -226,7 +226,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 159856c

Please sign in to comment.