Skip to content
Snippets Groups Projects
Commit d6d7b56f authored by Olav Morken's avatar Olav Morken
Browse files

Add support for extra attribute dictionaries.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@2582 44740490-163a-0410-bde0-09ae8108e29a
parent 833b3801
No related branches found
No related tags found
No related merge requests found
...@@ -202,7 +202,33 @@ $config = array ( ...@@ -202,7 +202,33 @@ $config = array (
*/ */
'language.available' => array('en', 'no', 'nn', 'se', 'da', 'de', 'sv', 'fi', 'es', 'fr', 'it', 'nl', 'lb', 'cs', 'sl', 'lt', 'hr', 'hu', 'pl', 'pt', 'pt-BR', 'tr'), 'language.available' => array('en', 'no', 'nn', 'se', 'da', 'de', 'sv', 'fi', 'es', 'fr', 'it', 'nl', 'lb', 'cs', 'sl', 'lt', 'hr', 'hu', 'pl', 'pt', 'pt-BR', 'tr'),
'language.default' => 'en', 'language.default' => 'en',
/*
* Extra dictionary for attribute names.
* This can be used to define local attributes.
*
* The format of the parameter is a string with <module>:<dictionary>.
*
* Specifying this option will cause us to look for modules/<module>/dictionaries/<dictionary>.definition.json
* The dictionary should look something like:
*
* {
* "firstattribute": {
* "en": "English name",
* "no": "Norwegian name"
* },
* "secondattribute": {
* "en": "English name",
* "no": "Norwegian name"
* }
* }
*
* Note that all attribute names in the dictionary must in lowercase.
*
* Example: 'attributes.extradictionary' => 'ourmodule:ourattributes',
*/
'attributes.extradictionary' => NULL,
/* /*
* Which theme directory should be used? * Which theme directory should be used?
*/ */
......
...@@ -307,6 +307,15 @@ class SimpleSAML_XHTML_Template { ...@@ -307,6 +307,15 @@ class SimpleSAML_XHTML_Template {
$normName = strtolower($name); $normName = strtolower($name);
$normName = str_replace(":", "_", $normName); $normName = str_replace(":", "_", $normName);
/* Check for an extra dictionary. */
$extraDict = $this->configuration->getString('attributes.extradictionary', NULL);
if ($extraDict !== NULL) {
$dict = $this->getDictionary($extraDict);
if (array_key_exists($normName, $dict)) {
return $this->getTranslation($dict[$normName]);
}
}
/* Search the default attribute dictionary. */ /* Search the default attribute dictionary. */
$dict = $this->getDictionary('attributes'); $dict = $this->getDictionary('attributes');
if (array_key_exists('attribute_' . $normName, $dict)) { if (array_key_exists('attribute_' . $normName, $dict)) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment