Skip to content

Improve documentation on support for a language-only Locale requested via "Accept-Language" #28673

Closed
@chulbert

Description

@chulbert
@Test
public void resolvePreferredAgainstLanguageOnly() {
    this.resolver.setSupportedLocales(Arrays.asList(GERMANY, US));
    assertThat(this.resolver.resolveLocaleContext(exchange(UK, ENGLISH)).getLocale()).isEqualTo(US);
}

This test should pass. If a client requests en-GB, en and the supported locales are de-DE, en-US then this should resolve to US because en (English of any kind) matches en-US (US English). Instead it incorrectly resolves to en-GB.

Note: There is an existing test with the same name that I believe has this wrong:

@Test
public void resolvePreferredAgainstLanguageOnly() {
    this.resolver.setSupportedLocales(Collections.singletonList(ENGLISH));
    assertThat(this.resolver.resolveLocaleContext(exchange(GERMANY, US, UK)).getLocale()).isEqualTo(ENGLISH);
}

This test should also pass but not because it "matches" -- it should resolve to ENGLISH because that's the only supported locale.

This affects all versions.

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: documentationA documentation task

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions