mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-11-18 22:14:27 +00:00
15 lines
515 B
TypeScript
15 lines
515 B
TypeScript
import { useCallback } from 'react';
|
|
import { TOptions } from 'i18next';
|
|
import { useTranslation } from 'react-i18next';
|
|
|
|
export type TranslationKeys = string;
|
|
|
|
/** Language lifecycle is managed by the host app — do not add i18n.changeLanguage() calls here. */
|
|
export default function useLocalize(): (phraseKey: TranslationKeys, options?: TOptions) => string {
|
|
const { t } = useTranslation();
|
|
|
|
return useCallback(
|
|
(phraseKey: TranslationKeys, options?: TOptions) => t(phraseKey, options),
|
|
[t],
|
|
);
|
|
}
|