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:
13
app/modules/cms/static/vendor/js/media.js
vendored
13
app/modules/cms/static/vendor/js/media.js
vendored
@@ -119,6 +119,9 @@ function vendorMedia() {
|
||||
uploadingFiles: [],
|
||||
|
||||
async init() {
|
||||
// Load i18n translations
|
||||
await I18n.loadModule('cms');
|
||||
|
||||
// Guard against duplicate initialization
|
||||
if (window._vendorMediaInitialized) return;
|
||||
window._vendorMediaInitialized = true;
|
||||
@@ -233,7 +236,7 @@ function vendorMedia() {
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
this.showToast('Media updated successfully', 'success');
|
||||
Utils.showToast(I18n.t('cms.messages.media_updated_successfully'), 'success');
|
||||
this.showDetailModal = false;
|
||||
await this.loadMedia();
|
||||
} else {
|
||||
@@ -250,7 +253,7 @@ function vendorMedia() {
|
||||
async deleteMedia() {
|
||||
if (!this.selectedMedia) return;
|
||||
|
||||
if (!confirm('Are you sure you want to delete this file? This cannot be undone.')) {
|
||||
if (!confirm(I18n.t('cms.confirmations.delete_file'))) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -260,7 +263,7 @@ function vendorMedia() {
|
||||
const response = await apiClient.delete(`/vendor/media/${this.selectedMedia.id}`);
|
||||
|
||||
if (response.ok) {
|
||||
this.showToast('Media deleted successfully', 'success');
|
||||
Utils.showToast(I18n.t('cms.messages.media_deleted_successfully'), 'success');
|
||||
this.showDetailModal = false;
|
||||
this.selectedMedia = null;
|
||||
await this.loadMedia();
|
||||
@@ -351,9 +354,9 @@ function vendorMedia() {
|
||||
copyToClipboard(text) {
|
||||
if (!text) return;
|
||||
navigator.clipboard.writeText(text).then(() => {
|
||||
this.showToast('URL copied to clipboard', 'success');
|
||||
Utils.showToast(I18n.t('cms.messages.url_copied_to_clipboard'), 'success');
|
||||
}).catch(() => {
|
||||
this.showToast('Failed to copy URL', 'error');
|
||||
Utils.showToast(I18n.t('cms.messages.failed_to_copy_url'), 'error');
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user