Browse Source

Simplified the default file map for PhpMessageSource.

tags/2.0.0-beta
Qiang Xue 11 years ago
parent
commit
c1f977cd45
  1. 6
      framework/yii/i18n/PhpMessageSource.php

6
framework/yii/i18n/PhpMessageSource.php

@ -26,6 +26,8 @@ use Yii;
* ); * );
* ~~~ * ~~~
* *
* You may use [[fileMap]] to customize the association between category names and the file names.
*
* @author Qiang Xue <qiang.xue@gmail.com> * @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0 * @since 2.0
*/ */
@ -60,10 +62,8 @@ class PhpMessageSource extends MessageSource
$messageFile = Yii::getAlias($this->basePath) . "/$language/"; $messageFile = Yii::getAlias($this->basePath) . "/$language/";
if (isset($this->fileMap[$category])) { if (isset($this->fileMap[$category])) {
$messageFile .= $this->fileMap[$category]; $messageFile .= $this->fileMap[$category];
} elseif (($pos = strrpos($category, '\\')) !== false) {
$messageFile .= (substr($category, $pos) . '.php');
} else { } else {
$messageFile .= "$category.php"; $messageFile .= str_replace('\\', '/', $category) . '.php';
} }
if (is_file($messageFile)) { if (is_file($messageFile)) {
$messages = include($messageFile); $messages = include($messageFile);

Loading…
Cancel
Save