mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-01-12 05:28:51 +01:00
* fix: Missing Translations in Prompt Filters in Prompt Library * fix: fixed issue with `zh` feat: added `Estonian` language option * fix: test for `i18n.ts` * refactor: `pt` --> `pt-BR` and `pt-PT` * feat: request access to another language. default is only one language during invite.
21 lines
No EOL
627 B
TypeScript
21 lines
No EOL
627 B
TypeScript
import { useEffect } from 'react';
|
|
import { TOptions } from 'i18next';
|
|
import { useRecoilValue } from 'recoil';
|
|
import { useTranslation } from 'react-i18next';
|
|
import { resources } from '~/locales/i18n';
|
|
import store from '~/store';
|
|
|
|
export type TranslationKeys = keyof typeof resources.en.translation;
|
|
|
|
export default function useLocalize() {
|
|
const lang = useRecoilValue(store.lang);
|
|
const { t, i18n } = useTranslation();
|
|
|
|
useEffect(() => {
|
|
if (i18n.language !== lang) {
|
|
i18n.changeLanguage(lang);
|
|
}
|
|
}, [lang, i18n]);
|
|
|
|
return (phraseKey: TranslationKeys, options?: TOptions) => t(phraseKey, options);
|
|
} |