Skip to content

fix: send well-formed locale tag to time picker connector (#10244) (CP: 25.2) - #10255

Merged
web-padawan merged 2 commits into
25.2from
cherry-pick-10244-to-25.2-1790578923644
Sep 28, 2026
Merged

web-padawan merged 2 commits into
25.2from
cherry-pick-10244-to-25.2-1790578923644

Conversation

@vaadin-bot

Copy link
Copy Markdown
Collaborator

This PR cherry-picks changes from the original PR #10244 to branch 25.2.

Original PR description

Description

Fixes #3309
Follow-up to #9873

TimePicker built the locale tag by joining getLanguage() and getCountry() as they are. An ill-formed locale, such as new Locale("en_GB"), produced a tag like en_gb. The browser rejects it, so the connector threw The locale en_gb is not supported and never set up locale-based formatting. #9873 fixed only the text of that error.

  • Changed TimePicker to parse the tag with Locale.forLanguageTag and send only its language and region to the connector
    • Well-formed locales produce the same tag as before, and script and variant are still dropped
    • A tag used as the language keeps its region, e.g. new Locale("en-CA") sends en-CA
    • Ill-formed subtags are dropped, e.g. new Locale("en_GB") sends und, so the browser falls back to its default locale
  • Corrected the setLocale Javadoc, which promised an en-US fallback that never happened
  • Added unit tests in TimePickerLocaleTest for the tag sent to the connector, including a tag used as the language and an ill-formed language and country
  • Changed the browser-formatted time helper in TimePickerLocalizationView to build a well-formed tag, so it does not throw its own error for an ill-formed locale

Type of change

  • Bugfix

How to test

  1. Open TimePickerLocalizationView.java at /vaadin-time-picker/time-picker-localization/en_GB-XX-10-30
  2. Check the browser console and the dev-mode error dialog
  3. There is no vaadin-time-picker: The locale ... is not supported error, and the time picker shows 10:30 in the format of the browser default locale

🤖 Generated with Claude Code

## Description

Fixes #3309
Follow-up to #9873

`TimePicker` built the locale tag by joining `getLanguage()` and
`getCountry()` as they are. An ill-formed locale, such as `new
Locale("en_GB")`, produced a tag like `en_gb`. The browser rejects it,
so the connector threw `The locale en_gb is not supported` and never set
up locale-based formatting. #9873 fixed only the text of that error.

- Changed `TimePicker` to parse the tag with `Locale.forLanguageTag` and
send only its language and region to the connector
- Well-formed locales produce the same tag as before, and script and
variant are still dropped
- A tag used as the language keeps its region, e.g. `new
Locale("en-CA")` sends `en-CA`
- Ill-formed subtags are dropped, e.g. `new Locale("en_GB")` sends
`und`, so the browser falls back to its default locale
- Corrected the `setLocale` Javadoc, which promised an `en-US` fallback
that never happened
- Added unit tests in `TimePickerLocaleTest` for the tag sent to the
connector, including a tag used as the language and an ill-formed
language and country
- Changed the browser-formatted time helper in
`TimePickerLocalizationView` to build a well-formed tag, so it does not
throw its own error for an ill-formed locale

## Type of change

- Bugfix

## How to test

1. Open `TimePickerLocalizationView.java` at
`/vaadin-time-picker/time-picker-localization/en_GB-XX-10-30`
2. Check the browser console and the dev-mode error dialog
3. There is no `vaadin-time-picker: The locale ... is not supported`
error, and the time picker shows `10:30` in the format of the browser
default locale

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@web-padawan
web-padawan enabled auto-merge (squash) September 28, 2026 07:04
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@web-padawan
web-padawan merged commit 73f3580 into 25.2 Sep 28, 2026
9 of 13 checks passed
@web-padawan
web-padawan deleted the cherry-pick-10244-to-25.2-1790578923644 branch September 28, 2026 07:36
@sonarqubecloud

Copy link
Copy Markdown

@vaadin-bot

Copy link
Copy Markdown
Collaborator Author

This ticket/PR has been released with Vaadin 25.2.10.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants