mirror of
https://github.com/vercel/commerce.git
synced 2025-05-15 14:06:59 +00:00
Played around with language options
This commit is contained in:
parent
cd2d9d26cf
commit
861de650f5
@ -1,5 +1,3 @@
|
|||||||
'use client'
|
|
||||||
|
|
||||||
import FlagEn from 'components/icons/flag-en';
|
import FlagEn from 'components/icons/flag-en';
|
||||||
import FlagSv from 'components/icons/flag-sv';
|
import FlagSv from 'components/icons/flag-sv';
|
||||||
import {
|
import {
|
||||||
@ -20,6 +18,7 @@ export default function LocaleSwitcher() {
|
|||||||
const [isOpen, setIsOpen] = useState(false)
|
const [isOpen, setIsOpen] = useState(false)
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
|
// Handle redirected pathname.
|
||||||
const redirectedPathName = (locale: string) => {
|
const redirectedPathName = (locale: string) => {
|
||||||
if (!pathName) return '/'
|
if (!pathName) return '/'
|
||||||
const segments = pathName.split('/')
|
const segments = pathName.split('/')
|
||||||
@ -27,6 +26,7 @@ export default function LocaleSwitcher() {
|
|||||||
return segments.join('/')
|
return segments.join('/')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Handle click on dropdown menu item (<li>).
|
||||||
const handleClick = (e: any, locale: string) => {
|
const handleClick = (e: any, locale: string) => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
|
|
||||||
|
@ -2,13 +2,10 @@ import createMiddleware from 'next-intl/middleware';
|
|||||||
|
|
||||||
export default createMiddleware({
|
export default createMiddleware({
|
||||||
// A list of all locales that are supported
|
// A list of all locales that are supported
|
||||||
locales: ['sv', 'en', 'nn'],
|
locales: ['sv', 'en'],
|
||||||
|
|
||||||
// If this locale is matched, pathnames work without a prefix (e.g. `/about`)
|
// If this locale is matched, pathnames work without a prefix (e.g. `/about`)
|
||||||
defaultLocale: 'sv',
|
defaultLocale: 'sv',
|
||||||
|
|
||||||
// Don't automatically detect locale, sv is default.
|
|
||||||
localeDetection: false
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export const config = {
|
export const config = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user