演示目录只保留可重建的源码。运行密钥、数据卷、依赖和带口令的本地配置不进入仓库。 Co-authored-by: Cursor <cursoragent@cursor.com>
17 lines
500 B
TypeScript
17 lines
500 B
TypeScript
import type { Namespace } from './resources'
|
|
import { use } from 'react'
|
|
import { getLocaleOnServer, getTranslation } from './server'
|
|
|
|
async function getI18nConfig<const T extends readonly [Namespace, ...Namespace[]]>(ns: T) {
|
|
const lang = await getLocaleOnServer()
|
|
return getTranslation(lang, ns)
|
|
}
|
|
|
|
export function useTranslation<const T extends readonly [Namespace, ...Namespace[]]>(ns: T) {
|
|
return use(getI18nConfig(ns))
|
|
}
|
|
|
|
export function useLocale() {
|
|
return use(getLocaleOnServer())
|
|
}
|