mirror of
https://code.castopod.org/adaures/castopod.git
synced 2024-09-27 20:21:59 +02:00
24 lines
541 B
PHP
24 lines
541 B
PHP
|
<?php
|
||
|
/**
|
||
|
* @copyright 2020 Podlibre
|
||
|
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
||
|
* @link https://castopod.org/
|
||
|
*/
|
||
|
|
||
|
/**
|
||
|
* Gets the browser default language using the request header key `HTTP_ACCEPT_LANGUAGE`
|
||
|
*
|
||
|
* @param mixed $http_accept_language
|
||
|
*
|
||
|
* @return string|null ISO 639-1 language code or null
|
||
|
*/
|
||
|
function get_browser_language($http_accept_language)
|
||
|
{
|
||
|
$langs = explode(',', $http_accept_language);
|
||
|
if (!empty($langs)) {
|
||
|
return substr($langs[0], 0, 2);
|
||
|
}
|
||
|
|
||
|
return null;
|
||
|
}
|