examples: improve typings for i18n app dir (#60160)
This commit is contained in:
parent
7818c2d736
commit
2d52962dfd
3 changed files with 6 additions and 8 deletions
|
@ -1,14 +1,12 @@
|
|||
'use client'
|
||||
|
||||
import { useState } from 'react'
|
||||
import { type getDictionary } from '../../../get-dictionary'
|
||||
|
||||
export default function Counter({
|
||||
dictionary,
|
||||
}: {
|
||||
dictionary: {
|
||||
increment: string
|
||||
decrement: string
|
||||
}
|
||||
dictionary: Awaited<ReturnType<typeof getDictionary>>['counter']
|
||||
}) {
|
||||
const [count, setCount] = useState(0)
|
||||
return (
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
|
||||
import { usePathname } from 'next/navigation'
|
||||
import Link from 'next/link'
|
||||
import { i18n } from '../../../i18n-config'
|
||||
import { i18n, type Locale } from '../../../i18n-config'
|
||||
|
||||
export default function LocaleSwitcher() {
|
||||
const pathName = usePathname()
|
||||
const redirectedPathName = (locale: string) => {
|
||||
const redirectedPathName = (locale: Locale) => {
|
||||
if (!pathName) return '/'
|
||||
const segments = pathName.split('/')
|
||||
segments[1] = locale
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { i18n } from '../../i18n-config'
|
||||
import { i18n, type Locale } from '../../i18n-config'
|
||||
|
||||
export async function generateStaticParams() {
|
||||
return i18n.locales.map((locale) => ({ lang: locale }))
|
||||
|
@ -9,7 +9,7 @@ export default function Root({
|
|||
params,
|
||||
}: {
|
||||
children: React.ReactNode
|
||||
params: { lang: string }
|
||||
params: { lang: Locale }
|
||||
}) {
|
||||
return (
|
||||
<html lang={params.lang}>
|
||||
|
|
Loading…
Reference in a new issue