Re-factor the toggleButton l10n in the PDFSidebar class

Rather than "manually" looking up the l10n-string and then updating the button, we can (and probably even should) just update the l10n-id and then trigger proper translation for the button DOM-element.
This commit is contained in:
Jonas Jenwald 2022-09-30 09:56:54 +02:00
parent 0011a747f7
commit bad00f825a
2 changed files with 7 additions and 10 deletions

View file

@ -307,9 +307,11 @@ class PDFSidebar {
}
#showUINotification() {
this.l10n.get("toggle_sidebar_notification2.title").then(msg => {
this.toggleButton.title = msg;
});
this.toggleButton.setAttribute(
"data-l10n-id",
"toggle_sidebar_notification2"
);
this.l10n.translate(this.toggleButton);
if (!this.isOpen) {
// Only show the notification on the `toggleButton` if the sidebar is
@ -326,9 +328,8 @@ class PDFSidebar {
}
if (reset) {
this.l10n.get("toggle_sidebar.title").then(msg => {
this.toggleButton.title = msg;
});
this.toggleButton.setAttribute("data-l10n-id", "toggle_sidebar");
this.l10n.translate(this.toggleButton);
}
}