feat(loyalty): add full i18n support for all loyalty module pages
Replace hardcoded English strings across all 22 templates, 10 JS files, and 4 locale files (en/fr/de/lb) with ~300 translation keys per language. Uses server-side _() for Jinja2 templates and I18n.t() for JS toast messages and dynamic Alpine.js expressions. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -190,12 +190,12 @@ function adminLoyaltyMerchantDetail() {
|
||||
};
|
||||
const response = await apiClient.post(`/admin/loyalty/merchants/${this.merchantId}/program`, data);
|
||||
this.program = response;
|
||||
Utils.showToast('Loyalty program created', 'success');
|
||||
Utils.showToast(I18n.t('loyalty.toasts.program_created'), 'success');
|
||||
loyaltyMerchantDetailLog.info('Program created for merchant', this.merchantId);
|
||||
// Reload stats
|
||||
await this.loadStats();
|
||||
} catch (error) {
|
||||
Utils.showToast(`Failed to create program: ${error.message}`, 'error');
|
||||
Utils.showToast(I18n.t('loyalty.toasts.create_failed', {message: error.message}), 'error');
|
||||
loyaltyMerchantDetailLog.error('Failed to create program:', error);
|
||||
}
|
||||
},
|
||||
@@ -207,10 +207,10 @@ function adminLoyaltyMerchantDetail() {
|
||||
try {
|
||||
const response = await apiClient.post(`/admin/loyalty/programs/${this.program.id}/${action}`);
|
||||
this.program.is_active = response.is_active;
|
||||
Utils.showToast(`Program ${action}d successfully`, 'success');
|
||||
Utils.showToast(I18n.t(`loyalty.toasts.program_${action}d`), 'success');
|
||||
loyaltyMerchantDetailLog.info(`Program ${action}d`);
|
||||
} catch (error) {
|
||||
Utils.showToast(`Failed to ${action} program: ${error.message}`, 'error');
|
||||
Utils.showToast(I18n.t(`loyalty.toasts.${action}_failed`, {message: error.message}), 'error');
|
||||
loyaltyMerchantDetailLog.error(`Failed to ${action} program:`, error);
|
||||
}
|
||||
},
|
||||
@@ -227,12 +227,12 @@ function adminLoyaltyMerchantDetail() {
|
||||
await apiClient.delete(`/admin/loyalty/programs/${this.program.id}`);
|
||||
this.program = null;
|
||||
this.showDeleteModal = false;
|
||||
Utils.showToast('Loyalty program deleted', 'success');
|
||||
Utils.showToast(I18n.t('loyalty.toasts.program_deleted'), 'success');
|
||||
loyaltyMerchantDetailLog.info('Program deleted');
|
||||
// Reload stats
|
||||
await this.loadStats();
|
||||
} catch (error) {
|
||||
Utils.showToast(`Failed to delete program: ${error.message}`, 'error');
|
||||
Utils.showToast(I18n.t('loyalty.toasts.delete_failed', {message: error.message}), 'error');
|
||||
loyaltyMerchantDetailLog.error('Failed to delete program:', error);
|
||||
this.showDeleteModal = false;
|
||||
}
|
||||
|
||||
@@ -150,14 +150,14 @@ function adminLoyaltyMerchantSettings() {
|
||||
|
||||
if (response) {
|
||||
loyaltyMerchantSettingsLog.info('Settings saved successfully');
|
||||
Utils.showToast('Settings saved successfully', 'success');
|
||||
Utils.showToast(I18n.t('loyalty.toasts.settings_saved'), 'success');
|
||||
|
||||
// Navigate back to merchant detail
|
||||
window.location.href = this.backUrl;
|
||||
}
|
||||
} catch (error) {
|
||||
loyaltyMerchantSettingsLog.error('Failed to save settings:', error);
|
||||
Utils.showToast(`Failed to save settings: ${error.message}`, 'error');
|
||||
Utils.showToast(I18n.t('loyalty.toasts.settings_save_failed', {message: error.message}), 'error');
|
||||
} finally {
|
||||
this.saving = false;
|
||||
}
|
||||
|
||||
@@ -109,19 +109,19 @@ function adminLoyaltyProgramEdit() {
|
||||
);
|
||||
this.programId = response.id;
|
||||
this.isNewProgram = false;
|
||||
Utils.showToast('Program created successfully', 'success');
|
||||
Utils.showToast(I18n.t('loyalty.toasts.program_created'), 'success');
|
||||
} else {
|
||||
await apiClient.patch(
|
||||
`/admin/loyalty/programs/${this.programId}`,
|
||||
payload
|
||||
);
|
||||
Utils.showToast('Program updated successfully', 'success');
|
||||
Utils.showToast(I18n.t('loyalty.toasts.program_updated'), 'success');
|
||||
}
|
||||
|
||||
loyaltyProgramEditLog.info('Program saved');
|
||||
window.location.href = this.backUrl;
|
||||
} catch (error) {
|
||||
Utils.showToast(`Failed to save: ${error.message}`, 'error');
|
||||
Utils.showToast(I18n.t('loyalty.toasts.save_failed', {message: error.message}), 'error');
|
||||
loyaltyProgramEditLog.error('Save failed:', error);
|
||||
} finally {
|
||||
this.saving = false;
|
||||
@@ -134,11 +134,11 @@ function adminLoyaltyProgramEdit() {
|
||||
|
||||
try {
|
||||
await apiClient.delete(`/admin/loyalty/programs/${this.programId}`);
|
||||
Utils.showToast('Program deleted', 'success');
|
||||
Utils.showToast(I18n.t('loyalty.toasts.program_deleted'), 'success');
|
||||
loyaltyProgramEditLog.info('Program deleted');
|
||||
window.location.href = this.backUrl;
|
||||
} catch (error) {
|
||||
Utils.showToast(`Failed to delete: ${error.message}`, 'error');
|
||||
Utils.showToast(I18n.t('loyalty.toasts.delete_failed', {message: error.message}), 'error');
|
||||
loyaltyProgramEditLog.error('Delete failed:', error);
|
||||
} finally {
|
||||
this.deleting = false;
|
||||
|
||||
@@ -249,10 +249,10 @@ function adminLoyaltyPrograms() {
|
||||
try {
|
||||
const response = await apiClient.post(`/admin/loyalty/programs/${program.id}/${action}`);
|
||||
program.is_active = response.is_active;
|
||||
Utils.showToast(`Program ${action}d successfully`, 'success');
|
||||
Utils.showToast(I18n.t(`loyalty.toasts.program_${action}d`), 'success');
|
||||
loyaltyProgramsLog.info(`Program ${program.id} ${action}d`);
|
||||
} catch (error) {
|
||||
Utils.showToast(`Failed to ${action} program: ${error.message}`, 'error');
|
||||
Utils.showToast(I18n.t(`loyalty.toasts.${action}_failed`, {message: error.message}), 'error');
|
||||
loyaltyProgramsLog.error(`Failed to ${action} program:`, error);
|
||||
}
|
||||
},
|
||||
@@ -267,13 +267,13 @@ function adminLoyaltyPrograms() {
|
||||
if (!this.deletingProgram) return;
|
||||
try {
|
||||
await apiClient.delete(`/admin/loyalty/programs/${this.deletingProgram.id}`);
|
||||
Utils.showToast('Program deleted successfully', 'success');
|
||||
Utils.showToast(I18n.t('loyalty.toasts.program_deleted'), 'success');
|
||||
loyaltyProgramsLog.info('Program deleted:', this.deletingProgram.id);
|
||||
this.showDeleteModal = false;
|
||||
this.deletingProgram = null;
|
||||
await Promise.all([this.loadPrograms(), this.loadStats()]);
|
||||
} catch (error) {
|
||||
Utils.showToast(`Failed to delete program: ${error.message}`, 'error');
|
||||
Utils.showToast(I18n.t('loyalty.toasts.delete_failed', {message: error.message}), 'error');
|
||||
loyaltyProgramsLog.error('Failed to delete program:', error);
|
||||
this.showDeleteModal = false;
|
||||
this.deletingProgram = null;
|
||||
|
||||
Reference in New Issue
Block a user