15 lines
620 B
TypeScript
15 lines
620 B
TypeScript
import type { TranslationKeys } from 'i18n';
|
|
import type { InterpolationParams } from 'i18n';
|
|
import { useTranslation as useTranslationBase } from 'i18n';
|
|
import type en from '../locales/en-GB.json';
|
|
|
|
type AppTranslationKey = TranslationKeys<typeof en>;
|
|
|
|
// The `app.` prefix is namespace wiring for the merged catalog (D6) — callers never spell it, they
|
|
// pass the same bare key the JSON file uses.
|
|
export const useTranslation = () => {
|
|
const { t: baseT, locale } = useTranslationBase();
|
|
const t = (key: AppTranslationKey, params?: InterpolationParams) => baseT(`app.${key}`, params);
|
|
return { t, locale };
|
|
};
|