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

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

This method retrieves a tag as an array with language => string mappings.
public getTag ( string $tag ) : array
$tag string The tag name. The tag name can also be on the form '{:}', to retrieve a tag from the specific dictionary.
Результат array An associative array with language => string mappings, or null if the tag wasn't found.
    public function getTag($tag)
    {
        assert('is_string($tag)');
        // first check translations loaded by the includeInlineTranslation and includeLanguageFile methods
        if (array_key_exists($tag, $this->langtext)) {
            return $this->langtext[$tag];
        }
        // check whether we should use the default dictionary or a dictionary specified in the tag
        if (substr($tag, 0, 1) === '{' && preg_match('/^{((?:\\w+:)?\\w+?):(.*)}$/D', $tag, $matches)) {
            $dictionary = $matches[1];
            $tag = $matches[2];
        } else {
            $dictionary = $this->defaultDictionary;
            if ($dictionary === null) {
                // we don't have any dictionary to load the tag from
                return null;
            }
        }
        $dictionary = $this->getDictionary($dictionary);
        if (!array_key_exists($tag, $dictionary)) {
            return null;
        }
        return $dictionary[$tag];
    }

Usage Example

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