mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-22 05:32:12 -03:00
feat(localization): update toast messages for consistency and improved error handling across various components
This commit is contained in:
@@ -430,7 +430,7 @@ async function handleImportFiles(files, modelHash, importContainer) {
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error importing examples:', error);
|
||||
showToast('import.importFailed', { message: error.message }, 'error');
|
||||
showToast('toast.import.importFailed', { message: error.message }, 'error');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -418,7 +418,7 @@ export class DownloadManager {
|
||||
const config = this.apiClient.apiConfig.config;
|
||||
|
||||
if (!modelRoot) {
|
||||
showToast('models.pleaseSelectRoot', { type: config.displayName }, 'error');
|
||||
showToast('toast.models.pleaseSelectRoot', { type: config.displayName }, 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -285,7 +285,7 @@ class ExampleImagesManager {
|
||||
// Close settings modal
|
||||
modalManager.closeModal('settingsModal');
|
||||
} else {
|
||||
showToast('exampleImages.downloadStartFailed', { error: data.error }, 'error');
|
||||
showToast('toast.exampleImages.downloadStartFailed', { error: data.error }, 'error');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to start download:', error);
|
||||
@@ -321,7 +321,7 @@ class ExampleImagesManager {
|
||||
this.updateDownloadButtonText();
|
||||
showToast('toast.exampleImages.downloadPaused', {}, 'info');
|
||||
} else {
|
||||
showToast('exampleImages.pauseFailed', { error: data.error }, 'error');
|
||||
showToast('toast.exampleImages.pauseFailed', { error: data.error }, 'error');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to pause download:', error);
|
||||
@@ -357,7 +357,7 @@ class ExampleImagesManager {
|
||||
this.updateDownloadButtonText();
|
||||
showToast('toast.exampleImages.downloadResumed', {}, 'success');
|
||||
} else {
|
||||
showToast('exampleImages.resumeFailed', { error: data.error }, 'error');
|
||||
showToast('toast.exampleImages.resumeFailed', { error: data.error }, 'error');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to resume download:', error);
|
||||
|
||||
@@ -77,7 +77,7 @@ export class DownloadManager {
|
||||
if (!result.success) {
|
||||
// Handle save error
|
||||
console.error("Failed to save recipe:", result.error);
|
||||
showToast('import.recipeSaveFailed', { error: result.error }, 'error');
|
||||
showToast('toast.import.recipeSaveFailed', { error: result.error }, 'error');
|
||||
// Close modal
|
||||
modalManager.closeModal('importModal');
|
||||
return;
|
||||
@@ -107,7 +107,7 @@ export class DownloadManager {
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error:', error);
|
||||
showToast('import.processingError', { message: error.message }, 'error');
|
||||
showToast('toast.import.processingError', { message: error.message }, 'error');
|
||||
} finally {
|
||||
this.importManager.loadingManager.hide();
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ export class FolderBrowser {
|
||||
this.initializeFolderBrowser();
|
||||
} catch (error) {
|
||||
console.error('Error in API calls:', error);
|
||||
showToast('import.folderBrowserError', { message: error.message }, 'error');
|
||||
showToast('toast.import.folderBrowserError', { message: error.message }, 'error');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
import { i18n } from '../i18n/index.js';
|
||||
import { initializePageI18n, t, formatFileSize, formatDate, formatNumber } from '../utils/i18nHelpers.js';
|
||||
import { findUnusedTranslationKeys, findMissingTranslationKeys, extractLeafKeys } from '../i18n/validator.js';
|
||||
|
||||
// Mock DOM elements for testing
|
||||
function createMockDOM() {
|
||||
@@ -96,6 +97,35 @@ function testLanguageDetection() {
|
||||
console.log(`Browser language: ${navigator.language}`);
|
||||
}
|
||||
|
||||
// Test unused translations detection
|
||||
function testUnusedTranslationsDetection() {
|
||||
console.log('=== Testing Unused Translations Detection ===');
|
||||
|
||||
// Mock used keys
|
||||
const mockUsedKeys = [
|
||||
'common.actions.save',
|
||||
'common.actions.cancel',
|
||||
'header.appTitle'
|
||||
];
|
||||
|
||||
// Get all translations
|
||||
const allTranslations = i18n.getTranslations();
|
||||
|
||||
// Find unused keys (only considering leaf nodes)
|
||||
const unusedKeys = findUnusedTranslationKeys(allTranslations, mockUsedKeys);
|
||||
|
||||
console.log(`Found ${unusedKeys.length} unused translation keys`);
|
||||
console.log('First 5 unused keys:', unusedKeys.slice(0, 5));
|
||||
|
||||
// Find missing keys
|
||||
const missingKeys = findMissingTranslationKeys(allTranslations, [
|
||||
...mockUsedKeys,
|
||||
'non.existent.key'
|
||||
]);
|
||||
|
||||
console.log(`Found ${missingKeys.length} missing translation keys:`, missingKeys);
|
||||
}
|
||||
|
||||
// Run all tests
|
||||
function runTests() {
|
||||
console.log('Starting i18n System Tests...');
|
||||
@@ -110,6 +140,9 @@ function runTests() {
|
||||
testDOMTranslation();
|
||||
}
|
||||
|
||||
// Test unused translations detection
|
||||
testUnusedTranslationsDetection();
|
||||
|
||||
console.log('=====================================');
|
||||
console.log('i18n System Tests Completed!');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user