Skip to content

Commit

Permalink
remove language stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
andreaselia committed Mar 29, 2024
1 parent 9255169 commit da0a00e
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 49 deletions.
27 changes: 0 additions & 27 deletions src/Agent.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,33 +138,6 @@ public static function getProperties(): array
);
}

public function languages(string $acceptLanguage = null): array
{
if ($acceptLanguage === null) {
$acceptLanguage = $this->getHttpHeader('HTTP_ACCEPT_LANGUAGE');
}

if (! $acceptLanguage) {
return [];
}

$languages = [];

// Parse accept language string.
foreach (explode(',', $acceptLanguage) as $piece) {
$parts = explode(';', $piece);
$language = strtolower($parts[0]);
$priority = empty($parts[1]) ? 1. : floatval(str_replace('q=', '', $parts[1]));

$languages[$language] = $priority;
}

// Sort languages by priority.
arsort($languages);

return array_keys($languages);
}

protected function findDetectionRulesAgainstUA(array $rules, $userAgent = null)
{
// TODO: added this user agent setting, wasn't there before though?
Expand Down
22 changes: 0 additions & 22 deletions tests/Unit/AgentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,28 +101,6 @@ class AgentTest extends TestCase
'Mozilla/5.0 (Linux; U; Android 2.2; en-us; Nexus One Build/FRF91) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1',
];

#[Test]
public function languages()
{
$agent = new Agent();
$agent->setHttpHeaders([
'HTTP_ACCEPT_LANGUAGE' => 'nl-NL,nl;q=0.8,en-US;q=0.6,en;q=0.4',
]);

$this->assertEquals(['nl-nl', 'nl', 'en-us', 'en'], $agent->languages());
}

#[Test]
public function languages_sorted()
{
$agent = new Agent();
$agent->setHttpHeaders([
'HTTP_ACCEPT_LANGUAGE' => 'en;q=0.4,en-US,nl;q=0.6',
]);

$this->assertEquals(['en-us', 'nl', 'en'], $agent->languages());
}

#[Test]
public function operating_systems()
{
Expand Down

0 comments on commit da0a00e

Please sign in to comment.