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 some issues on examples/app-dir-i18n-routing #51576

Merged
merged 3 commits into from
Jun 24, 2023
Merged

Conversation

cxa
Copy link
Contributor

@cxa cxa commented Jun 20, 2023

No description provided.

@vercel-spaces vercel-spaces bot requested a review from steven-tey June 20, 2023 16:28
@ijjk ijjk added the examples Issue/PR related to examples label Jun 20, 2023
@vercel-spaces
Copy link

vercel-spaces bot commented Jun 20, 2023

Notifying the following users due to files changed in this PR:

@timneutkens, @ijjk, @shuding, @huozhi, @feedthejim:

examples/app-dir-i18n-routing/middleware.ts

This comment was posted based on the notify modifier.

@kodiakhq kodiakhq bot merged commit fa519f6 into vercel:canary Jun 24, 2023
32 checks passed
@milovangudelj
Copy link
Contributor

Was the error catching really necessary?

I was having issues with that code cause Negotiator was returning an asterisk (['*']) from the Negotiator.languages() call, but I solved it by passing it i18n.locales as a parameter like so:

// @ts-ignore locales are readonly
const locales: string[] = i18n.locales;

// Use negotiator and intl-localematcher to get best locale
let languages = new Negotiator({ headers: negotiatorHeaders }).languages(
  locales
);

After this everything went back to working as expected. I mentioned this in #51712.

@cxa
Copy link
Contributor Author

cxa commented Jun 25, 2023

I don't realize that Negotiator can accept available locales before you mention it. Your method seems more elegant than catching error, just make a PR!

@milovangudelj
Copy link
Contributor

Thanks! Will do 😁

@milovangudelj
Copy link
Contributor

Opened #51786

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
examples Issue/PR related to examples locked
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants