Add function for getting user language without using cookies
This commit is contained in:
parent
a8599667c9
commit
6426947e60
|
@ -465,6 +465,23 @@ final class MD_STD {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns expected user language without making use of a cookie..
|
||||
*
|
||||
* @param non-empty-array<non-empty-string> $allowed_langs Allowed languages.
|
||||
* @param non-empty-string $default_lang Default language.
|
||||
*
|
||||
* @return non-empty-string
|
||||
*/
|
||||
public static function get_user_lang_no_cookie(array $allowed_langs, string $default_lang):string {
|
||||
|
||||
if (isset($_GET['navlang']) and in_array($_GET['navlang'], $allowed_langs, true)) {
|
||||
return $_GET['navlang'];
|
||||
}
|
||||
return $lang = self::lang_getfrombrowser($allowed_langs, $default_lang, "", false);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Function lang_getfrombrowser gets the browser language based on HTTP headers.
|
||||
*
|
||||
|
@ -474,7 +491,7 @@ final class MD_STD {
|
|||
* @param string $lang_variable Currently set language variable. Optional.
|
||||
* @param boolean $strict_mode Whether to demand "de-de" (true) or "de" (false) Optional.
|
||||
*
|
||||
* @return string
|
||||
* @return non-empty-string
|
||||
*/
|
||||
public static function lang_getfrombrowser(array $allowed_languages, string $default_language, string $lang_variable = "", bool $strict_mode = true):string {
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user