willdurand / Negotiation

Content Negotiation tools for PHP.
https://williamdurand.fr/Negotiation/
MIT License
1.41k stars 62 forks source link

Does not work with single language #102

Closed crtl closed 2 years ago

crtl commented 5 years ago

When youve only selected a single language in your browser (I tried it in Firefox 68) the library will not detect the language. The header sent is:

Accept-Language: de-DE
Marcin-TA commented 4 years ago

Did you find any another working library?

Seb33300 commented 4 years ago

Same issue here with LanguageNegotiator.

I have a computer where Edge returns only:

Accept-Language: fr-FR

And

$negotiator->getBest('fr-FR', ['en', 'fr']); // returns NULL
Seb33300 commented 4 years ago

Just found out that the issue was already fixed on 2.x branch, but no new tag have been created since a while.

You need configure your composer.json to use the current 2.x branch to get the fix:

"willdurand/negotiation": "2.x-dev"
emri99 commented 4 years ago

This should be greatly appreciated to create a new release 2.3.2 with this fix (for PHP 5.x) However, I haven't been able to find a fix for version related to PHP 7.x, did I miss something ? Thanks ;)

Seb33300 commented 3 years ago

@willdurand I tested the new 3.0.0 tag but this issue is still here.

This can be easily reproduced with:

$negotiator = new \Negotiation\LanguageNegotiator();
$bestLanguage = $negotiator->getBest('fr-FR', ['en', 'fr']); // returns NULL

When using "willdurand/negotiation": "2.x-dev", it works as expected:

$negotiator = new \Negotiation\LanguageNegotiator();
$bestLanguage = $negotiator->getBest('fr-FR', ['en', 'fr']); // returns fr

it looks like one fix applied to 2.x-dev was not properly merged into 3.0

willdurand commented 3 years ago

it looks like one fix applied to 2.x-dev was not properly merged into 3.0

mm interesting and sorry about that. Maybe I should have merged 2.x into master before releasing 3.0. I thought those branches were in sync already.

Seb33300 commented 3 years ago

I didn't try it but #113 looks to be the missing fix

willdurand commented 3 years ago

I'll take a look this week.

Seb33300 commented 3 years ago

Hello @willdurand, any news on this?

willdurand commented 2 years ago

should be fixed by https://github.com/willdurand/Negotiation/pull/113, I am sorry that this took almost a year.