Skip to content

Language variant redirect does not respect priorities #1302

@mabar

Description

@mabar

When I open links like https://www.php.net/stat, it opens chinese version of documentation.

It is caused by header Accept-Language: cs,en;q=0.9,fr;q=0.8,zh-CN;q=0.7,zh;q=0.6
When I change it to Accept-Language: cs,en;q=0.9,fr;q=0.8 (remove chinese), it sends me to english version
That is not expected, because language should be chosen by priority - czech (no q parameter is implicitly 1, highest), english, french and then chinese. Czech is not supported by php.net, therefore english version should open.

This is proper implementation that returns supported language that has the highest priority: https://github.com/nette/http/blob/a02f3d131f8a5dbd573244a6813ed316cde8d6ad/src/Http/Request.php#L308-L335
Here is proof: https://3v4l.org/UJnKb#vnull

Possibly related to #435

I have fresh Windows 11 and Opera installation and for some reason french and chinese were added without me doing that and seeing chinese docs when my system is set to czech and english was really confusing.

I don't feel quite confident with the website codebase, so this will hopefully allow you to fix the current behavior. Thank you

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions