Retreive a string to translate

if it doesn't find it, put it in the database

@param  string $string
@param  string $context
@param  string $language
@return string
195900
public function translate($string, $context = 'default', $language = 'default')
    {
        if ($this->isDefault($language)) {
            $language = $this->currentLanguage;
        } else {
            $this->setLanguage($language);
        }

        //get string from cache
        if (array_key_exists($context, $this->strings[$language]) &&
            array_key_exists($string, $this->strings[$language][$context])) {
            return $this->strings[$language][$context][$string];
        }

        //check in db
        $db_string = StringModel::select('id', 'date_creation')
            ->where('string', $string)
            ->where('context', $context)
            ->first();

        if (!$db_string) {
            $this->translateInsertString($context, $string);

            return $string;
        }

        $text = $this->translateGetString($context, $language, $db_string->id);
        if ($text) {
            $this->strings[$language][$context][$string] = $text;

            return $text;
        }

        return $string;
    }
1283961
public function pgettext($context, $message) {
		if ($this->reader === null) {
			return $message;
		}
		return $this->reader->pgettext((string)$context, (string)$message);
	}
432882
protected function trans($context, $key)
    {
        $message = "";

        if (array_key_exists($context, $this->messages)) {
            if (array_key_exists($key, $this->messages[$context])) {
                $message = $this->messages[$context][$key];
            }
        }

        return $message;
    }
986269
public function parse($str, $context = null)
    {
        $this->lexer->setInput($str);
        $this->context = $context;

        $rs = $this->parseInternal();

        if (null !== $this->lexer->next) {
            $this->syntaxError('end of input');
        }

        return $rs;
    }
793363
public function translateContext($context, $message)
    {
        $key = $context . chr(4) . $message;
        if (isset($this->translations[$key])) {
            return $this->translations[$key];
        } else {
            return $message;
        }
    }
876550
public function parseColumnNames($string, ContextAwareInterface $context = null)
    {
        $matchArray = [];
        preg_match_all("#~([a-zA-Z0-9_]\\.{0,1})+#", $string, $matchArray);
        $matchArray = array_unique($matchArray[0]);

        foreach ($matchArray as $match) {
            if($context){
                $nsMatch = $context->getNameInContext($match);
            }else{
                $nsMatch = $match;
            }

            $path=ltrim($nsMatch, "~");

            $tablePath = rtrim(substr($nsMatch, 1, strrpos($nsMatch, ".")), ".");

            $replace= $this->_doFQLTableName($tablePath, null, true)
                . "."
                . $this->getBaseFace()
                    ->getElement($path)
                    ->getSqlColumnName(true);

            $string = str_replace($match, $replace, $string);
        }

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

        return is_string($translated) ? $translated : $string;
    }
1361117
private function interpolate($message, array $context)
    {
        $replacements = array();
        foreach ($context as $key => $value) {
            if (is_array($value) === false && (is_object($value) === false || method_exists($value, '__toString'))) {
                $replacements[sprintf('{%s}', $key)] = $value;
            }
        }

        return strtr($message, $replacements);
    }
233036
public static function addTranslationContext($value, $context) {
		if (is_array($value) || $value instanceof Traversable) {
			$array = array();
			foreach ($value as $key => $string) {
				$array[$key] = self::addTranslationContext($string, $context);
			}
			return $array;
		}
		return (string)$context . chr(4) . (string)$value;
	}
359117
protected function escapeLiteral($text, $context)
	{
		if ($context === 'raw')
		{
			return $text;
		}

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

		return htmlspecialchars($text, $escapeMode);
	}
670900
public function filterStopwords($string, $language)
    {
        $prepared = trim(strip_tags($string));

        if ($prepared === '') {
            return '';
        }

        $stopwords = array();
        $path = GC_DIR_PRIVATE . "/stopwords/$language.txt";

        if (is_readable($path)) {
            $stopwords = array_map('trim', file($path, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES));
        }

        return implode(' ', array_diff(explode(' ', $prepared), $stopwords));
    }
265853
public function translate($string, $namespace, $arguments = array())
    {
        // Load the language file for the given namespace if the language file isn't loaded
        if (!isset($this->translatedStrings[$namespace]) || !is_array($this->translatedStrings[$namespace])) {
            $this->loadLanguageFileForNamespace($namespace);
        }
        
        // If no translation for the original string is available or the string is not translated 
        // return the original string to the caller.
        if (!isset($this->translatedStrings[$namespace][$string]) || $this->translatedStrings[$namespace][$string] == '') {
            return $this->replacePlaceholders($string, $arguments);
        }
        
        return $this->replacePlaceholders($this->translatedStrings[$namespace][$string], $arguments);
    }
1141962
protected function translate($string)
    {
        if ($this->hasTranslator()) {
            return $this->getTranslator()->translate($string, $this->getTranslatorTextDomain());
        }

        return $string;
    }
276557
public static function translate($string, Translation $translation = null) {
		if ($translation !== null) {
			$translation = self::get($translation->language, $translation->application_name);
		} else {
			$translation = self::get(\Application::get()->language, \Application::get()->name);
		}

		return $translation->translate_string($string);
	}
324411
protected function getValue($string, $domain, $locale)
    {
        if (!$domain) {
            $domain = 'default';
        }

        $this->loadDomain($domain, $locale);

        // We have to treat 'languages', 'default', 'modules' etc. domains differently.
        if (!(isset($GLOBALS['TL_LANG'][$domain]) && is_array($GLOBALS['TL_LANG'][$domain]))
            && (substr($domain, 0, 2) != 'tl_')
        ) {
            $lang = $GLOBALS['TL_LANG'];
        } else {
            if (!is_array($GLOBALS['TL_LANG'][$domain])) {
                return $string;
            }
            $lang = $GLOBALS['TL_LANG'][$domain];
        }

        $chunks = explode('.', $string);

        while (($chunk = array_shift($chunks)) !== null) {
            if (!array_key_exists($chunk, $lang)) {
                return $string;
            }

            $lang = $lang[$chunk];
        }

        return $lang;
    }
1151963
public function translate($string, $params = [], $domain = null)
    {
        $translationDomain = $domain ? $domain : $this->admin->getTranslationDomain();

        return $this->get('translator')->trans($string, $params, $translationDomain);
    }
604690
protected function createTranslateContext(
        string $text,
        Language $languageTo,
        Language $languageFrom
    ): RequestContext {
        $requestContext = (new RequestContext(sprintf("%s/%s", $this->apiEndpoint, self::TRANSLATE_API_PATH)))
            ->setRequestParameters(
                [
                    'lang' => $this->getLanguageString($languageTo, $languageFrom)
                ] + $this->getAuthData()
            )
            ->setData(['text' => $text])
            ->setMethod(RequestContext::METHOD_POST);

        return $this->fillGeneralRequestSettings($requestContext);
    }