Get the translation for a given key.

@param  string $id
@param  array  $parameters
@param  string $domain
@param  string $locale
@return string
345934
public function trans($id, array $parameters = [], $domain = 'messages', $locale = null)
    {
        $line = Arr::get($this->lines, $id);

        if (is_null($line)) {
            return $id;
        }

        return $this->makeReplacements($line, $parameters);
    }
593490
public function translate(string $key, array $params, string $locale = null): string
    {
        $realKey = $this->getRealKey($key, $locale);
        $message = ArrayHelper::get($this->messages, $realKey);
        
        // not exist, return key
        if (!\is_string($message)) {
            return $key;
        }

        // no params
        if (!$params) {
            return $message;
        }

        return $this->formatMessage($message, $params);
    }
445043
public static function trans(string $id = null, array $parameters = [], string $locale = null): string
    {
        return (string)trans(self::NAME . '::' . $id, $parameters, $locale);
    }
1340000
protected function prepareCacheId($locale, $domain) {
		if (is_array($locale)) {
			$list = [];
			
			// many locales to many domains
			if (is_array($domain)) {
				foreach ($locale as $part1) {
					foreach ($domain as $part2) {
						$list[] = $part1 . '_' . $part2;
					}
				}
				
				return $list;
			}
			
			// many locales to one domain
			foreach ($locale as $part) {
				$list[] = $part1 . '_' . $domain;
			}
			
			return $list;
		}
		
		// one locale to many domains
		if (is_array($domain)) {
			$list = [];
			
			foreach ($domain as $part) {
				$list[] = $locale . '_' . $part;
			}
			
			return $list;
		}
		
		// one locale to one domain
		return $locale . '_' . $domain;
	}
1221655
public function getTranslation(
        $entityType,
        $entityId,
        $entityField,
        $locale
    ) {
        $cacheKey = $this->buildKey(
            $entityType,
            $entityId,
            $entityField,
            $locale
        );

        $translation = $this
            ->cache
            ->fetch($cacheKey);

        if ($translation === false) {
            $translation = $this
                ->entityTranslatorProvider
                ->getTranslation(
                    $entityType,
                    $entityId,
                    $entityField,
                    $locale
                );

            $this
                ->cache
                ->save(
                    $cacheKey,
                    $translation
                );
        }

        return $translation;
    }
348459
public function translateItem($id, $lang)
	{
		$model = $this->crud['model'];
		$this->data['entry'] = $model::find($id);
		// check if there isn't a translation already
		$existing_translation = $this->data['entry']->translation($lang);

		if ($existing_translation)
		{
			$new_entry = $existing_translation;
		}
		else
		{
			// get the info for that entry
			$new_entry_attributes = $this->data['entry']->getAttributes();
			$new_entry_attributes['translation_lang'] = $lang;
			$new_entry_attributes['translation_of'] = $id;
			$new_entry_attributes = array_except($new_entry_attributes, 'id');

			$new_entry = $model::create($new_entry_attributes);
		}

		// redirect to the edit form for that translation
		return redirect(str_replace($id, $new_entry->id, str_replace('translate/'.$lang, 'edit', \Request::url())));
	}
837075
public function getById(string $id, array $params = [])
    {
        return $this->executeRequest(
            RequestMethodEnum::GET,
            ResourceMethodEnum::GET_BY_ID,
            $params,
            $id
        );
    }
677313
public function trans($key, Array $parameters = array(), $domain = NULL) {
    if (!isset($domain)) $domain = 'project';

    return $this->translationContainer->getTranslator()->trans($key, $parameters, $domain);
  }
1336512
protected function getTranslation($id, $domain, $locale, $fallbacks) {
		// Is initialize of the catalog need ?
		if (! isset($this->initializedCatalogs[$locale][$domain])) {
			$this->initCatalogs($locale, $domain);
		}
		
		// Is failure occurred ?
		if (! isset($this->catalogs[$locale][$domain][$id])) {
			if (empty($fallbacks)) {
				return;
			}
			
			$fallbackLocale = array_shift($fallbacks);
			
			return $this->getTranslation($id, $domain, $fallbackLocale, $fallbacks);
		}
		
		return $this->catalogs[$locale][$domain][$id];
	}
746926
public static function translate($key, $params = [], $language = null, Viewmodel $viewmodel = null) {
		
		$identifier = null;

		if(null !== $viewmodel) {
			$identifier = static :: load($viewmodel);
		}

		if(null === $key) {
			$key = '';
		}

		//Check if key is a string
		if(false === is_string($key)) {
			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($key)), E_USER_ERROR);
		}

		//Check if params is an array
		if(null !== $params && false === is_array($params)) {
			return trigger_error(sprintf('Argument 2 passed to %s() must be of the type array, "%s" given', __METHOD__, gettype($params)), E_USER_ERROR);
		}

		//Check if language is a string
		if(null !== $language && false === is_string($language)) {
			return trigger_error(sprintf('Argument 3 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($language)), E_USER_ERROR);
		}

		//Set default language if non given
		if(null === $language) {
			$language = static :: $language;
		}

		//If identifier is known (usually with a viewmodel as last param)
		if(null !== $identifier) {

			if(true === isset(static :: $translations[$identifier], static :: $translations[$identifier][$language])) {

				if(true === isset(static :: $translations[$identifier][$language][$key])) {
					return vsprintf(static :: $translations[$identifier][$language][$key], $params);
				}
			}
		}

		//Check the full resource for the translation
		foreach(static :: $translations as $translation) {

			if(true === isset($translation[$language][$key])) {
				return vsprintf($translation[$language][$key], $params);
			}
		}

		//No translation found
		return vsprintf($key, $params);
	}
1369451
protected function translateTitle($id, array $parameters = array(), $domain = null)
    {
        return $this->translator->trans($id, $parameters, $domain);
    }
403422
protected function getTranslation(string $key, string $locale)
    {
        return $this->translations()
            ->where('key', $key)
            ->where('locale', $locale)
            ->value('translation');
    }
56482
public function get(string $projectKey, string $id, string $locale)
    {
        $response = $this->httpGet(sprintf('/api/translations/%s/%s?key=%s', rawurlencode($id), $locale, $projectKey));

        if (!$this->hydrator) {
            return $response;
        }

        if (200 !== $response->getStatusCode()) {
            $this->handleErrors($response);
        }

        return $this->hydrator->hydrate($response, TranslationModel::class);
    }
43569
protected function findRecordInLocale($locale, $table, $id)
    {
        $query = SQLSelect::create('"ID"');
        $query->addFrom('"'. $table . '"');
        $query->addWhere([
            '"RecordID"' => $id,
            '"Locale"' => $locale,
        ]);

        return $query->firstRow()->execute()->value() !== null;
    }
1154738
static public function getJid( $domain, $node = NULL, $resource = NULL ){
		$jid	= $domain;
		if( strlen( trim( $node ) ) ) 
			$jid	= $node.'@'.$domain;
		if( strlen( trim( $resource ) ) )
			$jid	.= "/".$resource;
		return $jid;
	}
738690
protected function translate($message, $parameters = array())
    {
        return $this->translator->trans($message, $parameters, $this->translationDomain);
    }
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);
    }