Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AcceptHeaderLocaleResolver should match country locales against supported language locales [SPR-16457] #21002

Closed
spring-projects-issues opened this issue Feb 2, 2018 · 1 comment
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) status: backported An issue that has been backported to maintenance branches type: enhancement A general enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Feb 2, 2018

Oliver Becker opened SPR-16457 and commented

We are using the AcceptHeaderLocaleResolver along with a list of supported language locales to determine a matching locale based on the browser's accepted locales. This works pretty well for most browsers as those browsers always send also the (base) language locale as accepted locale.

For example if I configure Chrome to use "German (Germany)" as the preferred language, it will send both "de-DE" and "de" as accepted locales.

Unfortunately this is not the case in iOS where the request contains only a single "de-DE" locale. Currently the AcceptHeaderLocaleResolver will not accept "de-DE" if only "de" is in the list of supported locales, so it will fallback to the default locale.

I could work around this limitation by either creating a list of all possible country locales for our supported language locales or by modifying the HTTP request to strip the country part from the accepted locales.

It would be great if I don't have to do this and the AcceptHeaderLocaleResolver would match automatically a country specific locale against a supported language locale.


Affects: 4.3.14

Issue Links:

Referenced from: commits cd8a1bd, 4dc9645, 8fda96c

Backported to: 4.3.15

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented Feb 2, 2018

Juergen Hoeller commented

Good point! I've revised findSupportedLocale to fall back to a language-only match (for a supported locale without a country part) if no full match has been found

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) status: backported An issue that has been backported to maintenance branches type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants