Download client/src/hooks/useLocalize.ts from Zhitomir/chat: direct link, hf CLI and curl.
- Browser
- Download file 478 Bytes
-
https://huggingface.co/spaces/Zhitomir/chat/resolve/main/client/src/hooks/useLocalize.ts
- Command line
-
hf download hf://spaces/Zhitomir/chat/client/src/hooks/useLocalize.ts
-
curl -L -o useLocalize.ts https://huggingface.co/spaces/Zhitomir/chat/resolve/main/client/src/hooks/useLocalize.ts
478 Bytes
| import { useCallback } from 'react'; | |
| import { useRecoilValue } from 'recoil'; | |
| import { localize } from '~/localization/Translation'; | |
| import store from '~/store'; | |
| export default function useLocalize() { | |
| const lang = useRecoilValue(store.lang); | |
| const memoizedLocalize = useCallback( | |
| (phraseKey: string, ...values: string[]) => localize(lang, phraseKey, ...(values ?? [])), | |
| [lang], // Only recreate the function when `lang` changes | |
| ); | |
| return memoizedLocalize; | |
| } | |