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: Incorrect locale information provided Error if accept-language is invalid #192

Merged
merged 4 commits into from
Feb 17, 2023

Conversation

CptCompiler
Copy link
Contributor

Any errors thrown by Intl.getCanonicalLocales should be catched and the default language should be returned.
I noticed this because cypress was setting the accept-language header to *.

@vercel
Copy link

vercel bot commented Feb 17, 2023

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

Name Status Preview Comments Updated
next-intl ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Feb 17, 2023 at 5:01PM (UTC)

@CptCompiler CptCompiler changed the title fix: Incorrect locale information provided Error if accept-language is * fix: Incorrect locale information provided Error if accept-language is invalid Feb 17, 2023
Copy link
Owner

@amannn amannn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super cool, thanks a lot @CptCompiler!

The linter reports an error, would you mind fixing it?

try {
locale = match(languages, i18n.locales, i18n.defaultLocale);
} catch (e) {
// Invalid language
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the hassle with the linter, this looks good!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No worries. Thank you for this library!

@amannn amannn merged commit 9b564f9 into amannn:feat/next-13-rsc Feb 17, 2023
@amannn
Copy link
Owner

amannn commented Feb 17, 2023

Out in next-intl@2.11.0-beta.12, thanks again!

@CptCompiler CptCompiler deleted the patch-1 branch February 17, 2023 21:28
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