Returns the translation model for the specified language.
@param string|null $language
@return ActiveRecord
339337
public function getTranslation($language = null)
    {
        $language = $language ?: $this->getLanguage();

        $translations = $this->getTranslateRelations();
        if (isset($translations[$language])) {
            return $translations[$language];
        }

        $sourceLanguage = $this->getSourceLanguage();
        $attributes = isset($translations[$sourceLanguage]) ?
            ArrayHelper::toArray($translations[$sourceLanguage]) : [];

        $translations[$language] = $this->createTranslation($language, $attributes);

        $this->setTranslateRelations($translations);

        return $translations[$language];
    }
998808
public function translations($active = true)
    {
        if ($active) {
            return $this->hasMany(ContentTranslation::class)->where('is_active', '=', true);
        }
        return $this->hasMany(ContentTranslation::class);
    }
674357
private function getPosixLocale(Language $language): ?array
    {
        if (!$language->enabled) {
            return null;
        }

        $posixLocale = $this->localeConverter->convertToPOSIX($language->languageCode);
        if ($posixLocale === null) {
            return null;
        }

        if (!Locales::exists($posixLocale)) {
            return null;
        }

        return [$posixLocale, Locales::getName($posixLocale)];
    }
1283628
public static function get_smart_locale($language = null) {

		require_once FRAMEWORK_PATH . '/thirdparty/Zend/Locale.php';
		$locale = Zend_Locale::getBrowser();

		if(!$locale) {
			if($language) {
				return i18n::get_locale_from_lang($language);
			}
			else {
				return i18n::get_locale();
			}
		}

		$locale = array_keys($locale);
		$firstPref = array_shift($locale);

		if(strpos($firstPref, '_') === false) {
			return i18n::get_locale_from_lang($language);
		}

		return $firstPref;
	}
622816
public function generateElements($language = null)
    {
        $sitemapElements = [];
        $transformer = $this->transformer;

        $entities = $this
            ->entitySitemapElementProvider
            ->getEntities();

        if (is_array($entities)) {
            foreach ($entities as $entity) {
                $sitemapElements[] = $this
                    ->sitemapElementFactory
                    ->create(
                        $transformer->getLoc($entity, $language),
                        $transformer->getLastMod($entity, $language),
                        $this->changeFrequency,
                        $this->priority
                    );
            }
        }

        return $sitemapElements;
    }
741149
private function loadTranslation($language)
    {
        $class = $this->translationClass;
        if (!$class) {
            throw new InvalidParamException('Translation class not set.');
        }
        $translation = new $class;
        $translation->{$this->languageAttribute} = $language;

        return $translation;
    }
153913
public function translate($locale = null) {
        $locale = isset($locale) ? $locale : Locale\get_active_locale();

        if( in_array( $locale, Locale\get_locales() ) )
            throw new TranslatableException(
                _('Invalid locale')
            );

        $language = $this->getByLocale($locale);

        return $this->translations()
            ->where('language_id', $language->id)
            ->first();
    }
1104816
public function translation($lang)
    {
        $result = Translation::where('entity_id', $this->id)
            ->where('entity_type', get_class($this))
            ->where('language', $lang)
            ->first();

        if ($result) {
            return $result;
        }

        $this->data = $this;

        return $this;
    }
455395
protected function getTranslation(string $locale): ?Model
    {
        if (isset($this->translationCache[$locale])) {
            return $this->translationCache[$locale];
        }

        if (!$this->exists) {
            return null;
        }

        $translation = $this->translations
            ->where('locale', $locale)
            ->first();

        if ($translation) {
            $this->translationCache[$locale] = $translation;
        }

        return $translation;
    }
1035280
public function getLocalLabel($attribute, $language = null)
    {
        if ($language === null) {
            $language = \Yii::$app->language;
        }
        /** @var ActiveRecord $owner */
        $owner = $this->owner;
        if ($owner->isNewRecord) {
            return $owner->getAttribute($attribute);
        }
        $localLabels = $this->getLocalLabels();

        return !isset($localLabels[$language][$owner->getPrimaryKey()][$attribute])
            ? $owner->getAttribute($attribute)
            : $localLabels[$language][$owner->getPrimaryKey()][$attribute];
    }
1197943
public function getTitle($language = null)
    {
        if (!isset($this->titles[$language])) {
            return current($this->titles);
        }

        return $this->titles[$language];
    }
1331341
private function getTranslation()
    {
        $operatorTranslation = null;
        foreach ($this->entity->getTranslations() as $translation) {
            if ($translation->getLocale() == $this->locale) {
                $operatorTranslation = $translation;
            }
        }
        if (!$operatorTranslation) {
            $operatorTranslation = new OperatorValueTranslation();
            $operatorTranslation->setLocale($this->locale);
            $operatorTranslation->setOperatorValue($this->entity);
            $this->entity->addTranslation($operatorTranslation);
        }

        return $operatorTranslation;
    }
871299
private function getMessageFile($language) {
		if(!isset($this->messageFile[$language])) {
			$this->messageFile[$language] = new MessageFileLanguage($this->getPath(), $language);
		}
		return $this->messageFile[$language];
	}
725840
public function getValues($language = null)
    {
        if (!$language) {
            $language = $this->defaultLanguage;
        }

        if (!isset($this->values[$language])) {
            return [];
        }

        return $this->values[$language];
    }
455833
public function getTranslation($language = null)
    {
        if ($language === null) {
            $language = $this->getLanguage();
        }

        if (!isset($this->owner->{$this->translationsAttribute}[$language])) {
            $this->owner->{$this->translationsAttribute}[$language] = $this->loadTranslation($language);
        }

        return $this->owner->{$this->translationsAttribute}[$language];
    }
500652
public function get($language)
    {
        if (!isset($this->alphabets[$language])) {
            // Not found alphabet for language
            return null;
        }

        return $this->alphabets[$language];
    }
845998
public function getSpecialTidsForLanguage($language = null)
    {
        $specialTids = [];

        foreach ($this->specialTids as $specialTid) {
            if ($specialTid['language'] === $language || $specialTid['language'] === null) {
                $specialTids[$specialTid['name']] = $specialTid['treeId'];
            }
        }

        return $specialTids;
    }