diff --git a/lib/SimpleSAML/Locale/Translate.php b/lib/SimpleSAML/Locale/Translate.php index 9285aaf90eb81dbf7efc6dde406d9c75a9a1d436..4c26b670da39dd9cf51e955c089fb02765b85c56 100644 --- a/lib/SimpleSAML/Locale/Translate.php +++ b/lib/SimpleSAML/Locale/Translate.php @@ -143,45 +143,6 @@ class Translate } - /** - * Retrieve the preferred translation of a given text. - * - * @param array $translations The translations, as an associative array with language => text mappings. - * - * @return string The preferred translation. - * - * @throws \Exception If there's no suitable translation. - */ - public function getPreferredTranslation(array $translations): string - { - // look up translation of tag in the selected language - $selected_language = $this->language->getLanguage(); - if (array_key_exists($selected_language, $translations)) { - return $translations[$selected_language]; - } - - // look up translation of tag in the default language - $default_language = $this->language->getDefaultLanguage(); - if (array_key_exists($default_language, $translations)) { - return $translations[$default_language]; - } - - // check for english translation - if (array_key_exists('en', $translations)) { - return $translations['en']; - } - - // pick the first translation available - if (count($translations) > 0) { - $languages = array_keys($translations); - return $translations[$languages[0]]; - } - - // we don't have anything to return - throw new \Exception('Nothing to return from translation.'); - } - - /** * Translate the name of an attribute. * diff --git a/modules/admin/lib/Controller/Test.php b/modules/admin/lib/Controller/Test.php index b93e80e6b50a7f703af020a977db63bd3fa90c90..383debf0a8a696d65b274f7c5bddb5eabbfeedcc 100644 --- a/modules/admin/lib/Controller/Test.php +++ b/modules/admin/lib/Controller/Test.php @@ -180,10 +180,7 @@ class Test "NameId" => [$nameId->getValue()], ]; if ($nameId->getFormat() !== null) { - $format = $translator->getPreferredTranslation( - $translator->getTag('{status:subject_format}') ?? ['en' => 'Format'] - ); - $list[$format] = [$nameId->getFormat()]; + $list['Format'] = [$nameId->getFormat()]; } if ($nameId->getNameQualifier() !== null) { $list['NameQualifier'] = [$nameId->getNameQualifier()]; @@ -327,10 +324,7 @@ class Test 'NameID' => [$nameID->getValue()], ]; if ($nameID->getFormat() !== null) { - $format = $t->getPreferredTranslation( - $t->getTag('{status:subject_format}') ?? ['en' => 'Format'] - ); - $eptid[$format] = [$nameID->getFormat()]; + $eptid['Format'] = [$nameID->getFormat()]; } if ($nameID->getNameQualifier() !== null) { $eptid['NameQualifier'] = [$nameID->getNameQualifier()]; diff --git a/modules/saml/templates/proxy/invalid_session.twig b/modules/saml/templates/proxy/invalid_session.twig index f9acc7a9881e7b12c7b5ff432b80b091ee6dc6c7..593adca27ace9b143b6209ab459279102453ac0d 100644 --- a/modules/saml/templates/proxy/invalid_session.twig +++ b/modules/saml/templates/proxy/invalid_session.twig @@ -3,7 +3,7 @@ {% block content %} <h2>{{ 'Invalid Identity Provider'|trans }}</h2> - <p>{{ 'You already have a valid session with an identity provider (<em>%IDP%</em>) that is not accepted by <em>%SP%</em>. Would you like to log out from your existing session and log in again with another identity provider?'|trans({"%IDP%": idp_name, "%SP%": sp_name}, "app")|raw</p> + <p>{{ 'You already have a valid session with an identity provider (<em>%IDP%</em>) that is not accepted by <em>%SP%</em>. Would you like to log out from your existing session and log in again with another identity provider?'|trans({"%IDP%": idp_name|translateFromArray|default(idp_entityid), "%SP%": sp_name|translateFromArray|default(sp_entityid)}, "app")|raw</p> <form method="post" action="?"> <input type="hidden" name="AuthState" value="{{ AuthState|escape('html') }}" /> <input type="submit" name="continue" value="{{ 'Yes, continue'|trans }}" /> diff --git a/modules/saml/www/proxy/invalid_session.php b/modules/saml/www/proxy/invalid_session.php index 30c18095d309b9ece4d2a5ba71ad6a2207e440d7..9dd31b5250cd9e1dd9846df3dfa86c57a2d8f2c9 100644 --- a/modules/saml/www/proxy/invalid_session.php +++ b/modules/saml/www/proxy/invalid_session.php @@ -56,21 +56,19 @@ $idpmdcfg = $state['saml:sp:IdPMetadata']; /** @var \SimpleSAML\Configuration $idpmdcfg */ $idpmd = $idpmdcfg->toArray(); if (array_key_exists('name', $idpmd)) { - $template->data['idp_name'] = $translator->getPreferredTranslation($idpmd['name']); + $template->data['idp_name'] = $idpmd['name']; } elseif (array_key_exists('OrganizationDisplayName', $idpmd)) { - $template->data['idp_name'] = $translator->getPreferredTranslation($idpmd['OrganizationDisplayName']); -} else { - $template->data['idp_name'] = $idpmd['entityid']; + $template->data['idp_name'] = $idpmd['OrganizationDisplayName']; } +$template->data['idp_entityid'] = $idpmd['entityid']; // get the name of the SP $spmd = $state['SPMetadata']; if (array_key_exists('name', $spmd)) { - $template->data['sp_name'] = $translator->getPreferredTranslation($spmd['name']); + $template->data['sp_name'] = $spmd['name']; } elseif (array_key_exists('OrganizationDisplayName', $spmd)) { - $template->data['sp_name'] = $translator->getPreferredTranslation($spmd['OrganizationDisplayName']); -} else { - $template->data['sp_name'] = $spmd['entityid']; + $template->data['sp_name'] = $spmd['OrganizationDisplayName']; } +$template->data['sp_entityid'] = $spmd['entityid']; $template->send();