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:
@@ -80,7 +80,7 @@ function storeLoyaltyEnroll() {
|
||||
loyaltyEnrollLog.info('Customer enrolled successfully:', response.card_number);
|
||||
}
|
||||
} catch (error) {
|
||||
Utils.showToast(`Enrollment failed: ${error.message}`, 'error');
|
||||
Utils.showToast(I18n.t('loyalty.store.enroll.enrollment_failed', {message: error.message}), 'error');
|
||||
loyaltyEnrollLog.error('Enrollment failed:', error);
|
||||
} finally {
|
||||
this.enrolling = false;
|
||||
|
||||
@@ -87,10 +87,10 @@ function loyaltySettings() {
|
||||
let response;
|
||||
if (this.isNewProgram) {
|
||||
response = await apiClient.post('/store/loyalty/program', payload);
|
||||
Utils.showToast('Program created successfully', 'success');
|
||||
Utils.showToast(I18n.t('loyalty.store.settings.program_created'), 'success');
|
||||
} else {
|
||||
response = await apiClient.put('/store/loyalty/program', payload);
|
||||
Utils.showToast('Program updated successfully', 'success');
|
||||
Utils.showToast(I18n.t('loyalty.store.settings.program_updated'), 'success');
|
||||
}
|
||||
|
||||
this.populateSettings(response);
|
||||
@@ -98,7 +98,7 @@ function loyaltySettings() {
|
||||
|
||||
loyaltySettingsLog.info('Program saved:', response.display_name);
|
||||
} catch (error) {
|
||||
Utils.showToast(`Failed to save: ${error.message}`, 'error');
|
||||
Utils.showToast(I18n.t('loyalty.store.settings.save_failed', {message: error.message}), 'error');
|
||||
loyaltySettingsLog.error('Save failed:', error);
|
||||
} finally {
|
||||
this.saving = false;
|
||||
@@ -110,13 +110,13 @@ function loyaltySettings() {
|
||||
|
||||
try {
|
||||
await apiClient.delete('/store/loyalty/program');
|
||||
Utils.showToast('Loyalty program deleted', 'success');
|
||||
Utils.showToast(I18n.t('loyalty.store.settings.program_deleted'), 'success');
|
||||
loyaltySettingsLog.info('Program deleted');
|
||||
// Redirect to terminal page
|
||||
const storeCode = window.location.pathname.split('/')[2];
|
||||
window.location.href = `/store/${storeCode}/loyalty/program`;
|
||||
} catch (error) {
|
||||
Utils.showToast(`Failed to delete: ${error.message}`, 'error');
|
||||
Utils.showToast(I18n.t('loyalty.store.settings.delete_failed', {message: error.message}), 'error');
|
||||
loyaltySettingsLog.error('Delete failed:', error);
|
||||
} finally {
|
||||
this.deleting = false;
|
||||
|
||||
@@ -136,9 +136,9 @@ function storeLoyaltyTerminal() {
|
||||
}
|
||||
} catch (error) {
|
||||
if (error.status === 404) {
|
||||
Utils.showToast('Customer not found. You can enroll them as a new member.', 'warning');
|
||||
Utils.showToast(I18n.t('loyalty.store.terminal.customer_not_found'), 'warning');
|
||||
} else {
|
||||
Utils.showToast(`Error looking up customer: ${error.message}`, 'error');
|
||||
Utils.showToast(I18n.t('loyalty.store.terminal.error_lookup', {message: error.message}), 'error');
|
||||
}
|
||||
loyaltyTerminalLog.error('Lookup failed:', error);
|
||||
} finally {
|
||||
@@ -213,7 +213,7 @@ function storeLoyaltyTerminal() {
|
||||
await this.loadRecentTransactions();
|
||||
|
||||
} catch (error) {
|
||||
Utils.showToast(`Transaction failed: ${error.message}`, 'error');
|
||||
Utils.showToast(I18n.t('loyalty.store.terminal.transaction_failed', {message: error.message}), 'error');
|
||||
loyaltyTerminalLog.error('Transaction failed:', error);
|
||||
} finally {
|
||||
this.processing = false;
|
||||
@@ -229,7 +229,7 @@ function storeLoyaltyTerminal() {
|
||||
staff_pin: this.pinDigits
|
||||
});
|
||||
|
||||
Utils.showToast('Stamp added!', 'success');
|
||||
Utils.showToast(I18n.t('loyalty.store.terminal.stamp_added'), 'success');
|
||||
},
|
||||
|
||||
// Redeem stamps
|
||||
@@ -241,7 +241,7 @@ function storeLoyaltyTerminal() {
|
||||
staff_pin: this.pinDigits
|
||||
});
|
||||
|
||||
Utils.showToast('Stamps redeemed! Reward earned.', 'success');
|
||||
Utils.showToast(I18n.t('loyalty.store.terminal.stamps_redeemed'), 'success');
|
||||
},
|
||||
|
||||
// Earn points
|
||||
@@ -255,7 +255,7 @@ function storeLoyaltyTerminal() {
|
||||
});
|
||||
|
||||
const pointsEarned = response.points_earned || Math.floor(this.earnAmount * (this.program?.points_per_euro || 1));
|
||||
Utils.showToast(`${pointsEarned} points awarded!`, 'success');
|
||||
Utils.showToast(I18n.t('loyalty.store.terminal.x_points_awarded', {points: pointsEarned}), 'success');
|
||||
|
||||
this.earnAmount = null;
|
||||
},
|
||||
@@ -273,7 +273,7 @@ function storeLoyaltyTerminal() {
|
||||
staff_pin: this.pinDigits
|
||||
});
|
||||
|
||||
Utils.showToast(`Reward redeemed: ${reward.name}`, 'success');
|
||||
Utils.showToast(I18n.t('loyalty.store.terminal.reward_redeemed', {name: reward.name}), 'success');
|
||||
|
||||
this.selectedReward = '';
|
||||
},
|
||||
@@ -292,21 +292,11 @@ function storeLoyaltyTerminal() {
|
||||
|
||||
// Format number
|
||||
getTransactionLabel(tx) {
|
||||
const labels = {
|
||||
'card_created': 'Enrolled',
|
||||
'welcome_bonus': 'Welcome Bonus',
|
||||
'stamp_earned': 'Stamp Earned',
|
||||
'stamp_redeemed': 'Stamp Redeemed',
|
||||
'stamp_voided': 'Stamp Voided',
|
||||
'stamp_adjustment': 'Stamp Adjusted',
|
||||
'points_earned': 'Points Earned',
|
||||
'points_redeemed': 'Points Redeemed',
|
||||
'points_voided': 'Points Voided',
|
||||
'points_adjustment': 'Points Adjusted',
|
||||
'points_expired': 'Points Expired',
|
||||
'card_deactivated': 'Deactivated',
|
||||
};
|
||||
return labels[tx.transaction_type] || tx.transaction_type?.replace(/_/g, ' ') || 'Unknown';
|
||||
const type = tx.transaction_type;
|
||||
if (type) {
|
||||
return I18n.t('loyalty.transactions.' + type, {defaultValue: type.replace(/_/g, ' ')});
|
||||
}
|
||||
return I18n.t('loyalty.common.unknown');
|
||||
},
|
||||
|
||||
getTransactionColor(tx) {
|
||||
|
||||
Reference in New Issue
Block a user