mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
18 lines
403 B
TypeScript
18 lines
403 B
TypeScript
import React from 'react';
|
|
import { useTranslation } from 'react-i18next';
|
|
|
|
export default function useUpdateTranslations(fn: () => void) {
|
|
const { i18n } = useTranslation();
|
|
const currentLang = localStorage.getItem('i18nextLng');
|
|
|
|
React.useEffect(() => {
|
|
fn();
|
|
}, [fn]);
|
|
|
|
React.useEffect(() => {
|
|
i18n.on('languageChanged', () => {
|
|
fn();
|
|
});
|
|
}, [fn, i18n, currentLang]);
|
|
}
|