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:
@@ -1,49 +1,82 @@
|
||||
{
|
||||
"title": "Product Catalog",
|
||||
"description": "Product catalog management for vendors",
|
||||
"products": {
|
||||
"title": "Products",
|
||||
"subtitle": "Manage your product catalog",
|
||||
"create": "Create Product",
|
||||
"edit": "Edit Product",
|
||||
"delete": "Delete Product",
|
||||
"empty": "No products found",
|
||||
"empty_search": "No products match your search"
|
||||
},
|
||||
"product": {
|
||||
"name": "Product Name",
|
||||
"description": "Description",
|
||||
"product": "Product",
|
||||
"add_product": "Add Product",
|
||||
"edit_product": "Edit Product",
|
||||
"delete_product": "Delete Product",
|
||||
"product_name": "Product Name",
|
||||
"product_code": "Product Code",
|
||||
"sku": "SKU",
|
||||
"price": "Price",
|
||||
"sale_price": "Sale Price",
|
||||
"cost": "Cost",
|
||||
"stock": "Stock",
|
||||
"status": "Status",
|
||||
"active": "Active",
|
||||
"inactive": "Inactive"
|
||||
},
|
||||
"media": {
|
||||
"title": "Product Media",
|
||||
"upload": "Upload Image",
|
||||
"delete": "Delete Image",
|
||||
"primary": "Set as Primary",
|
||||
"error": "Media upload failed"
|
||||
},
|
||||
"validation": {
|
||||
"name_required": "Product name is required",
|
||||
"price_required": "Price is required",
|
||||
"invalid_sku": "Invalid SKU format",
|
||||
"duplicate_sku": "SKU already exists"
|
||||
"in_stock": "In Stock",
|
||||
"out_of_stock": "Out of Stock",
|
||||
"low_stock": "Low Stock",
|
||||
"availability": "Availability",
|
||||
"available": "Available",
|
||||
"unavailable": "Unavailable",
|
||||
"brand": "Brand",
|
||||
"category": "Category",
|
||||
"categories": "Categories",
|
||||
"image": "Image",
|
||||
"images": "Images",
|
||||
"main_image": "Main Image",
|
||||
"gallery": "Gallery",
|
||||
"weight": "Weight",
|
||||
"dimensions": "Dimensions",
|
||||
"color": "Color",
|
||||
"size": "Size",
|
||||
"material": "Material",
|
||||
"condition": "Condition",
|
||||
"new": "New",
|
||||
"used": "Used",
|
||||
"refurbished": "Refurbished",
|
||||
"no_products": "No products found",
|
||||
"search_products": "Search products...",
|
||||
"filter_by_category": "Filter by category",
|
||||
"filter_by_status": "Filter by status",
|
||||
"sort_by": "Sort by",
|
||||
"sort_newest": "Newest",
|
||||
"sort_oldest": "Oldest",
|
||||
"sort_price_low": "Price: Low to High",
|
||||
"sort_price_high": "Price: High to Low",
|
||||
"sort_name_az": "Name: A-Z",
|
||||
"sort_name_za": "Name: Z-A"
|
||||
},
|
||||
"messages": {
|
||||
"created": "Product created successfully",
|
||||
"updated": "Product updated successfully",
|
||||
"deleted": "Product deleted successfully",
|
||||
"not_found": "Product not found",
|
||||
"cannot_delete": "Cannot delete product",
|
||||
"error_loading": "Error loading products"
|
||||
},
|
||||
"filters": {
|
||||
"all_products": "All Products",
|
||||
"active_only": "Active Only",
|
||||
"search_placeholder": "Search products..."
|
||||
"product_deleted_successfully": "Product deleted successfully",
|
||||
"product_created_successfully": "Product created successfully",
|
||||
"product_updated_successfully": "Product updated successfully",
|
||||
"product_activated": "Product activated",
|
||||
"product_deactivated": "Product deactivated",
|
||||
"product_marked_as_featured": "Product marked as featured",
|
||||
"product_unmarked_as_featured": "Product unmarked as featured",
|
||||
"products_activated": "{count} product(s) activated",
|
||||
"products_deactivated": "{count} product(s) deactivated",
|
||||
"products_marked_as_featured": "{count} product(s) marked as featured",
|
||||
"products_unmarked_as_featured": "{count} product(s) unmarked as featured",
|
||||
"products_deleted": "{count} product(s) deleted",
|
||||
"failed_to_save_product": "Failed to save product",
|
||||
"failed_to_create_product": "Failed to create product",
|
||||
"failed_to_update_product": "Failed to update product",
|
||||
"failed_to_delete_product": "Failed to delete product",
|
||||
"failed_to_load_products": "Failed to load products",
|
||||
"failed_to_activate_products": "Failed to activate products",
|
||||
"failed_to_deactivate_products": "Failed to deactivate products",
|
||||
"failed_to_upload_image": "Failed to upload image",
|
||||
"product_removed_from_vendor_catalog": "Product removed from vendor catalog.",
|
||||
"please_fill_in_all_required_fields": "Please fill in all required fields",
|
||||
"failed_to_load_media_library": "Failed to load media library",
|
||||
"no_vendor_associated_with_this_product": "No vendor associated with this product",
|
||||
"please_select_an_image_file": "Please select an image file",
|
||||
"image_must_be_less_than_10mb": "Image must be less than 10MB",
|
||||
"image_uploaded_successfully": "Image uploaded successfully",
|
||||
"please_select_a_vendor": "Please select a vendor",
|
||||
"please_enter_a_product_title_english": "Please enter a product title (English)",
|
||||
"please_select_a_vendor_first": "Please select a vendor first",
|
||||
"title_and_price_required": "Title and price are required"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,6 +44,9 @@ function vendorProductCreate() {
|
||||
},
|
||||
|
||||
async init() {
|
||||
// Load i18n translations
|
||||
await I18n.loadModule('catalog');
|
||||
|
||||
// Guard against duplicate initialization
|
||||
if (window._vendorProductCreateInitialized) return;
|
||||
window._vendorProductCreateInitialized = true;
|
||||
@@ -66,7 +69,7 @@ function vendorProductCreate() {
|
||||
|
||||
async createProduct() {
|
||||
if (!this.form.title || !this.form.price) {
|
||||
this.showToast('Title and price are required', 'error');
|
||||
Utils.showToast(I18n.t('catalog.messages.title_and_price_required'), 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -93,7 +96,7 @@ function vendorProductCreate() {
|
||||
}
|
||||
|
||||
vendorProductCreateLog.info('Product created:', response.data);
|
||||
this.showToast('Product created successfully', 'success');
|
||||
Utils.showToast(I18n.t('catalog.messages.product_created_successfully'), 'success');
|
||||
|
||||
// Navigate back to products list
|
||||
setTimeout(() => {
|
||||
@@ -102,8 +105,8 @@ function vendorProductCreate() {
|
||||
|
||||
} catch (err) {
|
||||
vendorProductCreateLog.error('Failed to create product:', err);
|
||||
this.error = err.message || 'Failed to create product';
|
||||
this.showToast(this.error, 'error');
|
||||
this.error = err.message || I18n.t('catalog.messages.failed_to_create_product');
|
||||
Utils.showToast(this.error, 'error');
|
||||
} finally {
|
||||
this.saving = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user