Add scheduleregdww5sudfw lside ddd n
This commit is contained in:
parent
6706c6ca7e
commit
b8ef1e3e91
@ -3,9 +3,14 @@
|
|||||||
*/
|
*/
|
||||||
export function safeTranslation(t: any, key: string, fallback: string = '') {
|
export function safeTranslation(t: any, key: string, fallback: string = '') {
|
||||||
try {
|
try {
|
||||||
|
if (!t || typeof t !== 'function') {
|
||||||
|
console.warn(`Translation function not available for key "${key}"`);
|
||||||
|
return fallback;
|
||||||
|
}
|
||||||
|
|
||||||
const translation = t(key);
|
const translation = t(key);
|
||||||
// If the translation returns the key itself or contains "MISSING", use fallback
|
// 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 fallback;
|
||||||
}
|
}
|
||||||
return translation;
|
return translation;
|
||||||
@ -13,4 +18,31 @@ export function safeTranslation(t: any, key: string, fallback: string = '') {
|
|||||||
console.warn(`Translation error for key "${key}":`, error);
|
console.warn(`Translation error for key "${key}":`, error);
|
||||||
return fallback;
|
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),
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user