public function translate($key, $dictionaryName = null) {
        //If a dictionary name is specified,
        if(null !== $dictionaryName) {
            // Use the nearest dictionary by this name,
            // in current file upwards.
            $dictionary = $this->getDictionary($dictionaryName);
            if (null == $dictionary) {
                throw new DictionaryNotFoundException($dictionaryName, $this->getFilename(), $this->tag->getLineNumber());
            }
            try {
                return $dictionary->translate($key);
            } catch (DictionaryEntryNotFoundException $ex) {
                $ex->setDictionaryName($dictionaryName);
                $ex->setTemplateFile($this->getFilename(), $this->tag->getLineNumber());
                throw $ex;
            }
        }

        //Walk the array of dictionaries, to try the lookup in all of them.
        foreach($this->dictionaries[count($this->dictionaries) - 1] as $dictionary) {
            try {
                return $dictionary->translate($key);
            } catch(DictionaryEntryNotFoundException $ex) {
                // It is perfectly legitimate to not find a key in the first few registered dictionaries.
                // But if in the end, we still didn't find a translation, it will be time to
                // throw the exception.
            }
        }

        throw new DictionaryEntryNotFoundException($key, $this->getFilename(), $this->tag->getLineNumber());
    }
public function translate($key, $dictionaryName = null) {
        //If a dictionary name is specified,
        if(null !== $dictionaryName) {
            // Use the nearest dictionary by this name,
            // in current file upwards.
            $dictionary = $this->getDictionary($dictionaryName);
            if (null == $dictionary) {
                throw new DictionaryNotFoundException($dictionaryName, $this->getFilename(), $this->tag->getLineNumber());
            }
            try {
                return $dictionary->translate($key);
            } catch (DictionaryEntryNotFoundException $ex) {
                $ex->setDictionaryName($dictionaryName);
                $ex->setTemplateFile($this->getFilename(), $this->tag->getLineNumber());
                throw $ex;
            }
        }

        //Walk the array of dictionaries, to try the lookup in all of them.
        foreach($this->dictionaries[count($this->dictionaries) - 1] as $dictionary) {
            try {
                return $dictionary->translate($key);
            } catch(DictionaryEntryNotFoundException $ex) {
                // It is perfectly legitimate to not find a key in the first few registered dictionaries.
                // But if in the end, we still didn't find a translation, it will be time to
                // throw the exception.
            }
        }

        throw new DictionaryEntryNotFoundException($key, $this->getFilename(), $this->tag->getLineNumber());
    }
public function translate ( $ key , $ dictionaryName = null ) { //If a dictionary name is specified, if ( null !== $ dictionaryName ) { // Use the nearest dictionary by this name, // in current file upwards. $ dictionary = $ this -> getDictionary ( $ dictionaryName ) ; if ( null == $ dictionary ) { throw new DictionaryNotFoundException ( $ dictionaryName , $ this -> getFilename ( ) , $ this -> tag -> getLineNumber ( ) ) ; } try { return $ dictionary -> translate ( $ key ) ; } catch ( DictionaryEntryNotFoundException $ ex ) { $ ex -> setDictionaryName ( $ dictionaryName ) ; $ ex -> setTemplateFile ( $ this -> getFilename ( ) , $ this -> tag -> getLineNumber ( ) ) ; throw $ ex ; } } //Walk the array of dictionaries, to try the lookup in all of them. foreach ( $ this -> dictionaries [ count ( $ this -> dictionaries ) - 1 ] as $ dictionary ) { try { return $ dictionary -> translate ( $ key ) ; } catch ( DictionaryEntryNotFoundException $ ex ) { // It is perfectly legitimate to not find a key in the first few registered dictionaries. // But if in the end, we still didn't find a translation, it will be time to // throw the exception. } } throw new DictionaryEntryNotFoundException ( $ key , $ this -> getFilename ( ) , $ this -> tag -> getLineNumber ( ) ) ; }
If a dictionary name is specified, performs the lookup only in this one.
If the dictionary name is not in the perimeter of the current file,
bubbles up the translation request if a parent file exists.
Finally throws DictionaryNotFoundException if the dictionary name is not
found anywhere in the hierarchy.

If the entry is not found in the current file's named dictionary,
throws DictionaryEntryNotFoundException.

If no dictionary name parameter is specified, performs the lookup in every dictionary attached
to the current FIG file, and only if not found in any, bubbles up the request.

@param $key
@param string $dictionaryName
@return string
@throws DictionaryEntryNotFoundException
@throws DictionaryNotFoundException
If a dictionary name is specified performs the lookup only in this one . If the dictionary name is not in the perimeter of the current file bubbles up the translation request if a parent file exists . Finally throws DictionaryNotFoundException if the dictionary name is not found anywhere in the hierarchy .