Add scheduleregdww5sudfw lside ddd n

This commit is contained in:
yznahmad 2025-06-21 03:21:04 +03:00
parent 6706c6ca7e
commit b8ef1e3e91

View File

@ -3,9 +3,14 @@
*/
export function safeTranslation(t: any, key: string, fallback: string = '') {
try {
if (!t || typeof t !== 'function') {
console.warn(`Translation function not available for key "${key}"`);
return fallback;
}
const translation = t(key);
// If the translation returns the key itself or contains "MISSING", use fallback
if (translation === key || translation.includes('MISSING')) {
if (!translation || translation === key || translation.includes('MISSING')) {
return fallback;
}
return translation;
@ -13,4 +18,31 @@ export function safeTranslation(t: any, key: string, fallback: string = '') {
console.warn(`Translation error for key "${key}":`, error);
return fallback;
}
}
/**
* Utility function to check if the server is responding
* Can be used to detect server issues early
*/
export async function checkServerConnection() {
try {
const response = await fetch('/api/health', {
method: 'GET',
headers: {
'Cache-Control': 'no-cache',
},
});
return {
isConnected: response.ok,
status: response.status,
statusText: response.statusText,
};
} catch (error) {
console.error('Server connection check failed:', error);
return {
isConnected: false,
error: error instanceof Error ? error.message : String(error),
};
}
}