Skip to content

fix: handle missing region in navigator.language for chart locale#973

Merged
fortmarek merged 3 commits intomainfrom
fix/locale-invalid-language-tag
Mar 4, 2026
Merged

fix: handle missing region in navigator.language for chart locale#973
fortmarek merged 3 commits intomainfrom
fix/locale-invalid-language-tag

Conversation

@fortmarek
Copy link
Copy Markdown
Member

Summary

  • Fix RangeError: Invalid language tag: en-undefined crash when navigator.language has no region suffix (e.g. "en" instead of "en-US")
  • Use navigator.language directly instead of extracting and re-assembling the region, which also respects the user's actual locale rather than forcing en-*
  • This was breaking chart rendering and date pickers on affected browsers

Test plan

  • Verify charts render correctly with navigator.language set to "en" (no region)
  • Verify charts render correctly with navigator.language set to "en-US" (with region)
  • Verify date formatting in chart tooltips and axis labels

🤖 Generated with Claude Code

fortmarek and others added 2 commits March 4, 2026 12:40
When navigator.language is just "en" without a region suffix (e.g. "en-US"),
the locale() function produced "en-undefined", an invalid language tag that
crashes toLocaleDateString() and breaks chart rendering and date pickers.

Use navigator.language directly instead of extracting and re-assembling the
region component.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
navigator.language is supported in all modern browsers and always
returns a string. The userLanguage fallback was only needed for IE.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@fortmarek fortmarek marked this pull request as ready for review March 4, 2026 11:51
@fortmarek fortmarek requested a review from a team as a code owner March 4, 2026 11:51
@fortmarek fortmarek requested review from cschmatzler and removed request for a team March 4, 2026 11:51
@dosubot dosubot bot added size:S This PR changes 10-29 lines, ignoring generated files. changelog:fixed labels Mar 4, 2026
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Mar 4, 2026
@fortmarek fortmarek merged commit a1e01c4 into main Mar 4, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog:fixed lgtm This PR has been approved by a maintainer size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants