diff --git a/lib/SimpleSAML/XHTML/Template.php b/lib/SimpleSAML/XHTML/Template.php index 54674a59a7d119b8b44a7edc1f969555586590c0..e92684813334edbff51f9fe956e6b157d92ccad7 100644 --- a/lib/SimpleSAML/XHTML/Template.php +++ b/lib/SimpleSAML/XHTML/Template.php @@ -295,6 +295,29 @@ class SimpleSAML_XHTML_Template { } + /** + * Translate a attribute name. + * + * @param string $name The attribute name. + * @return string The translated attribute name, or the original attribute name if no translation was found. + */ + public function getAttributeTranslation($name) { + + /* Normalize attribute name. */ + $normName = strtolower($name); + $normName = str_replace(":", "_", $normName); + + /* Search the default attribute dictionary. */ + $dict = $this->getDictionary('attributes'); + if (array_key_exists('attribute_' . $normName, $dict)) { + return $this->getTranslation($dict['attribute_' . $normName]); + } + + /* No translations found. */ + return $name; + } + + /** * Translate a tag into the current language, with a fallback to english. * diff --git a/modules/consent/templates/consentform.php b/modules/consent/templates/consentform.php index d023eed33a9735207262692154608ce4b109d29a..3b737f81b3c1c50d40a21e3fd18596828c612453 100644 --- a/modules/consent/templates/consentform.php +++ b/modules/consent/templates/consentform.php @@ -137,10 +137,7 @@ function present_attributes($t, $attributes, $nameParent) { foreach ($attributes as $name => $value) { $nameraw = $name; - $nameTag = '{attributes:attribute_' . $parentStr . str_replace(":", "_", strtolower($name) ) . '}'; - if ($t->getTag($nameTag) !== NULL) { - $name = $t->t($nameTag); - } + $name = $t->getAttributeTranslation($nameraw); if (preg_match('/^child_/', $nameraw)) { // Insert child table diff --git a/modules/consentAdmin/templates/consentadmin.php b/modules/consentAdmin/templates/consentadmin.php index ae97cdf7d857ec3193c4869e8f24553b75f3c5e5..446b94e0632f77a2ca8f85cdd63738349ac923f8 100755 --- a/modules/consentAdmin/templates/consentadmin.php +++ b/modules/consentAdmin/templates/consentadmin.php @@ -99,7 +99,7 @@ TRSTART; if (isset($this->data['attribute_' . htmlspecialchars(strtolower($name)) ])) { $name = $this->data['attribute_' . htmlspecialchars(strtolower($name))]; } - $name = $this->t('attribute_'.strtolower($name)); // translate + $name = $this->getAttributeTranslation($name); // translate if (sizeof($value) > 1) { echo "<li>" . htmlspecialchars($name) . ":\n<ul>\n"; foreach ($value AS $v) { diff --git a/templates/status.php b/templates/status.php index 9c93364b1db313bfc200f159a036a9ae8e62d75f..faa37875ebaf8e0c4c368debcbca7edfe8409883 100644 --- a/templates/status.php +++ b/templates/status.php @@ -62,11 +62,8 @@ function present_attributes($t, $attributes, $nameParent) { foreach ($attributes as $name => $value) { $nameraw = $name; - $nameTag = '{attributes:attribute_' . $parentStr . str_replace(":", "_", strtolower($name) ) . '}'; - if ($t->getTag($nameTag) !== NULL) { - $name = $t->t($nameTag); - } - + $name = $t->getAttributeTranslation($nameraw); + if (preg_match('/^child_/', $nameraw)) { $parentName = preg_replace('/^child_/', '', $nameraw); foreach($value AS $child) {