import { TranslationOptions, TranslationResult } from "./useTranslation.type"; /** * Hook to manage translations in a React application using @formatjs/intl * * Can be used in two ways: * 1. With options (standalone mode): Provides translations directly * 2. Without options (context mode): Uses TranslationProvider context * * @param options - Optional configuration options for translations. If not provided, will use TranslationProvider context. * @param options.locale - The locale to use (required in standalone mode). Changing it switches the active language, so a consumer can drive the language from the outside. A language set through `setLocale` is kept while this prop stays the same, so passing a literal keeps `setLocale` in charge * @param options.translations - An object containing all translations for all locales (required in standalone mode). It is read on every render, so a locale added after mount becomes available to `setLocale`. Keep it in state or memoize it: a new object on every render re-flattens every locale and rebuilds the `intl` instance * @param options.fallbackLocale - Optional fallback locale if a translation is not found * * @returns An object with translation utilities including the full IntlShape instance * * @example * Standalone mode: * ```tsx * const translations = { * en: { * "greeting": "Hello, {name}!", * "welcome": "Welcome to our app" * }, * es: { * "greeting": "Hola, {name}!", * "welcome": "Bienvenido a nuestra aplicación" * } * } * * function MyComponent() { * const { t, intl, locale, setLocale } = useTranslation({ * locale: 'en', * translations * }) * * return ( *
*

{t('greeting', { name: 'John' })}

*

{intl.formatNumber(1000)}

*

{intl.formatDate(new Date())}

* *
* ) * } * ``` * * @example * Context mode: * ```tsx * function App() { * return ( * * * * ) * } * * function MyComponent() { * const { t, locale, setLocale } = useTranslation() * * return ( *
*

{t('greeting')}

* *
* ) * } * ``` */ declare const useTranslation: (options?: Partial>) => TranslationResult; export { useTranslation };