Drop rcube_browser::$lang property

You should use Accept-Language header instead, as we do in other place
pull/6911/head
Aleksander Machniak 5 years ago
parent 1a10074b85
commit 27bfd0884e

@ -61,12 +61,9 @@ class rcube_browser
/** @var bool $mz Browser is Mozilla Firefox */
public $mz = false;
/** @var string $lang Language code */
public $lang = 'en';
/**
* Object construstor
* Object constructor
*/
public function __construct()
{
@ -99,16 +96,8 @@ class rcube_browser
else if ($this->safari && preg_match('/(version|safari)\/([0-9.]+)/', $HTTP_USER_AGENT, $regs)) {
$this->ver = (float) $regs[1];
}
else if (preg_match('/(chrome|khtml|version)(\s*|\/)([0-9.]+)/', $HTTP_USER_AGENT, $regs)) {
else if (preg_match('/(chrome|khtml|version|msie|rv:)(\s*|\/)([0-9.]+)/', $HTTP_USER_AGENT, $regs)) {
$this->ver = (float) $regs[3];
}
else if (preg_match('/rv:([0-9.]+)/', $HTTP_USER_AGENT, $regs)) {
$this->ver = (float) $regs[1];
}
// Language code
if (preg_match('/ ([a-z]{2})-([a-z]{2})/', $HTTP_USER_AGENT, $regs)) {
$this->lang = $regs[1];
}
}
}

@ -61,29 +61,6 @@ class Framework_Browser extends PHPUnit_Framework_TestCase
return $this->extractDataSet(array('version'));
}
private function extractDataSet($keys)
{
$keys = array_merge(array('useragent'), $keys);
$browser = $this->useragents();
$extracted = array();
foreach ($browser as $label => $data) {
foreach($keys as $key) {
$extracted[$data['useragent']][] = $data[$key];
}
}
return $extracted;
}
function lang()
{
return $this->extractDataSet(array('lang'));
}
function browsers()
{
return $this->extractDataSet(array('isOpera', 'isChrome', 'isIE', 'isEdge', 'isNS', 'isSafari', 'isMZ'));
@ -105,7 +82,6 @@ class Framework_Browser extends PHPUnit_Framework_TestCase
'isEdge' => false,
'isSafari' => false,
'isMZ' => true,
'lang' => 'en-US',
),
'LINUX: Bon Echo ' => array(
@ -121,7 +97,6 @@ class Framework_Browser extends PHPUnit_Framework_TestCase
'isEdge' => false,
'isSafari' => false,
'isMZ' => true,
'lang' => 'en-US',
),
'Chrome Mac' => array(
@ -137,7 +112,6 @@ class Framework_Browser extends PHPUnit_Framework_TestCase
'isEdge' => false,
'isSafari' => false,
'isMZ' => false,
'lang' => 'en-US',
),
'IE 11' => array(
@ -153,7 +127,6 @@ class Framework_Browser extends PHPUnit_Framework_TestCase
'isEdge' => false,
'isSafari' => false,
'isMZ' => false,
'lang' => '',
),
'Opera 15' => array(
@ -169,7 +142,6 @@ class Framework_Browser extends PHPUnit_Framework_TestCase
'isEdge' => false,
'isSafari' => false,
'isMZ' => false,
'lang' => '',
),
'Edge 14' => array(
@ -185,7 +157,6 @@ class Framework_Browser extends PHPUnit_Framework_TestCase
'isEdge' => true,
'isSafari' => false,
'isMZ' => false,
'lang' => '',
),
);
}
@ -195,6 +166,23 @@ class Framework_Browser extends PHPUnit_Framework_TestCase
return $this->extractDataSet(array('isWin', 'isLinux', 'isUnix', 'isMac'));
}
private function extractDataSet($keys)
{
$keys = array_merge(array('useragent'), $keys);
$browser = $this->useragents();
$extracted = array();
foreach ($browser as $label => $data) {
foreach($keys as $key) {
$extracted[$data['useragent']][] = $data[$key];
}
}
return $extracted;
}
/**
* @param string $useragent
* @return rcube_browser

Loading…
Cancel
Save