Skip to content

Fix to correctly handle browsers's HTTP_ACCEPT_LANGUAGE correctly#3

Open
mvdberge wants to merge 3 commits intozuiderkwast:masterfrom
mvdberge:master
Open

Fix to correctly handle browsers's HTTP_ACCEPT_LANGUAGE correctly#3
mvdberge wants to merge 3 commits intozuiderkwast:masterfrom
mvdberge:master

Conversation

@mvdberge
Copy link

Fix to correctly handle browsers's HTTP_ACCEPT_LANGUAGE correctly which can contain a qvalue (e.g. 'en-US;q=0.5')

Bump version to today's date.

@mvdberge
Copy link
Author

Added fixes for tab/space problems

// 3. Set the UI language to one of the browser's accepted languages
$languages = split(',', preg_replace('/\(;q=\d+\.\d+\)/i', '', getenv('HTTP_ACCEPT_LANGUAGE')));
foreach ($languages as $l) {
$l = substr($l, 0, strpos($l, ';'));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just change the preg_replace a few lines above to remove any semicolon and everything following it, i.e. preg_replace('/;.*/', '', getenv('HTTP_ACCEPT_LANGUAGE'))?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants