diff --git a/test/unit/pdf_viewer.component_spec.js b/test/unit/pdf_viewer.component_spec.js index d527acace..cace29e03 100644 --- a/test/unit/pdf_viewer.component_spec.js +++ b/test/unit/pdf_viewer.component_spec.js @@ -30,6 +30,7 @@ import { AnnotationLayerBuilder } from "../../web/annotation_layer_builder.js"; import { DownloadManager } from "../../web/download_manager.js"; import { EventBus } from "../../web/event_utils.js"; import { GenericL10n } from "../../web/genericl10n.js"; +import { L10n } from "../../web/l10n.js"; import { NullL10n } from "../../web/l10n_utils.js"; import { PDFHistory } from "../../web/pdf_history.js"; import { PDFPageView } from "../../web/pdf_page_view.js"; @@ -72,4 +73,14 @@ describe("pdfviewer_api", function () { XfaLayerBuilder, }); }); + + it("checks that `NullL10n` implements all methods", function () { + const methods = Object.getOwnPropertyNames(NullL10n).sort(); + + const baseMethods = Object.getOwnPropertyNames(L10n.prototype) + .filter(m => m !== "constructor" && !m.startsWith("_")) + .sort(); + + expect(methods).toEqual(baseMethods); + }); }); diff --git a/web/genericl10n.js b/web/genericl10n.js index c90232cba..87feb67fe 100644 --- a/web/genericl10n.js +++ b/web/genericl10n.js @@ -25,7 +25,7 @@ import { L10n } from "./l10n.js"; class GenericL10n extends L10n { constructor(lang) { super({ lang }); - this.setL10n( + this._setL10n( new DOMLocalization( [], GenericL10n.#generateBundles.bind( diff --git a/web/l10n.js b/web/l10n.js index f4674984f..f8aa2f27c 100644 --- a/web/l10n.js +++ b/web/l10n.js @@ -31,7 +31,7 @@ class L10n { this.#dir = isRTL ?? L10n.#isRTL(this.#lang) ? "rtl" : "ltr"; } - setL10n(l10n) { + _setL10n(l10n) { this.#l10n = l10n; if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("TESTING")) { document.l10n = l10n; diff --git a/web/pdf_find_bar.js b/web/pdf_find_bar.js index a2b0f5477..ebdd817fb 100644 --- a/web/pdf_find_bar.js +++ b/web/pdf_find_bar.js @@ -144,16 +144,15 @@ class PDFFindBar { const { findResultsCount } = this; if (total > 0) { - const limit = MATCHES_COUNT_LIMIT, - isLimited = total > limit; + const limit = MATCHES_COUNT_LIMIT; findResultsCount.setAttribute( "data-l10n-id", - `pdfjs-find-match-count${isLimited ? "-limit" : ""}` + `pdfjs-find-match-count${total > limit ? "-limit" : ""}` ); findResultsCount.setAttribute( "data-l10n-args", - JSON.stringify(isLimited ? { limit } : { current, total }) + JSON.stringify({ limit, current, total }) ); } else { findResultsCount.removeAttribute("data-l10n-id");