fix(common): handle locales with existing Unicode extension (e.g. ar-u-nu-arab)#84
Open
crossi-dev wants to merge 1 commit into
Open
fix(common): handle locales with existing Unicode extension (e.g. ar-u-nu-arab)#84crossi-dev wants to merge 1 commit into
crossi-dev wants to merge 1 commit into
Conversation
…ting Unicode extensions (formkit#68)
|
Someone is attempting to deploy a commit to the Formkit Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #68
Problem
format()throwsRangeError: Invalid language tagwhen the locale already carries a Unicode extension block, e.g.ar-u-nu-arab(Arabic with Arabic-Indic numerals).The cause is in
createPartMap(src/common.ts): it pins the hour cycle by string-concatenating the extension onto the locale —For
ar-u-nu-arabthis producesar-u-nu-arab-u-hc-h23, which is invalid BCP 47 — a tag may only contain one-u-block.Intl.DateTimeFormatthen throws.Fix
Use
Intl.Locale, which understands the BCP 47 grammar and merges extension subtags into a single, valid-u-block (preserving-nu-arab):One-line logic change, plus a regression test.
Verified
does not throw when locale includes a numbering system) fails before the change with the exactRangeError, passes after.main(machine-local timezone-offset expectations),+1net passing.Came across Tempo and noticed #68 had been open a while, so I went ahead and fixed it. No strings attached — I'm with Choreless and we like contributing real fixes to projects we use. If it's useful and you ever want a hand with something larger, happy to help.
— Charles