Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: support like 'enAU' 'en_AU' locales in IntlMessageFormat #1420

Closed
wants to merge 1 commit into from

Conversation

apades
Copy link

@apades apades commented Oct 14, 2024

If locales params like camel case 'enUS', undline 'en_US', it will throw err when i use dynamic values template, i find that intl-messageformat only support kebab-case locale.

Error like this

IntlError: INVALID_MESSAGE: Incorrect locale information provided
    at getFallbackFromErrorAndNotify (webpack-internal:///(rsc)/../../packages/use-intl/dist/development/createFormatter-DbsypjTl.js:170:23)
    at translateBaseFn (webpack-internal:///(rsc)/../../packages/use-intl/dist/development/createFormatter-DbsypjTl.js:236:20)
    at translateFn (webpack-internal:///(rsc)/../../packages/use-intl/dist/development/createFormatter-DbsypjTl.js:258:24)

So i try to fixed it, many repositories have these naming schemes, it very distressed when i using dynamic values template

Copy link

vercel bot commented Oct 14, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
next-intl-example-app-router ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 14, 2024 3:33am
next-intl-example-app-router-without-i18n-routing ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 14, 2024 3:33am

Copy link

vercel bot commented Oct 14, 2024

@apades is attempting to deploy a commit to the next-intl Team on Vercel.

A member of the Team first needs to authorize it.

@amannn
Copy link
Owner

amannn commented Oct 14, 2024

Thanks for considering a PR! However, next-intl aligns with the Intl.Locale API which doesn't intend to support these alternative variants.

If your use case is showing these variants on the pathname, you can consider using custom prefixes.

Hope that helps!

@apades
Copy link
Author

apades commented Oct 14, 2024

custom prefixes didn't resolve my problem, but I get your point. Maybe you can alert some Intl.Locale error about some alternative variants, it will decrease some confusion about “It's working, but why I can not use dynamic tempalte”, I have seen this related on reddit and stackoverflow😂

@amannn
Copy link
Owner

amannn commented Oct 14, 2024

Oh you mean that we could include a warning if an invalid locale is received? That could be a good idea, yes—I made a note about it in #779. Thanks for raising this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants