1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2026-04-18 21:35:27 -04:00
Files
Sonarr/frontend/src/App/useTranslations.ts
T
2025-12-12 17:08:02 -08:00

29 lines
573 B
TypeScript

import { useEffect } from 'react';
import useApiQuery from 'Helpers/Hooks/useApiQuery';
import { setTranslations } from 'Utilities/String/translate';
interface TranslationsResponse {
strings: Record<string, string>;
}
export function useTranslations() {
const { data, ...result } = useApiQuery<TranslationsResponse>({
path: '/localization',
queryOptions: {
staleTime: Infinity,
gcTime: Infinity,
},
});
useEffect(() => {
if (data) {
setTranslations(data.strings);
}
}, [data]);
return {
...result,
data,
};
}