From 50a12e3e677d66b5b9b40704824b0d5b03420dc6 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Fri, 30 Jan 2026 15:51:04 +0100 Subject: [PATCH] Remove the `IL10n` interface Given that we either use the `L10n` class directly or extend it via `GenericL10n`, it should no longer be necessary to keep the interface-definition. This should help reduce the maintenance burden of the code, since you no longer need to remember to update separate code when touching the `L10n` class. --- src/display/editor/annotation_editor_layer.js | 3 +- web/annotation_editor_layer_builder.js | 3 +- web/app.js | 3 +- web/external_services.js | 4 +- web/genericl10n.js | 5 --- web/interfaces.js | 45 +------------------ web/l10n.js | 3 -- web/pdf_document_properties.js | 3 +- web/pdf_page_view.js | 3 +- web/pdf_viewer.js | 3 +- web/views_manager.js | 3 +- 11 files changed, 9 insertions(+), 69 deletions(-) diff --git a/src/display/editor/annotation_editor_layer.js b/src/display/editor/annotation_editor_layer.js index a740d3952..781f2f620 100644 --- a/src/display/editor/annotation_editor_layer.js +++ b/src/display/editor/annotation_editor_layer.js @@ -18,7 +18,6 @@ /** @typedef {import("../display_utils.js").PageViewport} PageViewport */ // eslint-disable-next-line max-len /** @typedef {import("../../../web/text_accessibility.js").TextAccessibilityManager} TextAccessibilityManager */ -/** @typedef {import("../../../web/interfaces").IL10n} IL10n */ // eslint-disable-next-line max-len /** @typedef {import("../annotation_layer.js").AnnotationLayer} AnnotationLayer */ /** @typedef {import("../draw_layer.js").DrawLayer} DrawLayer */ @@ -47,7 +46,7 @@ import { StampEditor } from "./stamp.js"; * @property {boolean} enabled * @property {TextAccessibilityManager} [accessibilityManager] * @property {number} pageIndex - * @property {IL10n} l10n + * @property {L10n} l10n * @property {AnnotationLayer} [annotationLayer] * @property {HTMLDivElement} [textLayer] * @property {DrawLayer} drawLayer diff --git a/web/annotation_editor_layer_builder.js b/web/annotation_editor_layer_builder.js index 9709628b6..b562c2542 100644 --- a/web/annotation_editor_layer_builder.js +++ b/web/annotation_editor_layer_builder.js @@ -20,7 +20,6 @@ /** @typedef {import("../src/display/editor/tools.js").AnnotationEditorUIManager} AnnotationEditorUIManager */ // eslint-disable-next-line max-len /** @typedef {import("./text_accessibility.js").TextAccessibilityManager} TextAccessibilityManager */ -/** @typedef {import("./interfaces").IL10n} IL10n */ // eslint-disable-next-line max-len /** @typedef {import("../src/display/annotation_layer.js").AnnotationLayer} AnnotationLayer */ // eslint-disable-next-line max-len @@ -33,7 +32,7 @@ import { GenericL10n } from "web-null_l10n"; * @typedef {Object} AnnotationEditorLayerBuilderOptions * @property {AnnotationEditorUIManager} [uiManager] * @property {PDFPageProxy} pdfPage - * @property {IL10n} [l10n] + * @property {L10n} [l10n] * @property {StructTreeLayerBuilder} [structTreeLayer] * @property {TextAccessibilityManager} [accessibilityManager] * @property {AnnotationLayer} [annotationLayer] diff --git a/web/app.js b/web/app.js index a06ba8c12..0cd978f3e 100644 --- a/web/app.js +++ b/web/app.js @@ -13,7 +13,6 @@ * limitations under the License. */ -/** @typedef {import("./interfaces.js").IL10n} IL10n */ // eslint-disable-next-line max-len /** @typedef {import("../src/display/api.js").PDFDocumentProxy} PDFDocumentProxy */ // eslint-disable-next-line max-len @@ -160,7 +159,7 @@ const PDFViewerApplication = { secondaryToolbar: null, /** @type {EventBus} */ eventBus: null, - /** @type {IL10n} */ + /** @type {L10n} */ l10n: null, /** @type {AnnotationEditorParams} */ annotationEditorParams: null, diff --git a/web/external_services.js b/web/external_services.js index 437223a94..74642af48 100644 --- a/web/external_services.js +++ b/web/external_services.js @@ -13,8 +13,6 @@ * limitations under the License. */ -/** @typedef {import("./interfaces.js").IL10n} IL10n */ - class BaseExternalServices { constructor() { if ( @@ -36,7 +34,7 @@ class BaseExternalServices { reportText(data) {} /** - * @returns {Promise} + * @returns {Promise} */ async createL10n() { throw new Error("Not implemented: createL10n"); diff --git a/web/genericl10n.js b/web/genericl10n.js index 79d3fa82b..779569f2a 100644 --- a/web/genericl10n.js +++ b/web/genericl10n.js @@ -13,8 +13,6 @@ * limitations under the License. */ -/** @typedef {import("./interfaces").IL10n} IL10n */ - import { FeatureTest, fetchData } from "pdfjs-lib"; import { FluentBundle, FluentResource } from "fluent-bundle"; import { DOMLocalization } from "fluent-dom"; @@ -49,9 +47,6 @@ function createBundle(lang, text) { return bundle; } -/** - * @implements {IL10n} - */ class GenericL10n extends L10n { constructor(lang) { super({ lang }); diff --git a/web/interfaces.js b/web/interfaces.js index 1e2a13910..83e0f6c96 100644 --- a/web/interfaces.js +++ b/web/interfaces.js @@ -71,49 +71,6 @@ class IDownloadManager { download(data, url, filename) {} } -/** - * @interface - */ -class IL10n { - /** - * @returns {string} - The current locale. - */ - getLanguage() {} - - /** - * @returns {string} - 'rtl' or 'ltr'. - */ - getDirection() {} - - /** - * Translates text identified by the key and adds/formats data using the args - * property bag. If the key was not found, translation falls back to the - * fallback text. - * @param {Array | string} ids - * @param {Object | null} [args] - * @param {string} [fallback] - * @returns {Promise} - */ - async get(ids, args = null, fallback) {} - - /** - * Translates HTML element. - * @param {HTMLElement} element - * @returns {Promise} - */ - async translate(element) {} - - /** - * Pause the localization. - */ - pause() {} - - /** - * Resume the localization. - */ - resume() {} -} - /** * @interface */ @@ -129,4 +86,4 @@ class IPDFPrintServiceFactory { } } -export { IDownloadManager, IL10n, IPDFPrintServiceFactory, IRenderableView }; +export { IDownloadManager, IPDFPrintServiceFactory, IRenderableView }; diff --git a/web/l10n.js b/web/l10n.js index ad469a526..b07abe84c 100644 --- a/web/l10n.js +++ b/web/l10n.js @@ -13,12 +13,9 @@ * limitations under the License. */ -/** @typedef {import("./interfaces").IL10n} IL10n */ - /** * NOTE: The L10n-implementations should use lowercase language-codes * internally. - * @implements {IL10n} */ class L10n { #dir; diff --git a/web/pdf_document_properties.js b/web/pdf_document_properties.js index bd3ec9cbb..98de92bf7 100644 --- a/web/pdf_document_properties.js +++ b/web/pdf_document_properties.js @@ -14,7 +14,6 @@ */ /** @typedef {import("./event_utils.js").EventBus} EventBus */ -/** @typedef {import("./interfaces.js").IL10n} IL10n */ /** @typedef {import("./overlay_manager.js").OverlayManager} OverlayManager */ // eslint-disable-next-line max-len /** @typedef {import("../src/display/api.js").PDFDocumentProxy} PDFDocumentProxy */ @@ -58,7 +57,7 @@ class PDFDocumentProperties { * @param {PDFDocumentPropertiesOptions} options * @param {OverlayManager} overlayManager - Manager for the viewer overlays. * @param {EventBus} eventBus - The application event bus. - * @param {IL10n} l10n - Localization service. + * @param {L10n} l10n - Localization service. * @param {function} fileNameLookup - The function that is used to lookup * the document fileName. */ diff --git a/web/pdf_page_view.js b/web/pdf_page_view.js index b3364661a..045b566eb 100644 --- a/web/pdf_page_view.js +++ b/web/pdf_page_view.js @@ -18,7 +18,6 @@ // eslint-disable-next-line max-len /** @typedef {import("../src/display/optional_content_config").OptionalContentConfig} OptionalContentConfig */ /** @typedef {import("./event_utils").EventBus} EventBus */ -/** @typedef {import("./interfaces").IL10n} IL10n */ /** @typedef {import("./interfaces").IRenderableView} IRenderableView */ // eslint-disable-next-line max-len /** @typedef {import("./pdf_rendering_queue").PDFRenderingQueue} PDFRenderingQueue */ @@ -98,7 +97,7 @@ import { XfaLayerBuilder } from "./xfa_layer_builder.js"; * @property {Object} [pageColors] - Overwrites background and foreground colors * with user defined ones in order to improve readability in high contrast * mode. - * @property {IL10n} [l10n] - Localization service. + * @property {L10n} [l10n] - Localization service. * @property {Object} [layerProperties] - The object that is used to lookup * the necessary layer-properties. * @property {boolean} [enableAutoLinking] - Enable creation of hyperlinks from diff --git a/web/pdf_viewer.js b/web/pdf_viewer.js index 9f4b2bb14..6235f8752 100644 --- a/web/pdf_viewer.js +++ b/web/pdf_viewer.js @@ -21,7 +21,6 @@ /** @typedef {import("../src/display/optional_content_config").OptionalContentConfig} OptionalContentConfig */ /** @typedef {import("./event_utils").EventBus} EventBus */ /** @typedef {import("./interfaces").IDownloadManager} IDownloadManager */ -/** @typedef {import("./interfaces").IL10n} IL10n */ // eslint-disable-next-line max-len /** @typedef {import("./pdf_find_controller").PDFFindController} PDFFindController */ // eslint-disable-next-line max-len @@ -134,7 +133,7 @@ function isValidAnnotationEditorMode(mode) { * rendering will keep track of which areas of the page each PDF operation * affects. Then, when rendering a partial page (if `enableDetailCanvas` is * enabled), it will only run through the operations that affect that portion. - * @property {IL10n} [l10n] - Localization service. + * @property {L10n} [l10n] - Localization service. * @property {boolean} [enablePermissions] - Enables PDF document permissions, * when they exist. The default value is `false`. * @property {Object} [pageColors] - Overwrites background and foreground colors diff --git a/web/views_manager.js b/web/views_manager.js index c9a19b5e5..9c08e7fb4 100644 --- a/web/views_manager.js +++ b/web/views_manager.js @@ -14,7 +14,6 @@ */ /** @typedef {import("./event_utils.js").EventBus} EventBus */ -/** @typedef {import("./interfaces.js").IL10n} IL10n */ import { docStyle, @@ -34,7 +33,7 @@ const UI_NOTIFICATION_CLASS = "pdfSidebarNotification"; * @typedef {Object} PDFSidebarOptions * @property {PDFSidebarElements} elements - The DOM elements. * @property {EventBus} eventBus - The application event bus. - * @property {IL10n} l10n - The localization service. + * @property {L10n} l10n - The localization service. */ /**