frontAnswerer/src/components/SafeTranslationProvider.tsx
Nastya 56ccd1dacb
Some checks failed
Deploy / CreateImage (push) Failing after 3m22s
Deploy / DeployService (push) Failing after 23s
добавление переводов в зависимости юзеров
2025-07-01 02:47:45 +03:00

27 lines
658 B
TypeScript

import React from "react";
import { useTranslation } from "react-i18next";
interface SafeTranslationProviderProps {
children: React.ReactNode;
}
export const SafeTranslationProvider: React.FC<SafeTranslationProviderProps> = ({ children }) => {
return <>{children}</>;
};
// Хук для безопасного использования переводов
export const useSafeTranslation = () => {
const { t } = useTranslation();
const safeT = (key: string, options?: any) => {
try {
return t(key, options);
} catch (error) {
console.warn("Translation error:", error);
return key;
}
};
return { t: safeT };
};