Skip to content

Commit aa006dc

Browse files
committed
Update the tooltips when changing the language.
1 parent 9a28f0e commit aa006dc

3 files changed

Lines changed: 14 additions & 3 deletions

File tree

index.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@
8989
</ul>
9090
</div>
9191

92-
<button id="btnLoadNew" class="btn btn-outline-light btn-sm" type="button" data-i18n-title="navbar.loadAnother">
92+
<button id="btnLoadNew" class="btn btn-outline-light btn-sm" type="button"
93+
data-bs-toggle="tooltip" data-bs-placement="bottom" data-i18n-title="navbar.loadAnother">
9394
<i class="bi bi-escape me-1"></i>
9495
<span class="d-none d-sm-inline" data-i18n="navbar.newFile">Exit</span>
9596
</button>

js/app.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,6 +1092,9 @@
10921092
if (elements.btnNewWindow) {
10931093
new bootstrap.Tooltip(elements.btnNewWindow);
10941094
}
1095+
if (elements.btnLoadNew) {
1096+
new bootstrap.Tooltip(elements.btnLoadNew);
1097+
}
10951098

10961099
// Setup language selector
10971100
setupLanguageSelector();

js/i18n.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,17 @@ const i18n = (function() {
143143
element.placeholder = t(key);
144144
});
145145

146-
// Update titles
146+
// Update titles and Bootstrap tooltips
147147
document.querySelectorAll('[data-i18n-title]').forEach(element => {
148148
const key = element.getAttribute('data-i18n-title');
149-
element.title = t(key);
149+
const newTitle = t(key);
150+
element.title = newTitle;
151+
152+
// Update Bootstrap tooltip instance if it exists
153+
const tooltipInstance = bootstrap.Tooltip.getInstance(element);
154+
if (tooltipInstance) {
155+
tooltipInstance.setContent({ '.tooltip-inner': newTitle });
156+
}
150157
});
151158

152159
// Update aria-labels

0 commit comments

Comments
 (0)