diff --git a/module/Activity/src/Service/Activity.php b/module/Activity/src/Service/Activity.php
index 33c44a3c00..3e2f7d9c3a 100644
--- a/module/Activity/src/Service/Activity.php
+++ b/module/Activity/src/Service/Activity.php
@@ -11,6 +11,7 @@
use Activity\Model\SignupField as SignupFieldModel;
use Activity\Model\SignupList as SignupListModel;
use Activity\Model\SignupOption as SignupOptionModel;
+use Application\Model\Enums\Languages;
use Application\Service\Email as EmailService;
use Company\Model\Company as CompanyModel;
use Company\Service\Company as CompanyService;
@@ -352,7 +353,7 @@ private function requestFacility(
?OrganModel $organ,
): void {
// Default to an English title, otherwise use the Dutch title
- $activityTitle = $activity->getName()->getText('en');
+ $activityTitle = $activity->getName()->getText(Languages::English);
$activityTime = $activity->getBeginTime()->format('d-m-Y H:i');
$type = sprintf('activity_creation_require_%s', $facilityType);
diff --git a/module/Activity/view/activity/admin/view.phtml b/module/Activity/view/activity/admin/view.phtml
index c2d459d388..664c02a136 100644
--- a/module/Activity/view/activity/admin/view.phtml
+++ b/module/Activity/view/activity/admin/view.phtml
@@ -3,6 +3,7 @@
declare(strict_types=1);
use Activity\Model\Activity as ActivityModel;
+use Application\Model\Enums\Languages;
use Application\View\HelperTrait;
use Laminas\View\Renderer\PhpRenderer;
@@ -82,10 +83,10 @@ $this->breadcrumbs()
| = $activity->getId() ?> |
- = $activity->getName()->getText("nl") ?>
+ = $activity->getName()->getText(Languages::Dutch) ?>
|
- = $activity->getName()->getText("en") ?>
+ = $activity->getName()->getText(Languages::English) ?>
|
= $activity->getBeginTime()->format('Y-m-d') ?> |
= (null === $activity->getOrgan()) ? $this->translate('None') : $this->escapeHtml($activity->getOrgan()->getAbbr()) ?> |
diff --git a/module/Activity/view/email/activity-update-proposed.phtml b/module/Activity/view/email/activity-update-proposed.phtml
index b3130de5c1..2a94d6b273 100644
--- a/module/Activity/view/email/activity-update-proposed.phtml
+++ b/module/Activity/view/email/activity-update-proposed.phtml
@@ -1,12 +1,17 @@
+
For English, see below.
L.s.
Er is een voorstel gedaan om een activiteit aan te passen op de GEWIS website.
-= $this->escapeHtml($activity->getName()->getText("nl")) ?>
+= $this->escapeHtml($activity->getName()->getText(Languages::Dutch)) ?>
-= $this->escapeHtml($activity->getDescription()->getText("nl")) ?>
+= $this->escapeHtml($activity->getDescription()->getText(Languages::Dutch)) ?>
@@ -19,11 +24,11 @@ Er is een voorstel gedaan om een activiteit aan te passen op de GEWIS website.
| Locatie: |
- = $this->escapeHtml($activity->getLocation()->getText("nl")) ?> |
+ = $this->escapeHtml($activity->getLocation()->getText(Languages::Dutch)) ?> |
| Kosten: |
- = $this->escapeHtml($activity->getCosts()->getText("nl")) ?> |
+ = $this->escapeHtml($activity->getCosts()->getText(Languages::Dutch)) ?> |
@@ -38,9 +43,9 @@ L.s.
An update proposal was made for an activity on the GEWIS website. See below for details.
-= $this->escapeHtml($activity->getName()->getText("en")) ?>
+= $this->escapeHtml($activity->getName()->getText(Languages::English)) ?>
-= $this->escapeHtml($activity->getDescription()->getText("en")) ?>
+= $this->escapeHtml($activity->getDescription()->getText(Languages::English)) ?>
@@ -53,11 +58,11 @@ An update proposal was made for an activity on the GEWIS website. See below for
| Location: |
- = $this->escapeHtml($activity->getLocation()->getText("en")) ?> |
+ = $this->escapeHtml($activity->getLocation()->getText(Languages::English)) ?> |
| Costs: |
- = $this->escapeHtml($activity->getCosts()->getText("en")) ?> |
+ = $this->escapeHtml($activity->getCosts()->getText(Languages::English)) ?> |
diff --git a/module/Activity/view/email/activity-updated.phtml b/module/Activity/view/email/activity-updated.phtml
index 4353cb9be1..454688e096 100644
--- a/module/Activity/view/email/activity-updated.phtml
+++ b/module/Activity/view/email/activity-updated.phtml
@@ -1,12 +1,17 @@
+
For English, see below.
L.s.
Er is een activiteit aangepast op de GEWIS website.
-= $this->escapeHtml($activity->getName()->getText("nl")) ?>
+= $this->escapeHtml($activity->getName()->getText(Languages::Dutch)) ?>
-= $this->escapeHtml($activity->getDescription()->getText("nl")) ?>
+= $this->escapeHtml($activity->getDescription()->getText(Languages::Dutch)) ?>
@@ -19,11 +24,11 @@ Er is een activiteit aangepast op de GEWIS website.
| Locatie: |
- = $this->escapeHtml($activity->getLocation()->getText("nl")) ?> |
+ = $this->escapeHtml($activity->getLocation()->getText(Languages::Dutch)) ?> |
| Kosten: |
- = $this->escapeHtml($activity->getCosts()->getText("nl")) ?> |
+ = $this->escapeHtml($activity->getCosts()->getText(Languages::Dutch)) ?> |
@@ -39,9 +44,9 @@ L.s.
An activity was updated on the GEWIS website. See below for details.
-= $this->escapeHtml($activity->getName()->getText("en")) ?>
+= $this->escapeHtml($activity->getName()->getText(Languages::English)) ?>
-= $this->escapeHtml($activity->getDescription()->getText("en")) ?>
+= $this->escapeHtml($activity->getDescription()->getText(Languages::English)) ?>
@@ -54,11 +59,11 @@ An activity was updated on the GEWIS website. See below for details.
| Location: |
- = $this->escapeHtml($activity->getLocation()->getText("en")) ?> |
+ = $this->escapeHtml($activity->getLocation()->getText(Languages::English)) ?> |
| Costs: |
- = $this->escapeHtml($activity->getCosts()->getText("en")) ?> |
+ = $this->escapeHtml($activity->getCosts()->getText(Languages::English)) ?> |
diff --git a/module/Activity/view/email/activity.phtml b/module/Activity/view/email/activity.phtml
index f3717edc24..503a64e60f 100644
--- a/module/Activity/view/email/activity.phtml
+++ b/module/Activity/view/email/activity.phtml
@@ -1,12 +1,17 @@
+
For English, see below.
L.s.
Er is een nieuwe activiteit aangemaakt op de GEWIS website.
-= $this->escapeHtml($activity->getName()->getText("nl")) ?>
+= $this->escapeHtml($activity->getName()->getText(Languages::Dutch)) ?>
-= $this->escapeHtml($activity->getDescription()->getText("nl")) ?>
+= $this->escapeHtml($activity->getDescription()->getText(Languages::Dutch)) ?>
@@ -19,11 +24,11 @@ Er is een nieuwe activiteit aangemaakt op de GEWIS website.
| Locatie: |
- = $this->escapeHtml($activity->getLocation()->getText("nl")) ?> |
+ = $this->escapeHtml($activity->getLocation()->getText(Languages::Dutch)) ?> |
| Kosten: |
- = $this->escapeHtml($activity->getCosts()->getText("nl")) ?> |
+ = $this->escapeHtml($activity->getCosts()->getText(Languages::Dutch)) ?> |
@@ -39,9 +44,9 @@ L.s.
A new activity was created at the GEWIS website. See below for details.
-= $this->escapeHtml($activity->getName()->getText("en")) ?>
+= $this->escapeHtml($activity->getName()->getText(Languages::English)) ?>
-= $this->escapeHtml($activity->getDescription()->getText("en")) ?>
+= $this->escapeHtml($activity->getDescription()->getText(Languages::English)) ?>
@@ -54,11 +59,11 @@ A new activity was created at the GEWIS website. See below for details.
| Location: |
- = $this->escapeHtml($activity->getLocation()->getText("en")) ?> |
+ = $this->escapeHtml($activity->getLocation()->getText(Languages::English)) ?> |
| Costs: |
- = $this->escapeHtml($activity->getCosts()->getText("en")) ?> |
+ = $this->escapeHtml($activity->getCosts()->getText(Languages::English)) ?> |
diff --git a/module/Activity/view/email/activity_created_require_GEFLITST.phtml b/module/Activity/view/email/activity_created_require_GEFLITST.phtml
index ed44d9f802..4705e1d6ff 100644
--- a/module/Activity/view/email/activity_created_require_GEFLITST.phtml
+++ b/module/Activity/view/email/activity_created_require_GEFLITST.phtml
@@ -1,12 +1,17 @@
+
For English, see below.
L.s.
Er is een nieuwe activiteit aangemaakt op de GEWIS website waarvoor een fotograaf van GEFLITST nodig is.
-= $this->escapeHtml($activity->getName()->getText("nl")) ?>
+= $this->escapeHtml($activity->getName()->getText(Languages::Dutch)) ?>
-= $this->escapeHtml($activity->getDescription()->getText("nl")) ?>
+= $this->escapeHtml($activity->getDescription()->getText(Languages::Dutch)) ?>
@@ -23,9 +28,9 @@ L.s.
A new activity has been created on the GEWIS website that needs a photographer of GEFLITST.
-= $this->escapeHtml($activity->getName()->getText("en")) ?>
+= $this->escapeHtml($activity->getName()->getText(Languages::English)) ?>
-= $this->escapeHtml($activity->getDescription()->getText("en")) ?>
+= $this->escapeHtml($activity->getDescription()->getText(Languages::English)) ?>
diff --git a/module/Activity/view/email/activity_created_require_Zettle.phtml b/module/Activity/view/email/activity_created_require_Zettle.phtml
index 8f24fd5361..28bba51b47 100644
--- a/module/Activity/view/email/activity_created_require_Zettle.phtml
+++ b/module/Activity/view/email/activity_created_require_Zettle.phtml
@@ -1,12 +1,17 @@
+
For English, see below.
L.s.
Er is een nieuwe activiteit aangemaakt op de GEWIS website waarvoor een Zettle nodig is.
-= $this->escapeHtml($activity->getName()->getText("nl")) ?>
+= $this->escapeHtml($activity->getName()->getText(Languages::Dutch)) ?>
-= $this->escapeHtml($activity->getDescription()->getText("nl")) ?>
+= $this->escapeHtml($activity->getDescription()->getText(Languages::Dutch)) ?>
@@ -23,9 +28,9 @@ L.s.
A new activity has been created on the GEWIS website that needs Zettle for payments.
-= $this->escapeHtml($activity->getName()->getText("en")) ?>
+= $this->escapeHtml($activity->getName()->getText(Languages::English)) ?>
-= $this->escapeHtml($activity->getDescription()->getText("en")) ?>
+= $this->escapeHtml($activity->getDescription()->getText(Languages::English)) ?>
diff --git a/module/Application/src/Model/LocalisedText.php b/module/Application/src/Model/LocalisedText.php
index 52ee8bc4e7..29f8ed6d0c 100644
--- a/module/Application/src/Model/LocalisedText.php
+++ b/module/Application/src/Model/LocalisedText.php
@@ -69,21 +69,23 @@ public function updateValueNL(?string $valueNL): void
*
* @throws InvalidArgumentException
*/
- public function getText(?string $locale = null): ?string
+ public function getText(?Languages $locale = null): ?string
{
if (null === $locale) {
$locale = $this->getPreferredLocale();
+ } else {
+ $locale = $locale->getLangParam();
}
return match ($locale) {
- 'nl' => null !== $this->valueNL ? $this->valueNL : $this->valueEN,
- 'en' => null !== $this->valueEN ? $this->valueEN : $this->valueNL,
+ Languages::Dutch->getLangParam() => null !== $this->valueNL ? $this->valueNL : $this->valueEN,
+ Languages::English->getLangParam() => null !== $this->valueEN ? $this->valueEN : $this->valueNL,
default => throw new InvalidArgumentException('Locale not supported: ' . $locale),
};
}
/**
- * @return string the preferred language: either 'nl' or 'en'
+ * @psalm-return 'en'|'nl' - From {@link Languages::getLangParam()}.
*/
private function getPreferredLocale(): string
{
@@ -102,12 +104,12 @@ public function getExactText(?Languages $locale = null): ?string
if (null === $locale) {
$locale = $this->getPreferredLocale();
} else {
- $locale = $locale->value;
+ $locale = $locale->getLangParam();
}
return match ($locale) {
- 'nl' => $this->valueNL,
- 'en' => $this->valueEN,
+ Languages::Dutch->getLangParam() => $this->valueNL,
+ Languages::English->getLangParam() => $this->valueEN,
default => throw new InvalidArgumentException('Locale not supported: ' . $locale),
};
}
diff --git a/module/Frontpage/view/frontpage/frontpage/home.phtml b/module/Frontpage/view/frontpage/frontpage/home.phtml
index 7670c96fd7..c9bbe9661b 100644
--- a/module/Frontpage/view/frontpage/frontpage/home.phtml
+++ b/module/Frontpage/view/frontpage/frontpage/home.phtml
@@ -3,6 +3,7 @@
declare(strict_types=1);
use Activity\Model\Activity as ActivityModel;
+use Application\Model\Enums\Languages;
use Application\View\HelperTrait;
use Company\Model\CompanyBannerPackage as CompanyBannerPackageModel;
use Decision\Service\AclService as DecisionAclService;
@@ -177,7 +178,7 @@ $lang = $this->plugin('translate')->getTranslator()->getLocale();
- = $activity->getName()->getText($lang) ?>
+ = $activity->getName()->getText(Languages::fromLangParam($lang)) ?>
= ucfirst($this->dateFormat($activity->getBeginTime(), IntlDateFormatter::FULL, IntlDateFormatter::SHORT, $lang)); ?>