feat(localization): enhance toast messages for better user feedback and localization support

This commit is contained in:
Will Miao
2025-08-31 11:51:28 +08:00
parent a258a18fa4
commit be8edafed0
9 changed files with 268 additions and 50 deletions

View File

@@ -283,12 +283,12 @@ export class BulkManager {
async copyAllModelsSyntax() {
if (state.currentPageType !== MODEL_TYPES.LORA) {
showToast('Copy syntax is only available for LoRAs', 'warning');
showToast('toast.loras.copyOnlyForLoras', {}, 'warning');
return;
}
if (state.selectedModels.size === 0) {
showToast('No LoRAs selected', 'warning');
showToast('toast.loras.noLorasSelected', {}, 'warning');
return;
}
@@ -310,11 +310,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 copy', 'error');
showToast('toast.loras.noValidLorasToCopy', {}, 'error');
return;
}
@@ -323,12 +323,12 @@ export class BulkManager {
async sendAllModelsToWorkflow() {
if (state.currentPageType !== MODEL_TYPES.LORA) {
showToast('Send to workflow is only available for LoRAs', 'warning');
showToast('toast.loras.sendOnlyForLoras', {}, 'warning');
return;
}
if (state.selectedModels.size === 0) {
showToast('No LoRAs selected', 'warning');
showToast('toast.loras.noLorasSelected', {}, 'warning');
return;
}

View File

@@ -1,4 +1,4 @@
import { updatePanelPositions } from "../utils/uiHelpers.js";
import { updatePanelPositions, showToast } from "../utils/uiHelpers.js";
import { getCurrentPageState } from "../state/index.js";
import { getModelApiClient } from "../api/modelApiFactory.js";
import { setStorageItem, getStorageItem } from "../utils/storageHelpers.js";
@@ -97,10 +97,7 @@ export class SearchManager {
// Check if clicking would deselect the last active option
const activeOptions = document.querySelectorAll('.search-option-tag.active');
if (activeOptions.length === 1 && activeOptions[0] === tag) {
// Don't allow deselecting the last option
if (typeof showToast === 'function') {
showToast('At least one search option must be selected', 'info');
}
showToast('toast.search.atLeastOneOption', {}, 'info');
return;
}