Returns a related translation model

@param string|null $language the language to return. If null, current sys language

@return ActiveRecord
975028
public function getTranslation($language = null)
    {
        if ($language === null) {
            $language = $this->getLanguage();
        }

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

        return $this->_models[$language];
    }
46575
public function getDefaultUrl($language = null)
    {
        foreach ($this->urls as $url) {
            if ($url->isDefault()) {
                return $url;
            }
        }

        return null;
    }
1230457
public function available($language = null)
    {
        return $this->node->getTree()->isPublished($this->node, $language);
    }
696434
protected function translate($key, $params = null, $language = null) {
		return Translation :: translate($key, $params, $language, $this -> getViewmodel());
	}
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;
    }
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];
    }
1299416
public function getAnswerModel($language)
    {
        $source = $this->getSource();
        return $source->getSurveyAnswerModel($this, $language, $this->_gemsSurvey['gsu_surveyor_id']);
    }
1326556
public function hasTranslation($language = null)
    {
        $translation = $this->getTranslation($language);
        return $translation && $this->isTranslationActive($translation);
    }
331096
public static function GetInstance() : Translator
   {

      if ( null === self::$_instance )
      {
         self::$_instance = new Translator();
      }

      return self::$_instance;

   }
664311
public function getTranslationsForLanguage($language) {
		if (!isset($this->messages[$language])) {
			$messageLanguage = $this->getMessageFile($language);
			$this->messages[$language] = $messageLanguage->getAllMessages();
		}		
		return $this->messages[$language];
	}
254129
private static function getMessagesByLanguage($language)
    {
        $messages = [];

        if (!array_key_exists($language, self::$messages)) {
            self::tryLoadingMessageFile($language);
        }

        if (array_key_exists($language, self::$messages)) {
            $messages = self::$messages[$language];
        } else {
            self::tryLoadingMessageFile('en');
            if (array_key_exists('en', self::$messages)) {
                $messages = self::$messages['en'];
            }
        }

        return $messages;
    }
1032932
public function getLanguageCode($language = null)
    {
        if ($language === null) {
            $language = $this->_language;
        }
        $code = KlarnaLanguage::getCode($language);

        return (string) $code;
    }
681050
public function get($language = null, $default = null)
    {
        if ($language === null) {
            $language = 'default';
        }

        $data = parent::get($language, null);

        if ($data === null) {
            $data = $this->get('default', $default);
        }

        return $data;
    }
57589
private function loadTranslation($language) {
        $translation = null;
        /** @var \yii\db\ActiveQuery $relation */
        $relation = $this->owner->getRelation($this->relation);
        /** @var ActiveRecord $class */
        $class = $relation->modelClass;
        $language = strtolower($language);
        if ($this->owner->getPrimarykey()) {
            $translation = $class::findOne(
                            [$this->languageField => $language, key($relation->link) => $this->owner->getPrimarykey()]
            );
        }
        if ($translation === null) {
            $translation = new $class;
            $translation->{key($relation->link)} = $this->owner->getPrimaryKey();
            $translation->{$this->languageField} = $language;
        }
        return $translation;
    }
938631
public function localized($language = null)
    {
        if (!$language){
            $language = Yii::$app->language;
        }
            
        if (!isset($this->with['translations'])) {
            $this->with(['translation' => function ($query) use ($language) {
                $query->where([$this->languageField => $language]);
            }]);
        }

        return $this;
    }
733241
public function joinLang($language = null)
    {
        if (!$language) {
            if (Yii::$app->id === 'app-backend') {
                $language = Yii::$app->wavecms->editedLanguage;
            } else {
                $language = Yii::$app->language;
            }
        }

        return $this->leftJoin(NewsLang::tableName(),
            NewsLang::tableName() . '.news_id = ' . News::tableName() . '.id AND 
                ' . NewsLang::tableName() . '.language = "' . $language . '"');
    }
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;
    }