Loads a specific translation model

@param string $language the language to return

@return null|\yii\db\ActiveQuery|static
170700
private function getNewTranslation($language)
    {
        $translation = null;
        /** @var \yii\db\ActiveQuery $relation */
        $relation = $this->owner->getRelation($this->relation);
        /** @var ActiveRecord $class */
        $class = $relation->modelClass;
        //if ($translation === null) {
        $translation = new $class;
        $translation->{key($relation->link)} = $this->owner->getPrimaryKey();
        $translation->{$this->languageAttribute} = $language;
        //}
        return $translation;
    }
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;
	}
1284890
public function loadInLang($language, $oxid)
    {
        // set new lang to this object
        $this->setLanguage($language);
        // reset
        $this->_sViewTable = false;

        return $this->load($oxid);
    }
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;
    }
46575
public function getDefaultUrl($language = null)
    {
        foreach ($this->urls as $url) {
            if ($url->isDefault()) {
                return $url;
            }
        }

        return null;
    }
1368965
public function loadAllTranslations($language)
    {
        foreach ($this->loaded as $module) {
            $this->loadModuleTranslation($module, $language);
        }
    }
572548
public function loadModel($id, $language) 
	{
		$model = Message::model()->findByAttributes(array('id'=>$id, 'language'=>$language));
		if($model===null)
			throw new CHttpException(404, Yii::t('phrase', 'The requested page does not exist.'));
		return $model;
	}
261791
public function translationData($lang)
    {
        $translation = $this->translation($lang);

        if ($translation) {
            $data = json_decode($translation->entity_data);

            if (isset($data->blocks)) {
                $data->blocks = json_decode($data->blocks, true);
            }

            return $data;
        }

        return null;
    }
1054946
public function getTranslationByLang($language) {
        if ($language instanceof Language) {
            $index = $language->getSymbol();
        } else {
            $index = $language;
        }
        if (empty($this->transArray[$index])) {
            $this->transArray[$index] = $this->getTranslations()->filter(function ($trans) use ($index) {
                                    return $trans->getTransLang()->getSymbol() == $index;
                            })
                    ->first();
        }

        return $this->transArray[$index];
    }
1166652
public function getTranslation($language_id = null)
    {
        /** @var ActiveRecord $translation */

        /** @var \DevGroup\Multilingual\Multilingual $multilingual */
        $multilingual = Yii::$app->multilingual;
        if ($language_id === null) {
            $language_id = $multilingual->language_id;
        }
        /** @var ActiveRecord $owner */
        $owner = $this->owner;
        if ($language_id === $multilingual->language_id && !$owner->isRelationPopulated($this->translationRelation)) {
            $language_id = $multilingual->language_id;
            $translation = $owner->{$this->defaultTranslationRelation};
            if ($translation !== null) {
                return $translation;
            }
        } else {
            // language id specified and it's not default
            $translations = $owner->{$this->translationRelation};
            foreach ($translations as $item) {
                if ($item->language_id === $language_id) {
                    return $item;
                }
            }
        }
        // translation does not exists!

        /** @var ActiveRecord $class */
        $class = $this->getTranslationModelClassName();
        /** @var ActiveRecord $translation */
        $translation = new $class();
        $translation->loadDefaultValues();
        $translation->setAttribute('language_id', $language_id);

        $translations = $this->owner->{$this->translationRelation};
        $translations[] = $translation;

        $owner->populateRelation($this->translationRelation, $translations);


        if ($language_id === $multilingual->language_id) {
            $owner->populateRelation($this->defaultTranslationRelation, $translation);
        }

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

        return $this->andWhere(['REGEXP', News::tableName() . '.languages', '(^|;)(' . $language . ')(;|$)']);
    }
59128
public function getTranslationModel($id = null)
    {
        $translationModel = new TranslationModel();
        $translationModel->setKeyword($this->getKeyword());
        $translationModel->setDomain($this->getDomain());
        $translationModel->addText($this->getLocale(), $this->getText(), $id);

        return $translationModel;
    }
1299416
public function getAnswerModel($language)
    {
        $source = $this->getSource();
        return $source->getSurveyAnswerModel($this, $language, $this->_gemsSurvey['gsu_surveyor_id']);
    }
350198
protected function loadMessages($category, $language)
	{
        $messageFile=$this->basePath . DIRECTORY_SEPARATOR . $language . DIRECTORY_SEPARATOR . $this->catalog;
        if($this->useMoFile)
        	$messageFile.=self::MO_FILE_EXT;
        else
        	$messageFile.=self::PO_FILE_EXT;

		if ($this->cachingDuration > 0 && $this->cacheID!==false && ($cache=Yii::app()->getComponent($this->cacheID))!==null)
		{
			$key = self::CACHE_KEY_PREFIX . $messageFile . "." . $category;
			if (($data=$cache->get($key)) !== false)
				return unserialize($data);
		}

		if (is_file($messageFile))
		{
			if($this->useMoFile)
				$file=new CGettextMoFile($this->useBigEndian);
			else
				$file=new CGettextPoFile();
			$messages=$file->load($messageFile,$category);
			if(isset($cache))
			{
				$dependency=new CFileCacheDependency($messageFile);
				$cache->set($key,serialize($messages),$this->cachingDuration,$dependency);
			}
			return $messages;
		}
		else
			return array();
	}
1107339
public function setLanguage($language = null)
    {
        if (is_null($language)) {
            if (($language = Yii::$app->request->getQueryParam('_lang')) !== null) {
                $this->language = $language;
                Yii::$app->response->cookies->add(new Cookie(['name' => '_lang', 'value' => $language]));
            } else if (($cookie = Yii::$app->request->cookies->get('_lang')) !== null) {
                $this->language = $cookie->value;
            } else if (($language = Yii::$app->request->getPreferredLanguage()) !== null) {
                $this->language = $language;
            }
        } else {
            $this->language = $language;
        }
    }
390338
public function loadByLanguage($language)
    {
        if (!is_null($language) && !preg_match('/[a-z]{2}/', $language)) {
            throw new ShopgateLibraryException(
                ShopgateLibraryException::CONFIG_READ_WRITE_ERROR,
                'invalid language code "' . $language . '"',
                true,
                false
            );
        }

        $this->loadFile($this->buildConfigFilePath('myconfig-' . $language . '.php'));
        $this->initFileNames();
    }
1295886
public static function getByLanguage($language, Site $site = null)
    {
        if (!$site) {
            $site = \Core::make('site')->getSite();
        }

        $em = Database::get()->getEntityManager();
        /**
         * @var $section Locale
         */
        $section = $em->getRepository('Concrete\Core\Entity\Site\Locale')
            ->findOneBy(['site' => $site, 'msLanguage' => $language]);

        if (is_object($section)) {
            $obj = parent::getByID($section->getSiteTree()->getSiteHomePageID(), 'RECENT');
            $obj->setLocale($section);

            return $obj;
        }

        return false;
    }