PHP_SMART_HOME_V3/app/class/LangManager.php
2019-10-11 12:24:20 +02:00

42 lines
745 B
PHP

<?php
/**
* Language Manager
*/
class LanguageManager
{
private $lngCode = 'en';
private $lngDatabase = [];
function __construct(string $lngCode)
{
$this->lngCode = $lngCode;
}
function load()
{
$file = './app/lang/en.php';
$arrayFirst = include($file);
$file = './app/lang/' . $this->lngCode . '.php';
$arraySecond = include($file);
$this->lngDatabase = array_merge($arrayFirst,$arraySecond);
return true;
}
function get(string $stringKey)
{
if (isset($this->lngDatabase[$stringKey])) {
return $this->lngDatabase[$stringKey];
}
return $stringKey;
}
function echo(string $stringKey)
{
if (isset($this->lngDatabase[$stringKey])) {
return $this->lngDatabase[$stringKey];
}
return $stringKey;
}
}