Skip to content

Commit

Permalink
Tweak languages method
Browse files Browse the repository at this point in the history
  • Loading branch information
jenssegers committed Jan 16, 2014
1 parent 006707c commit 45d3018
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/Jenssegers/Agent/Agent.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,16 @@ public function getRules()
*
* @return array
*/
public function languages()
public function languages($acceptLanguage = null)
{
$header = $this->getHttpHeader('HTTP_ACCEPT_LANGUAGE');
if (!$acceptLanguage)
{
$acceptLanguage = $this->getHttpHeader('HTTP_ACCEPT_LANGUAGE');
}

if ($header)
if ($acceptLanguage)
{
return explode(',', preg_replace('/(;q=[0-9\.]+)/i', '', strtolower(trim($header))));
return explode(',', preg_replace('/(;q=[0-9\.]+)/i', '', strtolower(trim($acceptLanguage))));
}

return array();
Expand Down

0 comments on commit 45d3018

Please sign in to comment.