Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable4.7] fix(appointments): properly localise the calendar events #6168

Merged
merged 1 commit into from
Jul 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading