pnpx create-next-app@latest .
pnpx shadcn@latest init
pnpm add negotiator @formatjs/intl-localematcher
pnpm add -d @types/negotiator
touch src/middleware.ts
Created
January 27, 2025 14:33
-
-
Save mo9a7i/8dddc8917c836448afaff582004c2dc8 to your computer and use it in GitHub Desktop.
create nextjs + shadcn in current directory
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
import { match } from '@formatjs/intl-localematcher' | |
import Negotiator from 'negotiator' | |
let headers = { 'accept-language': 'en-US,en;q=0.5' } | |
let languages = new Negotiator({ headers }).languages() | |
let locales = ['en-US', 'ar-SA'] | |
let defaultLocale = 'en-US' | |
match(languages, locales, defaultLocale) // -> 'en-US' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment