mirror of
https://git.steelants.cz/SH/PHP_SMART_HOME_V3.git
synced 2026-10-11 17:54:34 +00:00
Big LNG MNG update for revox
This commit is contained in:
1 parent
cea2573875
commit
407d1fa8a9
25 files changed
+202
-152
No files matched your search
@@ -7,24 +7,36 @@ class LanguageManager
|
||||
|
||||
private $lngCode = 'en';
|
||||
private $lngDatabase = [];
|
||||
private $debug = false;
|
||||
|
||||
function __construct(string $lngCode)
|
||||
function __construct(string $lngCode, bool $debug = false)
|
||||
{
|
||||
$this->lngCode = $lngCode;
|
||||
$this->debug = $debug;
|
||||
}
|
||||
|
||||
function load()
|
||||
{
|
||||
$file = './app/lang/en.php';
|
||||
if (!file_exists($file)){
|
||||
die();
|
||||
//TODO add lng EXEPTIONS
|
||||
}
|
||||
$arrayFirst = include($file);
|
||||
$file = './app/lang/' . $this->lngCode . '.php';
|
||||
$arraySecond = include($file);
|
||||
$arraySecond = [];
|
||||
if (file_exists($file)){
|
||||
$arraySecond = include($file);
|
||||
}
|
||||
$this->lngDatabase = array_merge($arrayFirst,$arraySecond);
|
||||
return true;
|
||||
}
|
||||
|
||||
function get(string $stringKey)
|
||||
{
|
||||
if ($this->debug) {
|
||||
return $stringKey;
|
||||
}
|
||||
if (isset($this->lngDatabase[$stringKey])) {
|
||||
return $this->lngDatabase[$stringKey];
|
||||
}
|
||||
@@ -33,9 +45,15 @@ class LanguageManager
|
||||
|
||||
function echo(string $stringKey)
|
||||
{
|
||||
if (isset($this->lngDatabase[$stringKey])) {
|
||||
return $this->lngDatabase[$stringKey];
|
||||
if ($this->debug) {
|
||||
echo $stringKey;
|
||||
return;
|
||||
}
|
||||
return $stringKey;
|
||||
if (isset($this->lngDatabase[$stringKey])) {
|
||||
echo $this->lngDatabase[$stringKey];
|
||||
return;
|
||||
}
|
||||
echo $stringKey;
|
||||
return;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user