Trying to reduce complexity of language init method.
This commit is contained in:
parent
9599759ade
commit
5f11e1997c
|
@ -103,12 +103,7 @@ class Lang
|
||||||
*/
|
*/
|
||||||
public static function init(Config $config)
|
public static function init(Config $config)
|
||||||
{
|
{
|
||||||
$matches = array();
|
self::loadAvailableLanguages();
|
||||||
foreach (glob(PHPCI_DIR . 'PHPCI/Languages/lang.*.php') as $file) {
|
|
||||||
if (preg_match('/lang\.([a-z]{2}\-?[a-z]*)\.php/', $file, $matches)) {
|
|
||||||
self::$languages[] = $matches[1];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Try cookies first:
|
// Try cookies first:
|
||||||
if (isset($_COOKIE) && array_key_exists('phpcilang', $_COOKIE) && self::setLanguage($_COOKIE['phpcilang'])) {
|
if (isset($_COOKIE) && array_key_exists('phpcilang', $_COOKIE) && self::setLanguage($_COOKIE['phpcilang'])) {
|
||||||
|
@ -160,4 +155,14 @@ class Lang
|
||||||
|
|
||||||
return $strings;
|
return $strings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected static function loadAvailableLanguages()
|
||||||
|
{
|
||||||
|
$matches = array();
|
||||||
|
foreach (glob(PHPCI_DIR . 'PHPCI/Languages/lang.*.php') as $file) {
|
||||||
|
if (preg_match('/lang\.([a-z]{2}\-?[a-z]*)\.php/', $file, $matches)) {
|
||||||
|
self::$languages[] = $matches[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue