feat(web-i18n): add es/fr locales and expand switcher locale set
This commit is contained in:
5
apps/web/src/i18n/navigation.ts
Normal file
5
apps/web/src/i18n/navigation.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
import { createNavigation } from "next-intl/navigation"
|
||||
|
||||
import { routing } from "./routing"
|
||||
|
||||
export const { Link, redirect, usePathname, useRouter, getPathname } = createNavigation(routing)
|
||||
14
apps/web/src/i18n/request.ts
Normal file
14
apps/web/src/i18n/request.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { hasLocale } from "next-intl"
|
||||
import { getRequestConfig } from "next-intl/server"
|
||||
|
||||
import { routing } from "./routing"
|
||||
|
||||
export default getRequestConfig(async ({ requestLocale }) => {
|
||||
const requested = await requestLocale
|
||||
const locale = hasLocale(routing.locales, requested) ? requested : routing.defaultLocale
|
||||
|
||||
return {
|
||||
locale,
|
||||
messages: (await import(`../messages/${locale}.json`)).default,
|
||||
}
|
||||
})
|
||||
8
apps/web/src/i18n/routing.ts
Normal file
8
apps/web/src/i18n/routing.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { defaultLocale, locales } from "@cms/i18n"
|
||||
import { defineRouting } from "next-intl/routing"
|
||||
|
||||
export const routing = defineRouting({
|
||||
locales: [...locales],
|
||||
defaultLocale,
|
||||
localePrefix: "never",
|
||||
})
|
||||
Reference in New Issue
Block a user