Consistent html lang attribute (#2)
This commit is contained in:
parent
deab83f737
commit
dcc850bf01
2 changed files with 7 additions and 8 deletions
|
@ -58,7 +58,11 @@ class Lang
|
||||||
$lang = strtolower(substr($lang, 0, 2));
|
$lang = strtolower(substr($lang, 0, 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
self::$instance = new self($lang, $path);
|
if (file_exists(($path ? $path : self::LANG_PATH) . $lang . '.lang.php')) {
|
||||||
|
self::$instance = new self($lang, $path);
|
||||||
|
} else {
|
||||||
|
self::$instance = new self(self::DEFAULT_LANG, $path);
|
||||||
|
}
|
||||||
|
|
||||||
return self::$instance;
|
return self::$instance;
|
||||||
}
|
}
|
||||||
|
@ -85,7 +89,7 @@ class Lang
|
||||||
|
|
||||||
if (array_key_exists($lang, $this->cache)) {
|
if (array_key_exists($lang, $this->cache)) {
|
||||||
$transDict = $this->cache[$lang];
|
$transDict = $this->cache[$lang];
|
||||||
} elseif (file_exists($this->path . $lang . '.lang.php')) {
|
} else if (file_exists($this->path . $lang . '.lang.php')) {
|
||||||
$transDict = include $this->path . $lang . '.lang.php';
|
$transDict = include $this->path . $lang . '.lang.php';
|
||||||
$this->cache[$lang] = $transDict;
|
$this->cache[$lang] = $transDict;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -60,11 +60,6 @@ $container['database'] = function ($container) use (&$config) {
|
||||||
|
|
||||||
Lang::build(substr(@$_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2), __DIR__. '/../resources/lang/');
|
Lang::build(substr(@$_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2), __DIR__. '/../resources/lang/');
|
||||||
|
|
||||||
$container['lang'] = function ($container) {
|
|
||||||
return Lang::getInstance();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
$container['view'] = function ($container) use (&$config) {
|
$container['view'] = function ($container) use (&$config) {
|
||||||
$view = new \Slim\Views\Twig(__DIR__ . '/../resources/templates', [
|
$view = new \Slim\Views\Twig(__DIR__ . '/../resources/templates', [
|
||||||
'cache' => __DIR__ . '/../resources/cache',
|
'cache' => __DIR__ . '/../resources/cache',
|
||||||
|
@ -82,7 +77,7 @@ $container['view'] = function ($container) use (&$config) {
|
||||||
$view->getEnvironment()->addGlobal('request', $container->get('request'));
|
$view->getEnvironment()->addGlobal('request', $container->get('request'));
|
||||||
$view->getEnvironment()->addGlobal('alerts', Session::getAlert());
|
$view->getEnvironment()->addGlobal('alerts', Session::getAlert());
|
||||||
$view->getEnvironment()->addGlobal('session', Session::all());
|
$view->getEnvironment()->addGlobal('session', Session::all());
|
||||||
$view->getEnvironment()->addGlobal('current_lang', $container->get('lang')->getLang());
|
$view->getEnvironment()->addGlobal('current_lang', Lang::getInstance()->getLang());
|
||||||
$view->getEnvironment()->addGlobal('PLATFORM_VERSION', PLATFORM_VERSION);
|
$view->getEnvironment()->addGlobal('PLATFORM_VERSION', PLATFORM_VERSION);
|
||||||
|
|
||||||
$view->getEnvironment()->addFunction(new Twig_Function('route', 'route'));
|
$view->getEnvironment()->addFunction(new Twig_Function('route', 'route'));
|
||||||
|
|
Loading…
Reference in a new issue