From b8ef1e3e91010606d08c9cc51b24920bcc7dec8d Mon Sep 17 00:00:00 2001 From: yznahmad Date: Sat, 21 Jun 2025 03:21:04 +0300 Subject: [PATCH] Add scheduleregdww5sudfw lside ddd n --- webapp/src/utils/i18nFallback.ts | 34 +++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/webapp/src/utils/i18nFallback.ts b/webapp/src/utils/i18nFallback.ts index 139b477..2462b53 100644 --- a/webapp/src/utils/i18nFallback.ts +++ b/webapp/src/utils/i18nFallback.ts @@ -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), + }; + } } \ No newline at end of file