-
-
Notifications
You must be signed in to change notification settings - Fork 257
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
[Docs]: App Router setup with i18n routing #1670
Comments
any feedback on how this should be set would be appreciated ! |
With |
Thank you so much for replying.
Hafez
…________________________________
From: Jan Amann ***@***.***>
Sent: Tuesday, January 21, 2025 12:33:28 PM
To: amannn/next-intl ***@***.***>
Cc: Mohamed Hafez ***@***.***>; Author ***@***.***>
Subject: Re: [amannn/next-intl] [Docs]: App Router setup with i18n routing (Issue #1670)
With hasLocale<https://next-intl.dev/blog/next-intl-4-0#strictly-typed-locale> that is currently proposed in ***@***.*** beta, you can avoid the any.
—
Reply to this email directly, view it on GitHub<#1670 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ATNYY7VAX7EHPAJKMQAXQ4L2L2AGRAVCNFSM6AAAAABVSTVZAOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMMBVGM2TCMZZGQ>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Here is how I define Locale type, you can just use it wherever routing.ts import { defineRouting } from "next-intl/routing"
import { createNavigation } from "next-intl/navigation"
import { isExport } from "@/lib/utils"
export const routing = defineRouting({
// A list of all locales that are supported
locales: ["en", "de"],
// Used when no locale matches
defaultLocale: "en",
localePrefix: isExport ? "always" : "as-needed",
localeCookie: false
})
// Lightweight wrappers around Next.js' navigation APIs
// that will consider the routing configuration
export const { Link, redirect, usePathname, useRouter, getPathname } =
createNavigation(routing)
export type Locale = (typeof routing.locales)[number] |
Thank you so so much both for your feedback. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
locale defined as any here is problematic and goes against typescript safety - we should not be using type any here with locale. it should be as const.
The text was updated successfully, but these errors were encountered: