Get the translation for the given key.

@param  string $key
@param  string $locale
@return string
165554
public function get($key, $locale = null)
    {
        if(!$locale){
            $locale = $this->getLocale();
        }

        if($locale == config('translator.default')){
            return $key;
        }

        $this->load($locale);

        if (!isset($this->languages[$locale][$key])){
            $this->setMissing($key, $locale);
            return $key;
        }

        return $this->languages[$locale][$key]["value"];
    }
772022
public static function getTranslation($key)
  {
    $_key = strtoupper($key);
    if ( isset(self::$translations[$_key]) ){
      return self::$translations[$_key];
    }
    
    return $key;
  }
365096
protected function getText($key)
    {
        return isset($this->texts[$key]) ? $this->texts[$key] : GetOpt::translate($key);
    }
308474
function keyTranslate( $key )
    {
        $msg = $this->findKey( $key );
        if ( $msg !== null )
            return $msg["translation"];
        else
        {
            return null;
        }
    }
906208
public String get(final String key) {
        return get(Keys.LANGUAGE, key, Locales.getLocale());
    }
826501
function getTranslation(string $key, array $replacements = array()) {
        if(isset($this->translations[$key])) {
            $lang = $this->translations[$key];
            
            if(!empty($replacements)) {
                foreach($replacements as $key => $val) {
                    $lang = \str_replace($key, $val, $lang);
                }
            }
            
            return $lang;
        }
        
        return $key;
    }
1043569
private function getTranslationByLocale($locale)
    {
        $attributeValueTranslation = null;

        foreach ($this->entity->getTranslations() as $translation) {
            if ($translation->getLocale() == $locale) {
                $attributeValueTranslation = $translation;
                break;
            }
        }

        return $attributeValueTranslation;
    }
261583
public Translation getTranslation(String locale) {
        LocaleCodeSpecification.assertCode(locale);

        return this.getTranslations().get(locale);
    }
1281820
private function translate($key, $locale = null)
    {
        if (is_null($locale))
            $locale = $this->translator->getLocale();

        $translation = $this->translator->trans($key, [], $locale);

        // @codeCoverageIgnoreStart
        if ( ! is_string($translation))
            throw new InvalidTranslationException(
                "The translation key [{$key}] for locale [{$locale}] should return a string value."
            );
        // @codeCoverageIgnoreEnd

        return (string) $translation;
    }
477331
public function translate($key)
    {
        $normalizeKey = $this->normalize($key);

        if ($this->exists($normalizeKey, false)) {
            $string = $this->strings[$normalizeKey];

            // In debug mode, we notice user this is a translated string.
            if ($this->debug) {
                $string = '**' . $string . '**';
            }

            // Store used keys
            if (!in_array($normalizeKey, $this->used)) {
                $this->used[] = $normalizeKey;
            }

            return $string;
        }

        // In debug mode, we notice user this is a translating string but not found.
        if ($this->debug) {
            $this->orphans[$normalizeKey] = $this->backtrace($normalizeKey, $this->traceLevelOffset + 2);

            $key = '??' . $key . '??';
        }

        return $key;
    }
810957
public function t($key, array $options = [], $locale = null)
    {
        if (strpos($key, '.') === 0) {
            $key = str_replace('/', '.', $this->template->prefix()) . $key;
        }
        
        $i18n = $this->actionView->getService('i18n');
        $options['exception'] = true;
        
        try {
            $tr = $i18n->translate($key, $options, $locale);
        } catch (TranslationMissingException $e) {
            $parts = explode('.', $key);
            $title = $this->actionView->getService('inflector')->titleize(end($parts));
            $tr = sprintf(
                '<span class="translation_missing" title="translation missing: %s">%s</span>',
                $i18n->defaultLocale() . '.' . $key,
                $title
            );
        }
        
        return $tr;
    }
309728
public function get($key, $replacement = array(), $locale = null) {
        $locale = $this->locale($locale);

        return Lang::get($key, $replacement, $locale);
    }
1227704
public static function getLanguage($locale)
    {
        return isset(self::$locales[$locale])
            ? self::$locales[$locale]
            : $locale;
    }
915875
private function retrievePattern($locale, $key)
    {
        $resBundle = $this->getResourceBundle($locale);

        $pattern = $resBundle->get($key);

        if ($pattern === null) {
            throw new \IntlException($resBundle->getErrorMessage(), $resBundle->getErrorCode());
        }

        return $pattern;
    }
513160
public function translate($key, $translation, $locale = null) {
        $this->translations[$this->locale($locale)][$key] = $translation;

        return $translation;
    }
697356
public function getTranslation(
        string $language,
        string $key
    ) : Translation {
        $languages = $this
            ->repositoryCollection
            ->getTranslations(
                [],
                [$language],
                function (Translation $translation) use ($key) {
                    return $translation->getKey() === $key;
                }
            );

        $firstLanguage = reset($languages);

        return $firstLanguage;
    }
533733
public function searchHelpTextByKeyLocale($translationKey, $locale)
    {
        $qb = $this->createQueryBuilder('h');
        $qb->where('h.locale LIKE :locale')
            ->andWhere('h.translationKey LIKE :translationKey')
            ->orderBy('h.id', 'asc')
            ->setParameter(':locale', substr($locale, 0, 2).'%')
            ->setParameter(':translationKey', $translationKey.'%');

        return $qb->getQuery()->getResult();
    }