protected function translate($key, $arguments = null, $mode = self::MODE_TRANSLATE)
    {
        $encoding = $this->getEncoding();

        if (false === $this->hasNamespace()) {
            throw new Doozr_I18n_Service_Exception(
                'Translation without namespace is not possible. Please set a namespace via setNamespace(...) '.
                'or addNamespace(...) first.'
            );
        }

        // Translate
        $translation = self::$translatorInterfaces[$encoding]->lookup(
            $key,
            $this->getTranslationTableUid(),
            $arguments
        );

        // encode result? => check runtimeEnvironment
        switch ($mode) {
            case self::MODE_TRANSLATE_ENCODE:
                $translation = htmlspecialchars($translation, ENT_QUOTES & ENT_DISALLOWED & ENT_HTML5, 'UTF-8');
                break;

            case self::MODE_TRANSLATE_ENCODE_PLUS:
                $translation = htmlentities($translation, ENT_QUOTES & ENT_DISALLOWED & ENT_HTML5, 'UTF-8', false);
                break;
        }

        return $translation;
    }
protected function translate($key, $arguments = null, $mode = self::MODE_TRANSLATE)
    {
        $encoding = $this->getEncoding();

        if (false === $this->hasNamespace()) {
            throw new Doozr_I18n_Service_Exception(
                'Translation without namespace is not possible. Please set a namespace via setNamespace(...) '.
                'or addNamespace(...) first.'
            );
        }

        // Translate
        $translation = self::$translatorInterfaces[$encoding]->lookup(
            $key,
            $this->getTranslationTableUid(),
            $arguments
        );

        // encode result? => check runtimeEnvironment
        switch ($mode) {
            case self::MODE_TRANSLATE_ENCODE:
                $translation = htmlspecialchars($translation, ENT_QUOTES & ENT_DISALLOWED & ENT_HTML5, 'UTF-8');
                break;

            case self::MODE_TRANSLATE_ENCODE_PLUS:
                $translation = htmlentities($translation, ENT_QUOTES & ENT_DISALLOWED & ENT_HTML5, 'UTF-8', false);
                break;
        }

        return $translation;
    }
protected function translate ( $ key , $ arguments = null , $ mode = self :: MODE_TRANSLATE ) { $ encoding = $ this -> getEncoding ( ) ; if ( false === $ this -> hasNamespace ( ) ) { throw new Doozr_I18n_Service_Exception ( 'Translation without namespace is not possible. Please set a namespace via setNamespace(...) ' . 'or addNamespace(...) first.' ) ; } // Translate $ translation = self :: $ translatorInterfaces [ $ encoding ] -> lookup ( $ key , $ this -> getTranslationTableUid ( ) , $ arguments ) ; // encode result? => check runtimeEnvironment switch ( $ mode ) { case self :: MODE_TRANSLATE_ENCODE : $ translation = htmlspecialchars ( $ translation , ENT_QUOTES & ENT_DISALLOWED & ENT_HTML5 , 'UTF-8' ) ; break ; case self :: MODE_TRANSLATE_ENCODE_PLUS : $ translation = htmlentities ( $ translation , ENT_QUOTES & ENT_DISALLOWED & ENT_HTML5 , 'UTF-8' , false ) ; break ; } return $ translation ; }
Translates a passes string.

This method is intend to act as the backend method for translation requests by _() __() and ___().

@param string     $key       The string to encrypt
@param mixed      $arguments The arguments used by translator for translation (e.g. inserting values)
@param int|string $mode      The runtimeEnvironment in which the translation is requested (normal, encode or encode-plus)

@author Benjamin Carl <opensource@clickalicious.de>

@return mixed STRING translation on success, otherwise FALSE

@throws Doozr_I18n_Service_Exception
Translates a passes string .