Skip to content

StringToLocaleConverter should allow BCP 47 values [SPR-16188] #20736

Closed
@spring-projects-issues

Description

@spring-projects-issues

adrian opened SPR-16188 and commented

I'm using Spring Boot to setup locale in spring mvc.

I'm trying to use BCP 47 for spring.mvc.locale value, but I end up with a

Property: spring.mvc.locale
Value: en-US
Reason: Failed to convert property value of type 'java.lang.String' to required type 'java.util.Locale' for property 'locale'; nested exception is org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [java.lang.String] to type [java.util.Locale]

StringToLocaleConverter (relies on StringUtils.parseLocaleString) relies on _ delimiters, which is not BCP 47.

Could StringToLocaleConverter be improved to handle BCP 47 (or otherwise try both formats ?)

For BCP-47, it would correspond to calling
https://docs.oracle.com/javase/7/docs/api/java/util/Locale.html#forLanguageTag(java.lang.String)

wdyt ?


Affects: 4.3.10

Issue Links:

Referenced from: commits ef3f93e

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions