react-intlayer
Version:
Easily internationalize i18n your React applications with type-safe multilingual content management.
25 lines (23 loc) • 1.23 kB
TypeScript
import { DeepTransformContent as DeepTransformContent$1 } from "../plugins.js";
import { ValidDotPathsFor } from "@intlayer/core";
import { DictionaryKeys, DictionaryRegistryContent, GetSubPath, LocalesValues } from "@intlayer/types";
//#region src/server/useI18n.d.ts
/**
* Hook that provides a translation function `t()` for accessing nested content by key.
* This hook mimics the pattern found in libraries like i18next, next-intl, and vue-i18n.
*
* @param namespace - The dictionary key to scope translations to
* @param locale - Optional locale override. If not provided, uses the current context locale
* @returns A translation function `t(key)` that returns the translated content for the given key
*
* @example
* ```tsx
* const t = useI18n('IndexPage');
* const title = t('title'); // Returns translated string for 'IndexPage.title'
* const nestedContent = t('section.subtitle'); // Returns 'IndexPage.section.subtitle'
* ```
*/
declare const useI18n: <T extends DictionaryKeys>(namespace: T, locale?: LocalesValues) => <P extends ValidDotPathsFor<T>>(path: P) => GetSubPath<DeepTransformContent$1<DictionaryRegistryContent<T>>, P>;
//#endregion
export { useI18n };
//# sourceMappingURL=useI18n.d.ts.map