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:
@@ -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