adding configuration option to set a default language and/or force it,

resolves #39
This commit is contained in:
El RIDO
2015-10-18 20:38:07 +02:00
parent ca07398b66
commit e3f4aa982c
4 changed files with 47 additions and 2 deletions

View File

@@ -26,6 +26,15 @@ class i18n
*/
protected static $_language = 'en';
/**
* language fallback
*
* @access protected
* @static
* @var string
*/
protected static $_languageFallback = 'en';
/**
* language labels
*
@@ -248,6 +257,20 @@ class i18n
return array_intersect_key(self::$_languageLabels, array_flip($languages));
}
/**
* set the default language
*
* @access public
* @static
* @param string $lang
* @return void
*/
public static function setLanguageFallback($lang)
{
if (in_array($lang, self::getAvailableLanguages()))
self::$_languageFallback = $lang;
}
/**
* get language file path
*
@@ -339,7 +362,7 @@ class i18n
}
if (count($matches) === 0)
{
return 'en';
return self::$_languageFallback;
}
krsort($matches);
$topmatches = current($matches);