feat(localization): enhance toast messages for recipes and example images with improved error handling and success feedback

This commit is contained in:
Will Miao
2025-08-31 13:51:37 +08:00
parent e60a579b85
commit 987b8c8742
11 changed files with 134 additions and 65 deletions

View File

@@ -142,7 +142,7 @@ class ExampleImagesManager {
if (!data.success) {
console.error('Failed to update example images path in backend:', data.error);
} else {
showToast('Example images path updated successfully', 'success');
showToast('toast.exampleImages.pathUpdated', {}, 'success');
}
} catch (error) {
console.error('Failed to update example images path:', error);
@@ -187,7 +187,7 @@ class ExampleImagesManager {
this.startDownload();
} else {
// If download is in progress, show info toast
showToast('Download already in progress', 'info');
showToast('toast.exampleImages.downloadInProgress', {}, 'info');
}
}
@@ -243,7 +243,7 @@ class ExampleImagesManager {
async startDownload() {
if (this.isDownloading) {
showToast('Download already in progress', 'warning');
showToast('toast.exampleImages.downloadInProgress', {}, 'warning');
return;
}
@@ -251,7 +251,7 @@ class ExampleImagesManager {
const outputDir = document.getElementById('exampleImagesPath').value || '';
if (!outputDir) {
showToast('Please enter a download location first', 'warning');
showToast('toast.exampleImages.enterLocationFirst', {}, 'warning');
return;
}
@@ -280,7 +280,7 @@ class ExampleImagesManager {
this.showProgressPanel();
this.startProgressUpdates();
this.updateDownloadButtonText();
showToast('Example images download started', 'success');
showToast('toast.exampleImages.downloadStarted', {}, 'success');
// Close settings modal
modalManager.closeModal('settingsModal');
@@ -289,7 +289,7 @@ class ExampleImagesManager {
}
} catch (error) {
console.error('Failed to start download:', error);
showToast('Failed to start download', 'error');
showToast('toast.exampleImages.downloadStartFailed', {}, 'error');
}
}
@@ -319,13 +319,13 @@ class ExampleImagesManager {
}
this.updateDownloadButtonText();
showToast('Download paused', 'info');
showToast('toast.exampleImages.downloadPaused', {}, 'info');
} else {
showToast(data.error || 'Failed to pause download', 'error');
}
} catch (error) {
console.error('Failed to pause download:', error);
showToast('Failed to pause download', 'error');
showToast('toast.exampleImages.pauseFailed', {}, 'error');
}
}
@@ -355,13 +355,13 @@ class ExampleImagesManager {
}
this.updateDownloadButtonText();
showToast('Download resumed', 'success');
showToast('toast.exampleImages.downloadResumed', {}, 'success');
} else {
showToast(data.error || 'Failed to resume download', 'error');
}
} catch (error) {
console.error('Failed to resume download:', error);
showToast('Failed to resume download', 'error');
showToast('toast.exampleImages.resumeFailed', {}, 'error');
}
}