Skip to content

Commit d6d7b56

Browse files
committed
Add support for extra attribute dictionaries.
git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@2582 44740490-163a-0410-bde0-09ae8108e29a
1 parent 833b380 commit d6d7b56

2 files changed

Lines changed: 36 additions & 1 deletion

File tree

config-templates/config.php

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,33 @@
202202
*/
203203
'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'),
204204
'language.default' => 'en',
205-
205+
206+
/*
207+
* Extra dictionary for attribute names.
208+
* This can be used to define local attributes.
209+
*
210+
* The format of the parameter is a string with <module>:<dictionary>.
211+
*
212+
* Specifying this option will cause us to look for modules/<module>/dictionaries/<dictionary>.definition.json
213+
* The dictionary should look something like:
214+
*
215+
* {
216+
* "firstattribute": {
217+
* "en": "English name",
218+
* "no": "Norwegian name"
219+
* },
220+
* "secondattribute": {
221+
* "en": "English name",
222+
* "no": "Norwegian name"
223+
* }
224+
* }
225+
*
226+
* Note that all attribute names in the dictionary must in lowercase.
227+
*
228+
* Example: 'attributes.extradictionary' => 'ourmodule:ourattributes',
229+
*/
230+
'attributes.extradictionary' => NULL,
231+
206232
/*
207233
* Which theme directory should be used?
208234
*/

lib/SimpleSAML/XHTML/Template.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,15 @@ public function getAttributeTranslation($name) {
307307
$normName = strtolower($name);
308308
$normName = str_replace(":", "_", $normName);
309309

310+
/* Check for an extra dictionary. */
311+
$extraDict = $this->configuration->getString('attributes.extradictionary', NULL);
312+
if ($extraDict !== NULL) {
313+
$dict = $this->getDictionary($extraDict);
314+
if (array_key_exists($normName, $dict)) {
315+
return $this->getTranslation($dict[$normName]);
316+
}
317+
}
318+
310319
/* Search the default attribute dictionary. */
311320
$dict = $this->getDictionary('attributes');
312321
if (array_key_exists('attribute_' . $normName, $dict)) {

0 commit comments

Comments
 (0)