57            $backtrace = debug_backtrace();
 
   58            $where = $backtrace[0][
'file'].
':'.$backtrace[0][
'line'];
 
   60                'Deprecated use of new SimpleSAML\Locale\Translate(...) at '.$where.
 
   61                '. The last parameter is now a dictionary name, which should not end in ".php".' 
   92        assert(
'is_string($name)');
 
   94        if (!array_key_exists(
$name, $this->dictionaries)) {
 
   95            $sepPos = strpos(
$name, 
':');
 
   96            if ($sepPos !== 
false) {
 
   98                $fileName = substr(
$name, $sepPos + 1);
 
  101                $dictDir = $this->configuration->getPathValue(
'dictionarydir', 
'dictionaries/');
 
  108        return $this->dictionaries[
$name];
 
  122        assert(
'is_string($tag)');
 
  125        if (array_key_exists(
$tag, $this->langtext)) {
 
  126            return $this->langtext[
$tag];
 
  130        if (substr(
$tag, 0, 1) === 
'{' && preg_match(
'/^{((?:\w+:)?\w+?):(.*)}$/D', 
$tag, $matches)) {
 
  131            $dictionary = $matches[1];
 
  135            if ($dictionary === 
null) {
 
  142        if (!array_key_exists(
$tag, $dictionary)) {
 
  146        return $dictionary[
$tag];
 
  161        assert(
'is_array($translations)');
 
  164        $selected_language = $this->language->getLanguage();
 
  165        if (array_key_exists($selected_language, $translations)) {
 
  166            return $translations[$selected_language];
 
  170        $default_language = $this->language->getDefaultLanguage();
 
  171        if (array_key_exists($default_language, $translations)) {
 
  172            return $translations[$default_language];
 
  176        if (array_key_exists(
'en', $translations)) {
 
  177            return $translations[
'en'];
 
  181        if (count($translations) > 0) {
 
  182            $languages = array_keys($translations);
 
  183            return $translations[$languages[0]];
 
  187        throw new \Exception(
'Nothing to return from translation.');
 
  201        $normName = strtolower(
$name);
 
  202        $normName = str_replace(
":", 
"_", $normName);
 
  205        $extraDict = $this->configuration->getString(
'attributes.extradictionary', 
null);
 
  206        if ($extraDict !== 
null) {
 
  208            if (array_key_exists($normName, $dict)) {
 
  215        if (array_key_exists(
'attribute_'.$normName, $dict)) {
 
  261        $replacements = array(),
 
  262        $fallbackdefault = 
true, 
 
  263        $oldreplacements = array(), 
 
  266        $backtrace = debug_backtrace();
 
  267        $where = $backtrace[0][
'file'].
':'.$backtrace[0][
'line'];
 
  268        if (!$fallbackdefault) {
 
  270                'Deprecated use of new SimpleSAML\Locale\Translate::t(...) at '.$where.
 
  271                '. This parameter will go away, the fallback will become' .
 
  272                ' identical to the $tag in 2.0.' 
  275        if (!is_array($replacements)) {
 
  280                'Deprecated use of SimpleSAML\Locale\Translate::t(...) at '.$where.
 
  281                '. Please update the code to use the new style of parameters.' 
  285            if (!$replacements && $this->
getTag(
$tag) === 
null) {
 
  287                    'Code which uses $fallbackdefault === FALSE should be updated to use the getTag() method instead.' 
  292            $replacements = $oldreplacements;
 
  295        if (is_array(
$tag)) {
 
  298                'Deprecated use of new SimpleSAML\Locale\Translate::t(...) at '.$where.
 
  299                '. The $tag-parameter can only be a string in 2.0.' 
  303            if ($tagData === 
null) {
 
  312        foreach ($replacements as $k => $v) {
 
  317            $translated = str_replace($k, $v, $translated);
 
  335            return 'not translated ('.$tag.
')';
 
  354        if (is_string($translation)) {
 
  355            $translation = array(
'en' => $translation);
 
  356        } elseif (!is_array($translation)) {
 
  357            throw new \Exception(
"Inline translation should be string or array. Is ".gettype($translation).
" now!");
 
  361        $this->langtext[
$tag] = $translation;
 
  376        if (!empty($otherConfig)) {
 
  377            $filebase = $otherConfig->getPathValue(
'dictionarydir', 
'dictionaries/');
 
  379            $filebase = $this->configuration->getPathValue(
'dictionarydir', 
'dictionaries/');
 
  384        $this->langtext = array_merge($this->langtext, 
$lang);
 
  397        $definitionFile = 
$filename.
'.definition.json';
 
  398        assert(
'file_exists($definitionFile)');
 
  400        $fileContent = file_get_contents($definitionFile);
 
  401        $lang = json_decode($fileContent, 
true);
 
  408        $translationFile = 
$filename.
'.translation.json';
 
  409        if (file_exists($translationFile)) {
 
  410            $fileContent = file_get_contents($translationFile);
 
  411            $moreTrans = json_decode($fileContent, 
true);
 
  412            if (!empty($moreTrans)) {
 
  413                $lang = array_merge_recursive(
$lang, $moreTrans);
 
  431        assert(
'file_exists($phpFile)');
 
  452        assert(
'is_string($filename)');
 
  456        $jsonFile = 
$filename.
'.definition.json';
 
  457        if (file_exists($jsonFile)) {
 
  462        if (file_exists($phpFile)) {
 
  467            $_SERVER[
'PHP_SELF'].
' - Template: Could not find dictionary file at ['.
$filename.
']' 
  477        if (func_num_args() === 1) {
 
  481        $args = array_slice(func_get_args(), 1);
 
  483        return strtr(
$text, is_array($args[0]) ? $args[0] : $args);
 
  491        if (func_num_args() === 3) {
 
  495        $args = array_slice(func_get_args(), 3);
 
  497        return strtr(
$text, is_array($args[0]) ? $args[0] : $args);
 
An exception for terminatinating execution or to throw for unit testing.
getAttributeTranslation($name)
Translate the name of an attribute.
__construct(\SimpleSAML_Configuration $configuration, $defaultDictionary=null)
Constructor.
readDictionaryJSON($filename)
Read a dictionary file in JSON format.
readDictionaryFile($filename)
Read a dictionary file.
static noop($tag)
Mark a string for translation without translating it.
getLanguage()
Return the internal language object used by this translator.
includeLanguageFile($file, $otherConfig=null)
Include a language file from the dictionaries directory.
static translateSingularGettext($original)
t( $tag, $replacements=array(), $fallbackdefault=true, $oldreplacements=array(), $striptags=false)
Translate a tag into the current language, with a fallback to english.
static translatePluralGettext($original, $plural, $value)
getDictionary($name)
This method retrieves a dictionary with the name given.
readDictionaryPHP($filename)
Read a dictionary file in PHP format.
$defaultDictionary
The default dictionary.
getStringNotTranslated($tag, $fallbacktag)
Return the string that should be used when no translation was found.
getTag($tag)
This method retrieves a tag as an array with language => string mappings.
$dictionaries
Associative array of dictionaries.
includeInlineTranslation($tag, $translation)
Include a translation inline instead of putting translations in dictionaries.
getPreferredTranslation($translations)
Retrieve the preferred translation of a given text.
static getModuleDir($module)
Retrieve the base directory for a module.
if(function_exists( 'posix_getuid') &&posix_getuid()===0) if(!array_key_exists('t', $options)) $tag
if($modEnd===false) $module
if(!file_exists("$old.txt")) if( $old===$new) if(file_exists("$new.txt")) $file
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']