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:
2026-02-01 17:29:13 +01:00
parent 1d78085085
commit 09d7d282c6
24 changed files with 681 additions and 822 deletions

View File

@@ -67,6 +67,9 @@ function adminMessages(initialConversationId = null) {
* Initialize component
*/
async init() {
// Load i18n translations
await I18n.loadModule('messaging');
// Guard against multiple initialization
if (window._adminMessagesInitialized) return;
window._adminMessagesInitialized = true;
@@ -141,7 +144,7 @@ function adminMessages(initialConversationId = null) {
messagesLog.debug(`Loaded ${this.conversations.length} conversations`);
} catch (error) {
messagesLog.error('Failed to load conversations:', error);
Utils.showToast('Failed to load conversations', 'error');
Utils.showToast(I18n.t('messaging.messages.failed_to_load_conversations'), 'error');
} finally {
this.loadingConversations = false;
}
@@ -197,7 +200,7 @@ function adminMessages(initialConversationId = null) {
this.scrollToBottom();
} catch (error) {
messagesLog.error('Failed to load conversation:', error);
Utils.showToast('Failed to load conversation', 'error');
Utils.showToast(I18n.t('messaging.messages.failed_to_load_conversation'), 'error');
} finally {
this.loadingMessages = false;
}
@@ -301,7 +304,7 @@ function adminMessages(initialConversationId = null) {
* Close conversation
*/
async closeConversation() {
if (!confirm('Are you sure you want to close this conversation?')) return;
if (!confirm(I18n.t('messaging.confirmations.close_conversation_admin'))) return;
try {
await apiClient.post(`/admin/messages/${this.selectedConversationId}/close`);
@@ -316,10 +319,10 @@ function adminMessages(initialConversationId = null) {
conv.is_closed = true;
}
Utils.showToast('Conversation closed', 'success');
Utils.showToast(I18n.t('messaging.messages.conversation_closed'), 'success');
} catch (error) {
messagesLog.error('Failed to close conversation:', error);
Utils.showToast('Failed to close conversation', 'error');
Utils.showToast(I18n.t('messaging.messages.failed_to_close_conversation'), 'error');
}
},
@@ -340,10 +343,10 @@ function adminMessages(initialConversationId = null) {
conv.is_closed = false;
}
Utils.showToast('Conversation reopened', 'success');
Utils.showToast(I18n.t('messaging.messages.conversation_reopened'), 'success');
} catch (error) {
messagesLog.error('Failed to reopen conversation:', error);
Utils.showToast('Failed to reopen conversation', 'error');
Utils.showToast(I18n.t('messaging.messages.failed_to_reopen_conversation'), 'error');
}
},
@@ -367,7 +370,7 @@ function adminMessages(initialConversationId = null) {
messagesLog.debug(`Loaded ${this.recipients.length} recipients`);
} catch (error) {
messagesLog.error('Failed to load recipients:', error);
Utils.showToast('Failed to load recipients', 'error');
Utils.showToast(I18n.t('messaging.messages.failed_to_load_recipients'), 'error');
} finally {
this.loadingRecipients = false;
}
@@ -416,7 +419,7 @@ function adminMessages(initialConversationId = null) {
await this.loadConversations();
await this.selectConversation(response.id);
Utils.showToast('Conversation created', 'success');
Utils.showToast(I18n.t('messaging.messages.conversation_created'), 'success');
} catch (error) {
messagesLog.error('Failed to create conversation:', error);
Utils.showToast(error.message || 'Failed to create conversation', 'error');

View File

@@ -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');
}
},