Skip to content

Commit

Permalink
support multi-language in cli
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanLuLyf committed Jul 8, 2020
1 parent 4ab8b02 commit f0886e7
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions BunnyPHP/Language.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ class Language implements \ArrayAccess
public function loadLanguage($lang, $basePath)
{
if (!$lang) {
$lang = strtolower(trim(explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE'])[0]));
if (key_exists('HTTP_ACCEPT_LANGUAGE', $_SERVER)) {
$lang = strtolower(trim(explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE'])[0]));
} elseif (key_exists('LANG', $_SERVER)) {
$lang = str_replace('_', '-', strtolower(trim(explode('.', $_SERVER['LANG'])[0])));
}
}
if (!$basePath) {
$basePath = APP_PATH . 'lang/';
Expand Down Expand Up @@ -101,4 +105,4 @@ public function offsetUnset($offset)
{
unset($this->translation[$offset]);
}
}
}

0 comments on commit f0886e7

Please sign in to comment.