mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-11-12 21:44:22 +08:00
21 lines
765 B
TypeScript
21 lines
765 B
TypeScript
'use client';
|
|
|
|
import type { useTranslations } from 'next-intl';
|
|
import { resolveClientLocale } from './client';
|
|
import { getRuntimeTranslator, type RuntimeKey } from './runtime-translators';
|
|
|
|
export { getRuntimeTranslator } from './runtime-translators';
|
|
|
|
export type RuntimeTranslator = ReturnType<typeof useTranslations>;
|
|
|
|
// Imperative browser code (network errors, form utilities) has no React hook
|
|
// context. Resolve the current preference when creating a message, not at import.
|
|
export const runtimeText = Object.assign(
|
|
(key: RuntimeKey, values?: Record<string, string | number>) =>
|
|
getRuntimeTranslator(resolveClientLocale())(key, values),
|
|
{
|
|
raw: (key: RuntimeKey): string =>
|
|
getRuntimeTranslator(resolveClientLocale()).raw(key),
|
|
},
|
|
);
|