Commit c1f977cd by Qiang Xue

Simplified the default file map for PhpMessageSource.

parent 09a91910
...@@ -26,6 +26,8 @@ use Yii; ...@@ -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 ...@@ -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);
......
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