From f3d506c85708fdd7329bb772042fa2685b4866d0 Mon Sep 17 00:00:00 2001 From: Josh North Date: Thu, 10 Jun 2021 06:12:24 -0400 Subject: [PATCH] Better language fail --- index.php | 2 +- src/Language/Translate.php | 32 ++++++++++++++------------------ src/Language/en.lang.ini.example | 1 + 3 files changed, 16 insertions(+), 19 deletions(-) diff --git a/index.php b/index.php index 0e6cee6..7332e30 100644 --- a/index.php +++ b/index.php @@ -257,7 +257,7 @@ if (Registry::AUTHMETHOD == 'SAML') {
-
 
+
 

diff --git a/src/Language/Translate.php b/src/Language/Translate.php index 5db257e..5a72c35 100644 --- a/src/Language/Translate.php +++ b/src/Language/Translate.php @@ -26,23 +26,19 @@ use App\LobbySIO\Config\Registry; * @author josh.north */ class Translate { - - private $UserLng; - private $langSelected; - public $lang = array(); - public function __construct($userLanguage){ - $this->UserLng = $userLanguage; - //construct lang file - $langFile = Registry::DIRPATH . 'src/Language/'. $this->UserLng . '.lang.ini'; - if(!file_exists($langFile)){ - //throw new \Exception("Language could not be loaded"); //or default to a language - $langFile = Registry::DIRPATH . 'src/Language/'. $this->UserLng . '.lang.ini.example'; - } - $this->lang = parse_ini_file($langFile); - } - public function userLanguage(){ - return $this->lang; - } - + private $UserLng; + private $langSelected; + public $lang = array(); + public function __construct($userLanguage){ + $this->UserLng = $userLanguage; + if(file_exists(Registry::DIRPATH . 'src/Language/'. $this->UserLng . '.lang.ini.example')){ $example = parse_ini_file(Registry::DIRPATH . 'src/Language/'. $this->UserLng . '.lang.ini.example'); }; + if(file_exists(Registry::DIRPATH . 'src/Language/'. $this->UserLng . '.lang.ini')){ $custom = parse_ini_file(Registry::DIRPATH . 'src/Language/'. $this->UserLng . '.lang.ini'); }; + if(isset($example)&&isset($custom)){$this->lang = array_merge($example,$custom);} + elseif(!isset($custom)){$this->lang = array_merge($example);} + elseif(!isset($example)){$this->lang = array_merge($custom);} + } + public function userLanguage(){ + return $this->lang; + } } diff --git a/src/Language/en.lang.ini.example b/src/Language/en.lang.ini.example index 178d193..9b596c7 100644 --- a/src/Language/en.lang.ini.example +++ b/src/Language/en.lang.ini.example @@ -1,3 +1,4 @@ +TTTT = 'TESTTESTTESTTEST' ACCESS_LEVEL = 'Access' ACCOUNT = 'Account' ACCOUNT_INFO_DESC = 'You may make changes to your user profile below. To change your password, enter a new password twice below and press save. Minimum password length is '