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:
@@ -51,6 +51,9 @@ function vendorNotifications() {
|
||||
},
|
||||
|
||||
async init() {
|
||||
// Load i18n translations
|
||||
await I18n.loadModule('messaging');
|
||||
|
||||
vendorNotificationsLog.info('Notifications init() called');
|
||||
|
||||
// Guard against multiple initialization
|
||||
@@ -121,7 +124,7 @@ function vendorNotifications() {
|
||||
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) {
|
||||
vendorNotificationsLog.error('Failed to mark as read:', error);
|
||||
Utils.showToast(error.message || 'Failed to mark notification as read', 'error');
|
||||
@@ -139,7 +142,7 @@ function vendorNotifications() {
|
||||
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) {
|
||||
vendorNotificationsLog.error('Failed to mark all as read:', error);
|
||||
Utils.showToast(error.message || 'Failed to mark all as read', 'error');
|
||||
@@ -150,7 +153,7 @@ function vendorNotifications() {
|
||||
* 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;
|
||||
}
|
||||
|
||||
@@ -165,7 +168,7 @@ function vendorNotifications() {
|
||||
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) {
|
||||
vendorNotificationsLog.error('Failed to delete notification:', error);
|
||||
Utils.showToast(error.message || 'Failed to delete notification', 'error');
|
||||
@@ -195,7 +198,7 @@ function vendorNotifications() {
|
||||
async saveSettings() {
|
||||
try {
|
||||
await apiClient.put(`/vendor/notifications/settings`, this.settingsForm);
|
||||
Utils.showToast('Notification settings saved', 'success');
|
||||
Utils.showToast(I18n.t('messaging.messages.notification_settings_saved'), 'success');
|
||||
this.showSettingsModal = false;
|
||||
} catch (error) {
|
||||
vendorNotificationsLog.error('Failed to save settings:', error);
|
||||
|
||||
Reference in New Issue
Block a user