Translates a string in the specified context.

@since [*next-version*]

@param string     $string  The string to translate.
@param mixed|null $context The context to be used for translation.

@return string The translated string.
973926
protected function _translate($string, $context = null)
    {
        if (!(($translator = $this->_getTranslator()) instanceof StringTranslatorInterface)) {
            return $string;
        }

        return $translator->translate($string, $context);
    }
1141305
protected function translate($string)
    {
        $translated = $this->app['translator']->get($string);

        return is_string($translated) ? $translated : $string;
    }
359117
protected function escapeLiteral($text, $context)
	{
		if ($context === 'raw')
		{
			return $text;
		}

		$escapeMode = ($context === 'attribute') ? ENT_COMPAT : ENT_NOQUOTES;

		return htmlspecialchars($text, $escapeMode);
	}
1141962
protected function translate($string)
    {
        if ($this->hasTranslator()) {
            return $this->getTranslator()->translate($string, $this->getTranslatorTextDomain());
        }

        return $string;
    }
1171587
public function translate($string)
    {
        $translated = isset($this->translations[$string]) ? $this->translations[$string] : $string;
        if ($translated == $string)
        {
            $this->logUntranslatedString($string);
        }

        return $translated;
    }
119341
protected function execute($string)
    {
        foreach ($this->patternsAndReplacements as $patternAndReplacement) {
            $tmp = preg_replace("/".$patternAndReplacement->pattern."/s", $patternAndReplacement->replacement, $string);
            if ($tmp === null) {
                InvalidExpression::invalidRegex($patternAndReplacement->pattern, $patternAndReplacement->replacement);
            } else {
                $string = $tmp;
            }
        }
        
        return $string;
    }
1160414
private function getTranslations($string, $params)
    {
        $out = [];
        $messages = $this->translationsHelper->getTranslations($string, $params);
        foreach ($messages as $message) {
            $out[$message['Lang']] = $message['Text'];
        }

        return $out;
    }
209087
protected static function addTranslation($file, $string)
    {
        static::$loaded[$file] = array_merge(static::$loaded[$file], [$string => '']);
        static::saveTranslationFile($file, static::$loaded[$file]);

        return $string;
    }
964225
public function translate($string) {

        // get selected signature

        if(empty($this->signature) === false) {
            if (array_key_exists($string, $this->signature) === false) {
                return $string;
            }
            return $this->signature[$string];
        }
        else {
            throw new Exception('Could not find translate signature');
        }
    }
1030527
public static function parse($text, $context = null)
    {
        if (!static::$_enabled || strpos($text, '{') === false) {
            return $text;
        }

        if ($context === null) {
            $context = static::_getDefaultContext();
        }

        static::cache('context', $context);
        $pattern = static::_regex();

        return preg_replace_callback("/{$pattern}/s", 'static::_doShortcode', $text);
    }
719838
final public static function handlifyString($string)
    {
        $string = preg_replace('/\W+/', '_', $string);
        $string = preg_replace('/([A-Z])/', '_$1', $string);
        $string = strtolower($string);
        $string = preg_replace('/_+/', '_', trim($string, '_'));

        return $string;
    }
1041684
public function translate($string, Array $vars = array())
    {
        // Use custom translator
        if ($this->translator) {
            return $this->translator($this->getString($string), $vars);
        }

        return $this->compileString($this->getString($string), $vars);
    }
855085
protected static function loadTranslation($string, $text_domain)
    {
        /**
         * Locale file path
         *
         * @var string $file
         */
        $file = static::$dir . '/' . static::$locale . '/' . $text_domain . '.php';

        /**
         * Check if we have already loaded this file
         */
        if (array_key_exists($file, static::$loaded)) {

            /**
             * Save missing string if configured to
             */
            if (static::$autoGenerate && (!isset(static::$loaded[$file][$string]))) {
                return static::addTranslation($file, $string);
            }

            /** return processed string */
            return isset(static::$loaded[$file][$string]) && !empty(static::$loaded[$file][$string])
                ? self::$loaded[$file][$string] : $string;
        }

        /**
         * Check if the file exists
         */
        if (!file_exists($file)) {

            /**
             * Create file if not in configured to
             */
            if (static::$autoGenerate) {
                static::saveTranslationFile($file, [$string => '']);
            }

            return $string;
        }
        /** @noinspection PhpIncludeInspection */
        static::$loaded[$file] = (array)require $file;

        /**
         * Save missing string if not in production
         */
        if (static::$autoGenerate && (!isset(static::$loaded[$file][$string]))) {
            return static::addTranslation($file, $string);
        }

        /** return processed string */
        return isset(static::$loaded[$file][$string]) && !empty(static::$loaded[$file][$string])
            ? static::$loaded[$file][$string] : $string;
    }
334968
public function translate($string)
    {
        $args = func_get_args();
        $translated = array_shift($args);
        $extraParams = $args;
        if (count($extraParams)>0)
        {
            $translated = vsprintf($translated, $extraParams);
        }

        return $translated;
    }
68988
static function contextCache( $contextName )
    {
        $translationCache = eZTranslationCache::cacheTable();
        if ( isset( $translationCache[$contextName] ) )
        {
            return $translationCache[$contextName]['root'];
        }
        return null;
    }
807925
protected function get($string, $lang)
	{
		// If fallbacks are used, split language parts and iterate each reader using each part.
		// If fallbacks are not used, just use the specified language and let the reader implementation
		// take care of the translation fallbacks.
		$lang_fallback_path = $this->_use_fallback
			? $this->split_lang($lang)
			: array($lang);
		foreach ($lang_fallback_path as $lang)
		{
			foreach ($this->_readers as $reader)
			{
				if (($translation = $reader->get($string, $lang)))
				{
					return $translation;
				}
			}
		}
		return $string;
	}
1203993
public function translate($string, &$num) {
        if ($this->short_circuit)
            return $string;
        $this->load_tables();

        if ($this->enable_cache) {
            // Caching enabled, get translated string from cache
            if (array_key_exists($string, $this->cache_translations))
                return $this->cache_translations[$string];
            else
                return $string;
        }
        else {
            // Caching not enabled, try to find string
            $num = $this->find_string($string);
            if ($num == -1)
                return $string;
            else
                return $this->get_translation_string($num);
        }
    }