diff --git a/public/modules/custom/helfi_etusivu/src/Enum/ServiceMapLink.php b/public/modules/custom/helfi_etusivu/src/Enum/ServiceMapLink.php index 53b2d352..cbf2dfcc 100644 --- a/public/modules/custom/helfi_etusivu/src/Enum/ServiceMapLink.php +++ b/public/modules/custom/helfi_etusivu/src/Enum/ServiceMapLink.php @@ -21,10 +21,10 @@ enum ServiceMapLink { */ public function link(): string { return match($this) { - ServiceMapLink::ROADWORK_EVENTS => 'eCBuut', - ServiceMapLink::CITYBIKE_STATIONS_STANDS => 'eCAduu', - ServiceMapLink::STREET_PARK_PROJECTS => 'eCBJGT', - ServiceMapLink::PLANS_IN_PROCESS => 'eCCv3K', + ServiceMapLink::ROADWORK_EVENTS => 'eDAB7W', + ServiceMapLink::CITYBIKE_STATIONS_STANDS => 'eDFeCc', + ServiceMapLink::STREET_PARK_PROJECTS => 'eDBTcc', + ServiceMapLink::PLANS_IN_PROCESS => 'eDB7Rk', }; } diff --git a/public/modules/custom/helfi_etusivu/src/Servicemap.php b/public/modules/custom/helfi_etusivu/src/Servicemap.php index bef3f60c..80168e44 100644 --- a/public/modules/custom/helfi_etusivu/src/Servicemap.php +++ b/public/modules/custom/helfi_etusivu/src/Servicemap.php @@ -6,6 +6,8 @@ use Drupal\Component\Utility\Xss; use Drupal\Core\Language\LanguageManagerInterface; +use Drupal\Core\StringTranslation\StringTranslationTrait; +use Drupal\Core\StringTranslation\TranslatableMarkup; use Drupal\Core\Url; use Drupal\helfi_etusivu\Enum\ServiceMapLink; use GuzzleHttp\ClientInterface; @@ -18,6 +20,8 @@ */ final class Servicemap { + use StringTranslationTrait; + /** * API URL for querying data. * @@ -31,6 +35,26 @@ final class Servicemap { */ private const SITE_URL = 'https://kartta.hel.fi/'; + /** + * Gets the address label for a given service map link. + * + * @param \Drupal\helfi_etusivu\Enum\ServiceMapLink $link + * The service map link option. + * @param string $address + * The address for which the label is generated. + * + * @return \Drupal\Core\StringTranslation\TranslatableMarkup + * The address label corresponding to the service map link. + */ + private function getAddressLabel(ServiceMapLink $link, string $address) : TranslatableMarkup { + return match($link) { + ServiceMapLink::ROADWORK_EVENTS => $this->t('Street works and events near the address @address', ['@address' => $address], ['context' => 'Helsinki near you address label']), + ServiceMapLink::CITYBIKE_STATIONS_STANDS => $this->t('City bike stations and bicycle racks near the address @address', ['@address' => $address], ['context' => 'Helsinki near you address label']), + ServiceMapLink::STREET_PARK_PROJECTS => $this->t('Street and park projects near the address @address', ['@address' => $address], ['context' => 'Helsinki near you address label']), + ServiceMapLink::PLANS_IN_PROCESS => $this->t('Plans under preparation near the address @address', ['@address' => $address], ['context' => 'Helsinki near you address label']), + }; + } + /** * Constructs a new instance. * @@ -104,8 +128,9 @@ public function query(string $address, int $page_size = 1) : array { public function getLink(ServiceMapLink $link, string $address) : string { $langcode = $this->languageManager->getCurrentLanguage()->getId(); $query = [ - 'link' => $link->link(), + 'addresslabel' => $this->getAddressLabel($link, $address), 'addresslocation' => Xss::filter($address), + 'link' => $link->link(), 'setlanguage' => $langcode, ]; diff --git a/public/modules/custom/helfi_etusivu/translations/fi.po b/public/modules/custom/helfi_etusivu/translations/fi.po index 44444406..3bee9a9d 100644 --- a/public/modules/custom/helfi_etusivu/translations/fi.po +++ b/public/modules/custom/helfi_etusivu/translations/fi.po @@ -155,7 +155,7 @@ msgstr "Katu- ja puistohankkeet kartalla" msgctxt "Helsinki near you" msgid "Plans in process on map" -msgstr "Valmisteilla oleva kaavat kartalla" +msgstr "Valmisteilla olevat kaavat kartalla" msgctxt "Helsinki near you" msgid "Please enter an address" @@ -184,3 +184,19 @@ msgstr "Yksi osoite-ehdotus löytyi." msgctxt "Helsinki near you form" msgid "@selectedItem @position of @count is highlighted" msgstr "Vaihtoehto numero @position: @selectedItem korostettu. Vaihtoehtojen määrä: @count." + +msgctxt "Helsinki near you address label" +msgid "Street works and events near the address @address" +msgstr "Katutyöt ja tapahtumat lähellä osoitetta @address" + +msgctxt "Helsinki near you address label" +msgid "City bike stations and bicycle racks near the address @address" +msgstr "Kaupunkipyöräasemat ja pyörätelineet lähellä osoitetta @address" + +msgctxt "Helsinki near you address label" +msgid "Street and park projects near the address @address" +msgstr "Katu- ja puistohankkeet lähellä osoitetta @address" + +msgctxt "Helsinki near you address label" +msgid "Plans under preparation near the address @address" +msgstr "Valmisteilla olevat kaavat lähellä osoitetta @address" diff --git a/public/modules/custom/helfi_etusivu/translations/sv.po b/public/modules/custom/helfi_etusivu/translations/sv.po index 4a9bd6a5..29a5d1ef 100644 --- a/public/modules/custom/helfi_etusivu/translations/sv.po +++ b/public/modules/custom/helfi_etusivu/translations/sv.po @@ -173,3 +173,19 @@ msgstr "Det finns ett resultat tillgängligt." msgctxt "Helsinki near you form" msgid "@selectedItem @position of @count is highlighted" msgstr "@selectedItem @position av @count är markerad" + +msgctxt "Helsinki near you address label" +msgid "Street works and events near the address @address" +msgstr "Gatuarbeten och evenemang nära adressen @address" + +msgctxt "Helsinki near you address label" +msgid "City bike stations and bicycle racks near the address @address" +msgstr "Stadscykelstationer och cykelställ nära adressen @address" + +msgctxt "Helsinki near you address label" +msgid "Street and park projects near the address @address" +msgstr "Gatu- och parkprojekt nära adressen @address" + +msgctxt "Helsinki near you address label" +msgid "Plans under preparation near the address @address" +msgstr "Detaljplaner under beredning nära adressen @address"