File size: 478 Bytes
aa2e6af | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | 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;
}
|