Commit ffed5d01 by Alexander Makarov

fixes #2176

parent 5cab2a87
...@@ -60,13 +60,13 @@ class GettextMessageSource extends MessageSource ...@@ -60,13 +60,13 @@ class GettextMessageSource extends MessageSource
*/ */
protected function loadMessages($category, $language) protected function loadMessages($category, $language)
{ {
$messageFile = $this->getMessageFilePath($category, $language); $messageFile = $this->getMessageFilePath($language);
$messages = $this->loadMessagesFromFile($messageFile); $messages = $this->loadMessagesFromFile($messageFile, $category);
$fallbackLanguage = substr($language, 0, 2); $fallbackLanguage = substr($language, 0, 2);
if ($fallbackLanguage != $language) { if ($fallbackLanguage != $language) {
$fallbackMessageFile = $this->getMessageFilePath($category, $fallbackLanguage); $fallbackMessageFile = $this->getMessageFilePath($fallbackLanguage);
$fallbackMessages = $this->loadMessagesFromFile($fallbackMessageFile); $fallbackMessages = $this->loadMessagesFromFile($fallbackMessageFile, $category);
if ($messages === null && $fallbackMessages === null && $fallbackLanguage != $this->sourceLanguage) { if ($messages === null && $fallbackMessages === null && $fallbackLanguage != $this->sourceLanguage) {
Yii::error("The message file for category '$category' does not exist: $messageFile Fallback file does not exist as well: $fallbackMessageFile", __METHOD__); Yii::error("The message file for category '$category' does not exist: $messageFile Fallback file does not exist as well: $fallbackMessageFile", __METHOD__);
...@@ -90,11 +90,10 @@ class GettextMessageSource extends MessageSource ...@@ -90,11 +90,10 @@ class GettextMessageSource extends MessageSource
/** /**
* Returns message file path for the specified language and category. * Returns message file path for the specified language and category.
* *
* @param string $category the message category
* @param string $language the target language * @param string $language the target language
* @return string path to message file * @return string path to message file
*/ */
protected function getMessageFilePath($category, $language) protected function getMessageFilePath($language)
{ {
$messageFile = Yii::getAlias($this->basePath) . '/' . $language . '/' . $this->catalog; $messageFile = Yii::getAlias($this->basePath) . '/' . $language . '/' . $this->catalog;
if ($this->useMoFile) { if ($this->useMoFile) {
...@@ -108,10 +107,11 @@ class GettextMessageSource extends MessageSource ...@@ -108,10 +107,11 @@ class GettextMessageSource extends MessageSource
/** /**
* Loads the message translation for the specified language and category or returns null if file doesn't exist. * Loads the message translation for the specified language and category or returns null if file doesn't exist.
* *
* @param $messageFile string path to message file * @param string $messageFile path to message file
* @param string $category the message category
* @return array|null array of messages or null if file not found * @return array|null array of messages or null if file not found
*/ */
protected function loadMessagesFromFile($messageFile) protected function loadMessagesFromFile($messageFile, $category)
{ {
if (is_file($messageFile)) { if (is_file($messageFile)) {
if ($this->useMoFile) { if ($this->useMoFile) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment