This commit is contained in:
JonatanRek
2019-10-11 12:24:20 +02:00
parent cb587e6e0e
commit cea2573875
2 changed files with 119 additions and 0 deletions

41
app/class/LangManager.php Normal file
View File

@@ -0,0 +1,41 @@
<?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;
}
}