From 4442bb64770fc06b6425fa3e12193ef1a20e9989 Mon Sep 17 00:00:00 2001 From: Tim van Dijen <tvdijen@gmail.com> Date: Thu, 9 Aug 2018 11:59:32 +0200 Subject: [PATCH] Move inline translations away from template --- modules/consentAdmin/templates/consentadmin.php | 8 +++----- modules/consentAdmin/www/consentAdmin.php | 7 +++++++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/modules/consentAdmin/templates/consentadmin.php b/modules/consentAdmin/templates/consentadmin.php index dfdeb7b76..94f827f14 100644 --- a/modules/consentAdmin/templates/consentadmin.php +++ b/modules/consentAdmin/templates/consentadmin.php @@ -23,14 +23,12 @@ $hide_text = $this->t('{consentAdmin:consentadmin:hide}'); $attributes_text = $this->t('{consentAdmin:consentadmin:attributes_text}'); foreach ($spList as $spName => $spValues) { - $this->getTranslator()->includeInlineTranslation('spname', $spValues['name']); - $this->getTranslator()->includeInlineTranslation('spdescription', $spValues['description']); if (!is_null($spValues['serviceurl'])) { - $htmlSpName = '<a href="'.$spValues['serviceurl'].'" style="color: black; font-weight: bold;">'.htmlspecialchars($this->t('spname', array(), false, true)).'</a>'; + $htmlSpName = '<a href="'.$spValues['serviceurl'].'" style="color: black; font-weight: bold;">'.htmlspecialchars($spValues['name']).'</a>'; } else { - $htmlSpName = htmlspecialchars($this->t('spname', array(), false, true)); + $htmlSpName = htmlspecialchars($spValues['name']); } - $spDescription = htmlspecialchars($this->t('spdescription', array(), false, true)); + $spDescription = htmlspecialchars($spValues['description']); $checkedAttr = $spValues['consentStatus'] == 'ok' ? 'checked="checked"' : ''; $consentValue = $spValues['consentValue']; $consentText = $spValues['consentStatus'] == 'changed' ? "attributes has changed" : ""; diff --git a/modules/consentAdmin/www/consentAdmin.php b/modules/consentAdmin/www/consentAdmin.php index 57b22db43..48921aa93 100644 --- a/modules/consentAdmin/www/consentAdmin.php +++ b/modules/consentAdmin/www/consentAdmin.php @@ -268,6 +268,13 @@ foreach ($all_sp_metadata as $sp_entityid => $sp_values) { // Add a URL to the service if present in metadata $sp_service_url = isset($sp_metadata['ServiceURL']) ? $sp_metadata['ServiceURL'] : null; + // Translate SP name and description + $translator->includeInlineTranslation('spname', $sp_name); + $translator->includeInlineTranslation('spdescription', $sp_description); + + $sp_name = $translator->getPreferredTranslation($translator->getTag('spname')); + $sp_description = $translator->getPreferredTranslation($translator->getTag('spdescription')); + // Fill out array for the template $sp_list[$sp_entityid] = array( 'spentityid' => $sp_entityid, -- GitLab