Skip to content

Commit 0a1865b

Browse files
committed
fix(WebServer): fix status bar slot display showing {{slot}}
- Use t() with interpolation options instead of hardcoded string - Show 'Slot: -' when no slot is selected - Set data-i18n-options so i18n re-renders preserve the value - Fix mock t() to support {{var}} interpolation in tests
1 parent 12bbaac commit 0a1865b

2 files changed

Lines changed: 14 additions & 4 deletions

File tree

Tools/WebServer/static/js/core/slots.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,15 @@ function updateSlotUI() {
5656

5757
document.getElementById('activeSlotCount').textContent =
5858
`${activeCount}/${maxSlots}`;
59-
document.getElementById('currentSlotDisplay').textContent =
60-
`Slot: ${state.selectedSlot}`;
59+
const slotDisplay = document.getElementById('currentSlotDisplay');
60+
const slotValue = state.selectedSlot != null ? state.selectedSlot : '-';
61+
slotDisplay.textContent = t('statusbar.slot', 'Slot: {{slot}}', {
62+
slot: slotValue,
63+
});
64+
slotDisplay.setAttribute(
65+
'data-i18n-options',
66+
JSON.stringify({ slot: slotValue }),
67+
);
6168

6269
// Update slotSelect dropdown
6370
const slotSelect = document.getElementById('slotSelect');

Tools/WebServer/tests/js/mocks.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -507,10 +507,13 @@ const browserGlobals = {
507507
window: null,
508508
navigator: { clipboard: { writeText: () => Promise.resolve() } },
509509
console,
510-
// i18n translation function mock - returns fallback or key
510+
// i18n translation function mock - returns fallback with interpolation
511511
t: (key, fallbackOrOptions = {}, options = {}) => {
512512
if (typeof fallbackOrOptions === 'string') {
513-
return fallbackOrOptions;
513+
const vars = typeof options === 'object' ? options : {};
514+
return fallbackOrOptions.replace(/\{\{(\w+)\}\}/g, (_, k) =>
515+
vars[k] != null ? vars[k] : `{{${k}}}`,
516+
);
514517
}
515518
return key;
516519
},

0 commit comments

Comments
 (0)