Skip to content

Instantly share code, notes, and snippets.

@mo9a7i
Created January 27, 2025 14:33
Show Gist options
  • Save mo9a7i/8dddc8917c836448afaff582004c2dc8 to your computer and use it in GitHub Desktop.
Save mo9a7i/8dddc8917c836448afaff582004c2dc8 to your computer and use it in GitHub Desktop.
create nextjs + shadcn in current directory
pnpx create-next-app@latest .

pnpx shadcn@latest init

pnpm add negotiator @formatjs/intl-localematcher
pnpm add -d @types/negotiator

touch src/middleware.ts
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