mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-24 22:52:12 -03:00
feat(localization): enhance toast messages for API actions and model management with i18n support
refactor(localization): update toast messages in various components and managers for better user feedback
This commit is contained in:
@@ -350,11 +350,11 @@ export class BulkManager {
|
||||
|
||||
if (missingLoras.length > 0) {
|
||||
console.warn('Missing metadata for some selected loras:', missingLoras);
|
||||
showToast(`Missing data for ${missingLoras.length} LoRAs`, 'warning');
|
||||
showToast('toast.loras.missingDataForLoras', { count: missingLoras.length }, 'warning');
|
||||
}
|
||||
|
||||
if (loraSyntaxes.length === 0) {
|
||||
showToast('No valid LoRAs to send', 'error');
|
||||
showToast('toast.loras.noValidLorasToSend', {}, 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -363,7 +363,7 @@ export class BulkManager {
|
||||
|
||||
showBulkDeleteModal() {
|
||||
if (state.selectedModels.size === 0) {
|
||||
showToast('No models selected', 'warning');
|
||||
showToast('toast.models.noModelsSelected', {}, 'warning');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -377,7 +377,7 @@ export class BulkManager {
|
||||
|
||||
async confirmBulkDelete() {
|
||||
if (state.selectedModels.size === 0) {
|
||||
showToast('No models selected', 'warning');
|
||||
showToast('toast.models.noModelsSelected', {}, 'warning');
|
||||
modalManager.closeModal('bulkDeleteModal');
|
||||
return;
|
||||
}
|
||||
@@ -392,7 +392,10 @@ export class BulkManager {
|
||||
|
||||
if (result.success) {
|
||||
const currentConfig = MODEL_CONFIG[state.currentPageType];
|
||||
showToast(`Successfully deleted ${result.deleted_count} ${currentConfig.displayName.toLowerCase()}(s)`, 'success');
|
||||
showToast('toast.models.deletedSuccessfully', {
|
||||
count: result.deleted_count,
|
||||
type: currentConfig.displayName.toLowerCase()
|
||||
}, 'success');
|
||||
|
||||
filePaths.forEach(path => {
|
||||
state.virtualScroller.removeItemByFilePath(path);
|
||||
@@ -403,11 +406,11 @@ export class BulkManager {
|
||||
window.modelDuplicatesManager.updateDuplicatesBadgeAfterRefresh();
|
||||
}
|
||||
} else {
|
||||
showToast(`Error: ${result.error || 'Failed to delete models'}`, 'error');
|
||||
showToast('toast.models.deleteFailed', { error: result.error || 'Failed to delete models' }, 'error');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error during bulk delete:', error);
|
||||
showToast('Failed to delete models', 'error');
|
||||
showToast('toast.models.deleteFailedGeneral', {}, 'error');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -538,7 +541,7 @@ export class BulkManager {
|
||||
|
||||
selectAllVisibleModels() {
|
||||
if (!state.virtualScroller || !state.virtualScroller.items) {
|
||||
showToast('Unable to select all items', 'error');
|
||||
showToast('toast.bulk.unableToSelectAll', {}, 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -565,7 +568,10 @@ export class BulkManager {
|
||||
|
||||
const newlySelected = state.selectedModels.size - oldCount;
|
||||
const currentConfig = MODEL_CONFIG[state.currentPageType];
|
||||
showToast(`Selected ${newlySelected} additional ${currentConfig.displayName.toLowerCase()}(s)`, 'success');
|
||||
showToast('toast.models.selectedAdditional', {
|
||||
count: newlySelected,
|
||||
type: currentConfig.displayName.toLowerCase()
|
||||
}, 'success');
|
||||
|
||||
if (this.isStripVisible) {
|
||||
this.updateThumbnailStrip();
|
||||
@@ -574,7 +580,7 @@ export class BulkManager {
|
||||
|
||||
async refreshAllMetadata() {
|
||||
if (state.selectedModels.size === 0) {
|
||||
showToast('No models selected', 'warning');
|
||||
showToast('toast.models.noModelsSelected', {}, 'warning');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -610,7 +616,7 @@ export class BulkManager {
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error during bulk metadata refresh:', error);
|
||||
showToast('Failed to refresh metadata', 'error');
|
||||
showToast('toast.models.refreshMetadataFailed', {}, 'error');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -321,7 +321,7 @@ export class FilterManager {
|
||||
await getModelApiClient().loadMoreWithVirtualScroll(true, true);
|
||||
}
|
||||
|
||||
showToast(`Filters cleared`, 'info');
|
||||
showToast('toast.filters.cleared', {}, 'info');
|
||||
}
|
||||
|
||||
loadFiltersFromStorage() {
|
||||
|
||||
@@ -261,7 +261,7 @@ export class ImportManager {
|
||||
|
||||
this.updateTargetPath();
|
||||
} catch (error) {
|
||||
showToast(error.message, 'error');
|
||||
showToast('toast.import.importFailed', { message: error.message }, 'error');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -350,11 +350,11 @@ export class ImportManager {
|
||||
await this.folderTreeManager.loadTree(treeData.tree);
|
||||
} else {
|
||||
console.error('Failed to fetch folder tree:', treeData.error);
|
||||
showToast('Failed to load folder tree', 'error');
|
||||
showToast('toast.import.folderTreeFailed', {}, 'error');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error initializing folder tree:', error);
|
||||
showToast('Error loading folder tree', 'error');
|
||||
showToast('toast.import.folderTreeError', {}, 'error');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ class MoveManager {
|
||||
if (filePath === 'bulk') {
|
||||
const selectedPaths = Array.from(state.selectedModels);
|
||||
if (selectedPaths.length === 0) {
|
||||
showToast('No models selected', 'warning');
|
||||
showToast('toast.models.noModelsSelected', {}, 'warning');
|
||||
return;
|
||||
}
|
||||
this.bulkFilePaths = selectedPaths;
|
||||
@@ -116,7 +116,7 @@ class MoveManager {
|
||||
|
||||
} catch (error) {
|
||||
console.error(`Error fetching ${modelConfig.displayName.toLowerCase()} roots or folders:`, error);
|
||||
showToast(error.message, 'error');
|
||||
showToast('toast.models.moveFailed', { message: error.message }, 'error');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,11 +131,11 @@ class MoveManager {
|
||||
await this.folderTreeManager.loadTree(treeData.tree);
|
||||
} else {
|
||||
console.error('Failed to fetch folder tree:', treeData.error);
|
||||
showToast('Failed to load folder tree', 'error');
|
||||
showToast('toast.import.folderTreeFailed', {}, 'error');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error initializing folder tree:', error);
|
||||
showToast('Error loading folder tree', 'error');
|
||||
showToast('toast.import.folderTreeError', {}, 'error');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,7 +163,7 @@ class MoveManager {
|
||||
const config = apiClient.apiConfig.config;
|
||||
|
||||
if (!selectedRoot) {
|
||||
showToast(`Please select a ${config.displayName.toLowerCase()} root directory`, 'error');
|
||||
showToast('toast.models.pleaseSelectRoot', { type: config.displayName.toLowerCase() }, 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -236,7 +236,7 @@ class MoveManager {
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error moving model(s):', error);
|
||||
showToast('Failed to move model(s): ' + error.message, 'error');
|
||||
showToast('toast.models.moveFailed', { message: error.message }, 'error');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -314,7 +314,7 @@ export class SettingsManager {
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error loading LoRA roots:', error);
|
||||
showToast('Failed to load LoRA roots: ' + error.message, 'error');
|
||||
showToast('toast.settings.loraRootsFailed', { message: error.message }, 'error');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -353,7 +353,7 @@ export class SettingsManager {
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error loading checkpoint roots:', error);
|
||||
showToast('Failed to load checkpoint roots: ' + error.message, 'error');
|
||||
showToast('toast.settings.checkpointRootsFailed', { message: error.message }, 'error');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -392,7 +392,7 @@ export class SettingsManager {
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error loading embedding roots:', error);
|
||||
showToast('Failed to load embedding roots: ' + error.message, 'error');
|
||||
showToast('toast.settings.embeddingRootsFailed', { message: error.message }, 'error');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -560,14 +560,17 @@ export class SettingsManager {
|
||||
// Show success toast
|
||||
const mappingCount = Object.keys(state.global.settings.base_model_path_mappings).length;
|
||||
if (mappingCount > 0) {
|
||||
showToast(`Base model path mappings updated (${mappingCount} mapping${mappingCount !== 1 ? 's' : ''})`, 'success');
|
||||
showToast('toast.settings.mappingsUpdated', {
|
||||
count: mappingCount,
|
||||
plural: mappingCount !== 1 ? 's' : ''
|
||||
}, 'success');
|
||||
} else {
|
||||
showToast('Base model path mappings cleared', 'success');
|
||||
showToast('toast.settings.mappingsCleared', {}, 'success');
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error saving base model mappings:', error);
|
||||
showToast('Failed to save base model mappings: ' + error.message, 'error');
|
||||
showToast('toast.settings.mappingSaveFailed', { message: error.message }, 'error');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -744,11 +747,11 @@ export class SettingsManager {
|
||||
throw new Error('Failed to save download path templates');
|
||||
}
|
||||
|
||||
showToast('Download path templates updated', 'success');
|
||||
showToast('toast.settings.downloadTemplatesUpdated', {}, 'success');
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error saving download path templates:', error);
|
||||
showToast('Failed to save download path templates: ' + error.message, 'error');
|
||||
showToast('toast.settings.downloadTemplatesFailed', { message: error.message }, 'error');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -809,7 +812,7 @@ export class SettingsManager {
|
||||
}
|
||||
}
|
||||
|
||||
showToast(`Settings updated: ${settingKey.replace(/_/g, ' ')}`, 'success');
|
||||
showToast('toast.settings.settingsUpdated', { setting: settingKey.replace(/_/g, ' ') }, 'success');
|
||||
|
||||
// Apply frontend settings immediately
|
||||
this.applyFrontendSettings();
|
||||
@@ -830,11 +833,13 @@ export class SettingsManager {
|
||||
// Recalculate layout when compact mode changes
|
||||
if (settingKey === 'compact_mode' && state.virtualScroller) {
|
||||
state.virtualScroller.calculateLayout();
|
||||
showToast(`Compact Mode ${value ? 'enabled' : 'disabled'}`, 'success');
|
||||
showToast('toast.settings.compactModeToggled', {
|
||||
state: value ? 'toast.settings.compactModeEnabled' : 'toast.settings.compactModeDisabled'
|
||||
}, 'success');
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
showToast('Failed to save setting: ' + error.message, 'error');
|
||||
showToast('toast.settings.settingSaveFailed', { message: error.message }, 'error');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -888,7 +893,7 @@ export class SettingsManager {
|
||||
throw new Error('Failed to save setting');
|
||||
}
|
||||
|
||||
showToast(`Settings updated: ${settingKey.replace(/_/g, ' ')}`, 'success');
|
||||
showToast('toast.settings.settingsUpdated', { setting: settingKey.replace(/_/g, ' ') }, 'success');
|
||||
}
|
||||
|
||||
// Apply frontend settings immediately
|
||||
@@ -902,11 +907,11 @@ export class SettingsManager {
|
||||
if (value === 'medium') densityName = "Medium";
|
||||
if (value === 'compact') densityName = "Compact";
|
||||
|
||||
showToast(`Display Density set to ${densityName}`, 'success');
|
||||
showToast('toast.settings.displayDensitySet', { density: densityName }, 'success');
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
showToast('Failed to save setting: ' + error.message, 'error');
|
||||
showToast('toast.settings.settingSaveFailed', { message: error.message }, 'error');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -945,10 +950,10 @@ export class SettingsManager {
|
||||
throw new Error('Failed to save setting');
|
||||
}
|
||||
|
||||
showToast(`Settings updated: ${settingKey.replace(/_/g, ' ')}`, 'success');
|
||||
showToast('toast.settings.settingsUpdated', { setting: settingKey.replace(/_/g, ' ') }, 'success');
|
||||
|
||||
} catch (error) {
|
||||
showToast('Failed to save setting: ' + error.message, 'error');
|
||||
showToast('toast.settings.settingSaveFailed', { message: error.message }, 'error');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -984,7 +989,7 @@ export class SettingsManager {
|
||||
window.location.reload();
|
||||
|
||||
} catch (error) {
|
||||
showToast('Failed to change language: ' + error.message, 'error');
|
||||
showToast('toast.settings.languageChangeFailed', { message: error.message }, 'error');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1019,15 +1024,15 @@ export class SettingsManager {
|
||||
const result = await response.json();
|
||||
|
||||
if (result.success) {
|
||||
showToast('Cache files have been cleared successfully. Cache will rebuild on next action.', 'success');
|
||||
showToast('toast.settings.cacheCleared', {}, 'success');
|
||||
} else {
|
||||
showToast(`Failed to clear cache: ${result.error}`, 'error');
|
||||
showToast('toast.settings.cacheClearFailed', { error: result.error }, 'error');
|
||||
}
|
||||
|
||||
// Close the confirmation modal
|
||||
modalManager.closeModal('clearCacheModal');
|
||||
} catch (error) {
|
||||
showToast(`Error clearing cache: ${error.message}`, 'error');
|
||||
showToast('toast.settings.cacheClearError', { message: error.message }, 'error');
|
||||
modalManager.closeModal('clearCacheModal');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,7 +156,7 @@ export class ImageProcessor {
|
||||
|
||||
async uploadAndAnalyzeImage() {
|
||||
if (!this.importManager.recipeImage) {
|
||||
showToast('Please select an image first', 'error');
|
||||
showToast('toast.import.selectImageFirst', {}, 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -406,7 +406,7 @@ export class RecipeDataManager {
|
||||
proceedFromDetails() {
|
||||
// Validate recipe name
|
||||
if (!this.importManager.recipeName) {
|
||||
showToast('Please enter a recipe name', 'error');
|
||||
showToast('toast.import.enterRecipeName', {}, 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user