SimpleSAML\Locale\Translate::getAttributeTranslation PHP Метод

getAttributeTranslation() публичный Метод

Translate the name of an attribute.
public getAttributeTranslation ( string $name ) : string
$name string The attribute name.
Результат 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);
        // 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->getPreferredTranslation($dict[$normName]);
            }
        }
        // search the default attribute dictionary
        $dict = $this->getDictionary('attributes');
        if (array_key_exists('attribute_' . $normName, $dict)) {
            return $this->getPreferredTranslation($dict['attribute_' . $normName]);
        }
        // no translations found
        return $name;
    }

Usage Example

Пример #1
0
 /**
  * @param $name
  *
  * @return string
  * @deprecated This method will be removed in SSP 2.0. Please use \SimpleSAML\Locale\Language::getLanguage()
  * instead.
  */
 public function getAttributeTranslation($name)
 {
     return $this->translator->getAttributeTranslation($name);
 }