Skip to content

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

Closed
@spring-projects-issues

Description

@spring-projects-issues

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

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)status: backportedAn issue that has been backported to maintenance branchestype: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions