Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[HttpKernel] Accept-Language and defaultLocale#54703

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
karimmorel wants to merge1 commit intosymfony:5.4
base:5.4
Choose a base branch
Loading
fromkarimmorel:http-kernel-accept-language-default

Conversation

karimmorel
Copy link

@karimmorelkarimmorel commentedApr 23, 2024
edited
Loading

QA
Branch5.4
Bug fixyes
New featureno
Deprecationsno
LicenseMIT

When theAccept-Language header is used to set the locale, if it's value is not within the list ofenabled_locales, the value fordefault_locale is overwritten by the first value of the list ofenabled_locales.

Seb33300 reacted with thumbs up emoji
@carsonbot
Copy link

Hey!

I see that this is your first PR. That is great! Welcome!

Symfony has acontribution guide which I suggest you to read.

In short:

  • Always add tests
  • Keep backward compatibility (seehttps://symfony.com/bc).
  • Bug fixes must be submitted against the lowest maintained branch where they apply (seehttps://symfony.com/releases)
  • Features and deprecations must be submitted against the 7.1 branch.

Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change.

When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor!
If this PR is merged in a lower version branch, it will be merged up to all maintained branches within a few days.

I am going to sit back now and wait for the reviews.

Cheers!

Carsonbot

@rosier
Copy link
Contributor

This looks more like a configuration issue to me. For this feature the order of locales is important.

https://symfony.com/doc/current/translation.html#selecting-the-language-preferred-by-the-user

@Seb33300
Copy link
Contributor

Seb33300 commentedApr 23, 2024
edited
Loading

Indeed, just found this in the documentation.

If it can't find a perfect match between them, this method returns the first locale passed as argument (that's why the order of the passed locales is important).

However, this behaviour looks wrong to me.
IMO, if it can't find a perfect match, I think it should return the default locale, not the first of the list.

And this PR fixes the issue by setting the default locale first in the list.

@rosier
Copy link
Contributor

I may be missing something, but can't you put in your config the default as the first value of the list ofenabled_locales

@karimmorel
Copy link
Author

I was not aware of that part of the documentation, but when I noticed that behaviour, I thought it was weirdly designed.

default_locale is used to set the locale, whileenabled_locales is used to limit it. So to me, it is weird to useenabled_locales to set the locale.

@Seb33300
Copy link
Contributor

@karimmorel you should also open a PR to update the documentation in case this PR is merged:
https://github.com/symfony/symfony-docs/edit/6.4/translation.rst

karimmorel reacted with thumbs up emoji

@Seb33300
Copy link
Contributor

Just realized that the documentation concerns the methodgetPreferredLanguage() and you did not change that method.
So you dont need to update the doc.

@fabpotfabpot modified the milestones:5.4,6.4Dec 14, 2024
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Projects
None yet
Milestone
6.4
Development

Successfully merging this pull request may close these issues.

5 participants
@karimmorel@carsonbot@rosier@Seb33300@fabpot

[8]ページ先頭

©2009-2025 Movatter.jp