refactor: complete JS i18n migration for confirm dialogs and toast messages
Migrate 34 hardcoded user-facing strings to use I18n.t() for translation: - CMS: media file operations (5 strings) - Marketplace: Letzshop integration (16 strings) - Messaging: notifications, messages, email templates (5 strings) - Tenancy: platform modules, menu config, theme (5 strings) - Core: menu config, settings, storefront cart (5 strings) - Catalog: product creation (3 strings) - Utils: clipboard operations (2 strings) Added confirmations and messages keys to module locale files. Added I18n.loadModule() calls to JS files that were missing them. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -71,6 +71,9 @@ function adminNotifications() {
|
||||
* Initialize component
|
||||
*/
|
||||
async init() {
|
||||
// Load i18n translations
|
||||
await I18n.loadModule('messaging');
|
||||
|
||||
// Guard against multiple initialization
|
||||
if (window._adminNotificationsInitialized) return;
|
||||
window._adminNotificationsInitialized = true;
|
||||
@@ -114,7 +117,7 @@ function adminNotifications() {
|
||||
notificationsLog.debug(`Loaded ${this.notifications.length} notifications`);
|
||||
} catch (error) {
|
||||
notificationsLog.error('Failed to load notifications:', error);
|
||||
Utils.showToast('Failed to load notifications', 'error');
|
||||
Utils.showToast(I18n.t('messaging.messages.failed_to_load_notifications'), 'error');
|
||||
} finally {
|
||||
this.loadingNotifications = false;
|
||||
}
|
||||
@@ -131,10 +134,10 @@ function adminNotifications() {
|
||||
notification.is_read = true;
|
||||
this.stats.unread_count = Math.max(0, this.stats.unread_count - 1);
|
||||
|
||||
Utils.showToast('Notification marked as read', 'success');
|
||||
Utils.showToast(I18n.t('messaging.messages.notification_marked_as_read'), 'success');
|
||||
} catch (error) {
|
||||
notificationsLog.error('Failed to mark as read:', error);
|
||||
Utils.showToast('Failed to mark notification as read', 'error');
|
||||
Utils.showToast(I18n.t('messaging.messages.failed_to_mark_notification_as_read'), 'error');
|
||||
}
|
||||
},
|
||||
|
||||
@@ -149,10 +152,10 @@ function adminNotifications() {
|
||||
this.notifications.forEach(n => n.is_read = true);
|
||||
this.stats.unread_count = 0;
|
||||
|
||||
Utils.showToast('All notifications marked as read', 'success');
|
||||
Utils.showToast(I18n.t('messaging.messages.all_notifications_marked_as_read'), 'success');
|
||||
} catch (error) {
|
||||
notificationsLog.error('Failed to mark all as read:', error);
|
||||
Utils.showToast('Failed to mark all as read', 'error');
|
||||
Utils.showToast(I18n.t('messaging.messages.failed_to_mark_all_as_read'), 'error');
|
||||
}
|
||||
},
|
||||
|
||||
@@ -160,7 +163,7 @@ function adminNotifications() {
|
||||
* Delete notification
|
||||
*/
|
||||
async deleteNotification(notificationId) {
|
||||
if (!confirm('Are you sure you want to delete this notification?')) {
|
||||
if (!confirm(I18n.t('messaging.confirmations.delete_notification'))) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -175,10 +178,10 @@ function adminNotifications() {
|
||||
this.stats.unread_count = Math.max(0, this.stats.unread_count - 1);
|
||||
}
|
||||
|
||||
Utils.showToast('Notification deleted', 'success');
|
||||
Utils.showToast(I18n.t('messaging.messages.notification_deleted'), 'success');
|
||||
} catch (error) {
|
||||
notificationsLog.error('Failed to delete notification:', error);
|
||||
Utils.showToast('Failed to delete notification', 'error');
|
||||
Utils.showToast(I18n.t('messaging.messages.failed_to_delete_notification'), 'error');
|
||||
}
|
||||
},
|
||||
|
||||
@@ -225,7 +228,7 @@ function adminNotifications() {
|
||||
notificationsLog.debug(`Loaded ${this.alerts.length} alerts`);
|
||||
} catch (error) {
|
||||
notificationsLog.error('Failed to load alerts:', error);
|
||||
Utils.showToast('Failed to load alerts', 'error');
|
||||
Utils.showToast(I18n.t('messaging.messages.failed_to_load_alerts'), 'error');
|
||||
} finally {
|
||||
this.loadingAlerts = false;
|
||||
}
|
||||
@@ -272,10 +275,10 @@ function adminNotifications() {
|
||||
}
|
||||
this.alertStats.resolved_today++;
|
||||
|
||||
Utils.showToast('Alert resolved successfully', 'success');
|
||||
Utils.showToast(I18n.t('messaging.messages.alert_resolved_successfully'), 'success');
|
||||
} catch (error) {
|
||||
notificationsLog.error('Failed to resolve alert:', error);
|
||||
Utils.showToast('Failed to resolve alert', 'error');
|
||||
Utils.showToast(I18n.t('messaging.messages.failed_to_resolve_alert'), 'error');
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user