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:
@@ -62,6 +62,9 @@ function vendorMessages(initialConversationId = null) {
|
||||
* Initialize component
|
||||
*/
|
||||
async init() {
|
||||
// Load i18n translations
|
||||
await I18n.loadModule('messaging');
|
||||
|
||||
// Guard against multiple initialization
|
||||
if (window._vendorMessagesInitialized) return;
|
||||
window._vendorMessagesInitialized = true;
|
||||
@@ -143,7 +146,7 @@ function vendorMessages(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;
|
||||
}
|
||||
@@ -192,7 +195,7 @@ function vendorMessages(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;
|
||||
}
|
||||
@@ -276,7 +279,7 @@ function vendorMessages(initialConversationId = null) {
|
||||
* Close conversation
|
||||
*/
|
||||
async closeConversation() {
|
||||
if (!confirm('Close this conversation?')) return;
|
||||
if (!confirm(I18n.t('messaging.confirmations.close_conversation'))) return;
|
||||
|
||||
try {
|
||||
await apiClient.post(`/vendor/messages/${this.selectedConversationId}/close`);
|
||||
@@ -288,10 +291,10 @@ function vendorMessages(initialConversationId = null) {
|
||||
const conv = this.conversations.find(c => c.id === this.selectedConversationId);
|
||||
if (conv) 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');
|
||||
}
|
||||
},
|
||||
|
||||
@@ -309,10 +312,10 @@ function vendorMessages(initialConversationId = null) {
|
||||
const conv = this.conversations.find(c => c.id === this.selectedConversationId);
|
||||
if (conv) 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');
|
||||
}
|
||||
},
|
||||
|
||||
@@ -356,7 +359,7 @@ function vendorMessages(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');
|
||||
|
||||
Reference in New Issue
Block a user