You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
AcceptHeaderLocaleResolver should match country locales against supported language locales [SPR-16457] #21002
in: webIssues in web modules (web, webmvc, webflux, websocket)status: backportedAn issue that has been backported to maintenance branchestype: enhancementA general enhancement
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.
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
in: webIssues in web modules (web, webmvc, webflux, websocket)status: backportedAn issue that has been backported to maintenance branchestype: enhancementA general enhancement
Activity
spring-projects-issues commentedon Feb 2, 2018
Juergen Hoeller commented
Good point! I've revised
findSupportedLocaleto fall back to a language-only match (for a supported locale without a country part) if no full match has been found