Browse Source

Cleaning up some code

Jose Lorenzo Rodriguez 11 years ago
parent
commit
77d8c1150f
1 changed files with 8 additions and 10 deletions
  1. 8 10
      src/I18n/MessagesFileLoader.php

+ 8 - 10
src/I18n/MessagesFileLoader.php

@@ -31,19 +31,10 @@ class MessagesFileLoader {
 
 	protected $_extension;
 
-	protected $_basePath;
-
 	public function __construct($name, $locale, $extension = 'po') {
 		$this->_name = $name;
 		$this->_locale = $locale;
 		$this->_extension = $extension;
-
-		$pluginName = Inflector::camelize($name);
-		$this->_basePath = APP . 'Locale' . DS;
-
-		if (Plugin::loaded($pluginName)) {
-			$this->_basePath = Plugin::path($pluginName) . 'Locale' . DS;
-		}
 	}
 
 	public function __invoke() {
@@ -75,8 +66,15 @@ class MessagesFileLoader {
 			$locale['language']
 		];
 
+		$pluginName = Inflector::camelize($this->_name);
+		$basePath = APP . 'Locale' . DS;
+
+		if (Plugin::loaded($pluginName)) {
+			$basePath = Plugin::path($pluginName) . 'Locale' . DS;
+		}
+
 		foreach ($folders as $folder) {
-			$path = $this->_basePath  . $folder . DS . 'LC_MESSAGES' . DS;
+			$path = $basePath  . $folder . DS . 'LC_MESSAGES' . DS;
 			if (is_dir($path)) {
 				return $path;
 			}