Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[L10n] Don't try to connect the root element when it has already been done #17142

Merged
merged 1 commit into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions web/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,14 +272,6 @@ const PDFViewerApplication = {
this.bindEvents();
this.bindWindowEvents();

// We can start UI localization now.
const appContainer = appConfig.appContainer || document.documentElement;
this.l10n.translate(appContainer).then(() => {
// Dispatch the 'localized' event on the `eventBus` once the viewer
// has been fully initialized and translated.
this.eventBus.dispatch("localized", { source: this });
});

this._initializedCapability.resolve();
},

Expand Down Expand Up @@ -375,6 +367,12 @@ const PDFViewerApplication = {
: null
);
document.getElementsByTagName("html")[0].dir = this.l10n.getDirection();
if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("MOZCENTRAL")) {
const appContainer =
this.appConfig.appContainer || document.documentElement;
// Connect Fluent and translate what we already have.
this.l10n.translate(appContainer);
}
},

/**
Expand Down
11 changes: 0 additions & 11 deletions web/toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ const PAGE_NUMBER_LOADING_INDICATOR = "visiblePageIsLoading";
*/

class Toolbar {
#wasLocalized = false;

/**
* @param {ToolbarOptions} options
* @param {EventBus} eventBus
Expand Down Expand Up @@ -206,11 +204,6 @@ class Toolbar {
// Suppress context menus for some controls.
scaleSelect.oncontextmenu = noContextMenu;

this.eventBus._on("localized", () => {
this.#wasLocalized = true;
this.#updateUIState(true);
});

this.#bindEditorToolsListener(options);
}

Expand Down Expand Up @@ -254,10 +247,6 @@ class Toolbar {
}

#updateUIState(resetNumPages = false) {
if (!this.#wasLocalized) {
// Don't update the UI state until we localize the toolbar.
return;
}
const { pageNumber, pagesCount, pageScaleValue, pageScale, items } = this;

if (resetNumPages) {
Expand Down