forked from verdnatura/hedera-web
48 lines
761 B
PHP
Executable File
48 lines
761 B
PHP
Executable File
<?php
|
|
|
|
namespace
|
|
{
|
|
function i($stringId)
|
|
{
|
|
echo Vn\Locale::getString ($stringId);
|
|
}
|
|
|
|
function s($stringId)
|
|
{
|
|
return Vn\Locale::getString ($stringId);
|
|
}
|
|
}
|
|
|
|
namespace Vn
|
|
{
|
|
class Locale
|
|
{
|
|
static $strings = array ();
|
|
|
|
static function add ($strings)
|
|
{
|
|
foreach ($strings as $stringId => &$string)
|
|
self::$strings[$stringId] = &$string;
|
|
}
|
|
|
|
static function getString ($stringId)
|
|
{
|
|
if (isset (self::$strings[$stringId]))
|
|
return self::$strings[$stringId];
|
|
else
|
|
return $stringId;
|
|
}
|
|
|
|
static function loadFile ($path)
|
|
{
|
|
$file = 'locale/'. $_SESSION['lang'] .'/'. $path .'.json';
|
|
|
|
if (file_exists ($file)
|
|
&& ($jsonString = file_get_contents ($file)))
|
|
self::add (json_decode ($jsonString, TRUE));
|
|
}
|
|
}
|
|
}
|
|
|
|
?>
|