Loads the message translation for the specified language and category.
@param string $category the message category
@param string $language the target language
@return array the loaded messages
508266
protected function loadMessages($category,$language)
	{
		$messageFile=$this->getMessageFile($category,$language);

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

		if(is_file($messageFile))
		{
			$messages=include($messageFile);
			if(!is_array($messages))
				$messages=array();
			if(isset($cache))
			{
				$dependency=new CFileCacheDependency($messageFile);
				$cache->set($key,serialize($messages),$this->cachingDuration,$dependency);
			}
			return $messages;
		}
		else
			return array();
	}
1056780
public static function createFromCategory(Category $category): self
    {
        $message = new self();
        $message->setId($category->getId());
        $message->setEnabled($category->isEnabled());

        foreach ($category->getTranslations() as $translation) {
            $transMessage = CategoryTranslationMessage::createFromCategoryTranslation($translation);

            $message->addTranslation($transMessage);
        }

        return $message;
    }
399727
public function translate($category, $message, $params, $language)
    {
        if (stripos($message, '{lang:') !== false) {
            $message = $this->removeLegacyLangTags($message);
        }

        return parent::translate($category, $message, $params, $language);
    }
769743
public function serialize(Category $category)
    {
        return [
            'id' => $category->getId(),
            'name' => $category->getName(),
            'order' => $category->getOrder(),
            'user' => $this->userSerializer->serialize($category->getUser()),
        ];
    }
133205
public function setTranslationsForLanguage(array $messages, $language)
    {
        foreach ($messages as $key => $value) {
            $this->setTranslation($key, $value, $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;
    }
1229041
public function getMessageForAllLanguages($key, $lang = null) {
		
		if (!$this->messages) {
			$this->loadAllMessages();
		}
		
		$messageArray = array();
		foreach ($this->messages as $language=>$messageLanguage) {
			if(is_null($lang) || $lang == "")
				$messageArray[$language] = $messageLanguage->getMessage($key);
			elseif($lang == $language)
				$messageArray[$language] = $messageLanguage->getMessage($key);
		}
		return $messageArray;
	}
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];
    }
365386
public function getCategories(CategoryListMessage $message): array
    {
        $path = sprintf('sites/%d/categories', $message->getSiteId());

        $response = $this->getClient()->sendRequest(RequestStatus::GET, $path);

        /** @var Category[] $models */
        $models = $this->getModelFactory()->createMany(Category::class, $response);

        return $models;
    }
867873
private void initializeCategoryTranslation() {
    flatCategoriesLst.forEach(category -> {
      translationServiceProperty().addListener((observable, oldValue, newValue) -> {
        category.translate(newValue);
        // listen for i18n changes in the TranslationService for this Category
        newValue.addListener(() -> category.translate(newValue));
      });
    });
  }
659685
public static function createFromCategoryTranslation(CategoryTranslation $translation): self
    {
        $message = new self();
        $message->setLocale($translation->getLocale());
        $message->setTitle($translation->getTitle());
        $message->setDescription($translation->getDescription());

        return $message;
    }
492465
private function loadCategory($id = null, $languageId = null, $viewName, $params = [])
    {
        $category = (!empty($id)) ? Category::findOne($id) : new Category();
        $categoryTranslation = (!empty($id)) ? CategoryTranslation::find()->where([
            'category_id' => $id,
            'language_id' => $languageId
        ])->one() : new CategoryTranslation();

        $categoryTranslation = $categoryTranslation ?? new CategoryTranslation();

        if (Yii::$app->request->isPost) {
            ($category->isNewRecord) ? $this->trigger(self::EVENT_BEFORE_CREATE_CATEGORY) :
                $this->trigger(self::EVENT_BEFORE_EDIT_CATEGORY);

            $post = Yii::$app->request->post();

            $category->load($post);
            $category->parent_id = (!empty($category->parent_id)) ? $category->parent_id : null;
            $categoryTranslation->load($post);

            if ($category->validate()) {
                $eventName = $category->isNewRecord ? self::EVENT_AFTER_CREATE_CATEGORY : self::EVENT_AFTER_EDIT_CATEGORY;

                $category->save();

                if (empty($categoryTranslation->seoUrl)) $categoryTranslation->seoUrl = Inflector::slug($categoryTranslation->title);

                $categoryTranslation->category_id = $category->id;
                $categoryTranslation->language_id = $languageId;

                if ($categoryTranslation->validate()) {
                    $categoryTranslation->save();

                    $this->trigger($eventName, new CategoryEvent(['id' => $category->id]));

                    Yii::$app->getSession()->setFlash('success', 'The category has been successfully modified.');
                    return $this->redirect([$viewName, 'id' => $category->id, 'languageId' => $languageId]);
                }
            }
        }

        return $this->render('save', [
            'viewName' => $viewName,
            'params' => array_merge([
                'languages' => Language::findAll(['active' => true]),
                'maxPosition' => Category::find()->where(['parent_id' => $category->parent_id])->max('position') + 1 ?? 1,
                'category' => $category,
                'categoryTranslation' => $categoryTranslation,
                'categories' => Category::find()->with('translations')->all(),
                'selectedLanguage' => Language::findOne($languageId),
            ], $params)
        ]);
    }
342733
protected function getMessageFilePath($category, $language)
    {
        $suffix = explode('.', $category)[1];
        $messageFile = $this->basePath . "/$language/";
        if (isset($this->fileMap[$suffix])) {
            $messageFile .= $this->fileMap[$suffix];
        } else {
            $messageFile .= str_replace('\\', '/', $suffix) . '.php';
        }

        return $messageFile;
    }
303246
private function _loadLanguageItems()
    {
        $this->_languageItems = LanguageSource::find()
            ->joinWith(['languageTranslate' => function ($query) {
                $query->where(['language' => $this->_languageId]);
            },
            ])
            ->where(['category' => Scanner::CATEGORY_JAVASCRIPT])
            ->all();
    }
763843
private function loadTranslationMessages($language)
    {
        // Reset any previous translations if any
        $this->moduleManager->clearTranslations();
        $this->translator->reset();

        // Now load new ones
        $this->moduleManager->loadAllTranslations($language);
        $this->translator->extend($this->moduleManager->getTranslations());
    }
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();
	}
132491
public static <T> T getMessageLogger(Class<T> type, String category) {
        return getMessageLogger(type, category, Locale.getDefault());
    }