Translate key .

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

        return $translation;
    }
633805
public function translate($locale) {
		$localeEntity = clone $this;
		$localeEntity->setLocale($locale);
		if(isset($this->data['translations'][$locale]))
			$localeEntity->_set($this->data['translations'][$locale]);
		unset($localeEntity->data['translations'][$locale]);
		$localeEntity->data['translations'][$this->getLocale()] = $this->data['properties'];

		return $localeEntity;
	}
460390
public function has($key, $locale = null, $fallback = true)
    {
        return $this->get($key, array(), $locale, $fallback) !== $key;
    }
863565
public static function get($key, $default = null, $locale = null)
    {
        return self::all($locale)->get($key, $default);
    }
1107662
public function getTranslation(string $key, string $locale = null)
    {
        $this->throwExceptionIfAttributeIsNotTranslatable($key);

        $translations = $this->getTranslations($key);

        if (count($translations)) {
            $locale = $locale ?: config('app.locale');

            if (isset($translations[$locale])) {
                $translation = $translations[$locale];
            } else {
                $translation = $translations[$this->getDefaultLocale()] ?? head($translations);
            }

        } else {
            $translation = null;
        }

        if ($this->hasGetMutator($key)) {
            return $this->mutateAttribute($key, $translation);
        }

        return $translation;
    }
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"];
    }
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();
    }
1085502
public function getMap($locale, $key = null)
    {
        // Get sanitized locale
        $locale = Locale::sanitizeLocale($locale);

        if ($key) {
            return isset($this->maps[$locale][$key]) ? $this->maps[$locale][$key] : null;
        }

        return isset($this->maps[$locale]) ? $this->maps[$locale] : null;
    }
345316
public function get($key, $replacement = array(), $locale = null) {
        $value = $this->getStoreTranslation($key, $this->locale($locale));

        return $this->replace($value, $replacement);
    }
27642
public function setTranslation($key, $locale, $value)
    {
        $this->guardAgainstNonTranslatableAttribute($key);

        $translations = $this->getTranslations($key);
        $oldValue     = $translations[$locale] ?? '';

        if ($this->hasSetMutator($key)) {
            $this->{'set'.Str::studly($key).'Attribute'}($value);
            $value = $this->attributes[$key];
        }

        $translations[$locale]  = $value;
        $this->attributes[$key] = $this->asJson($translations);

        event(new TranslationHasBeenSet($this, $key, $locale, $oldValue, $value));

        return $this;
    }
1095625
protected function normalizeLocale($key, $locale, $useFallback)
    {
        if (in_array($locale, $this->getTranslatedLocales($key)) || ! $useFallback)
            return $locale;

        return config('app.fallback_locale') ?: $locale;
    }
912518
private function translate($key, $translations)
    {
        if ($translations != null && isset($translations[$key])) {
            return $translations[$key];
        }

        return $key;
    }
87206
public function translate($key, $data = null)
    {
        $rs = isset($this->data[$key]) ? $this->data[$key] : $key;
        if ($rs && !empty($data)) {
            $names = array_keys($data);
            $names = array_map(function($pkey){ return '{' . $pkey . '}'; }, $names);
            $rs = str_replace($names, array_values($data), $rs);
        }
        return $rs;
    }
1085748
public function getByKey($key, $locale, $group = null) {
        $query = $this->source
            ->select('languages.slug as locale', 'translations.*')
            ->join('languages', 'languages.id', '=','translations.language_id')
            ->where('languages.slug', $locale)
            ->whereKey($key);

        if($group)
            $query->where('group', $group);

        return $query
            ->first();
    }
512300
public function getName(string $key, string $locale = null)
    {
        return $this->get($key, $locale);
    }
790344
public function getTranslation($entity, $property, $locale)
    {
        $metadata = $this->metadataCollection->getMetadata($entity);
        if($metadata === null) {
            return null;
        }

        $property = $metadata->getProperty($property);
        if($property === null) {
            return null;
        }

        $strategy = $this->strategyResolver->getStrategy($property->getStrategy());
        return $strategy->getTranslation($entity, $property, $locale, $metadata);
    }
1119737
public function has($key, $locale = null) {
        $locale = $this->locale($locale);

        return $this->get($key, [], $locale) !== $key;
    }