Permalink
Browse files

#596: Move setting of language to constructor of Flux_Lang class.

  • Loading branch information...
franzliedke committed Feb 21, 2012
1 parent 74b127d commit cb5244f309698e4c6bdf9f066e5da6665516a0c3
Showing with 15 additions and 5 deletions.
  1. +14 −3 include/classes/lang.php
  2. +1 −2 include/common.php
View
@@ -38,6 +38,17 @@ class Flux_Lang
* @var array
*/
protected $loadedResources = array();
+
+
+ /**
+ * Constructor
+ *
+ * @param string $lang
+ */
+ public function __construct($lang)
+ {
+ $this->setLanguage($lang);
+ }
/**
* Get a list of all available languages
@@ -92,7 +103,7 @@ public static function setLanguageDirectory($dir)
*/
public function setDefaultLanguage($lang)
{
- if (file_exists(self::$langDir.'/'.$lang))
+ if (self::languageExists($lang))
$this->defaultLang = $lang;
else
throw new Exception('It seems like default language pack "'.$lang.'" does not exist.');
@@ -104,9 +115,9 @@ public function setDefaultLanguage($lang)
* @param array $lang
* @return void
*/
- public function setLanguage($lang)
+ protected function setLanguage($lang)
{
- if (file_exists(self::$langDir.'/'.$lang))
+ if (self::languageExists($lang))
$this->lang = $lang;
else
throw new Exception('It seems like language pack "'.$lang.'" does not exist.');
View
@@ -162,9 +162,8 @@ function stripslashes_array($array)
// Load the language system
require PUN_ROOT.'include/classes/lang.php';
-$lang = new Flux_Lang();
+$lang = new Flux_Lang($pun_user['language']);
$lang->setDefaultLanguage('English');
-$lang->setLanguage($pun_user['language']);
// Load the common language file
$lang->load('common');

0 comments on commit cb5244f

Please sign in to comment.