Skip to content

Commit 50a12e3

Browse files
committed
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.
1 parent b517b5c commit 50a12e3

11 files changed

Lines changed: 9 additions & 69 deletions

src/display/editor/annotation_editor_layer.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
/** @typedef {import("../display_utils.js").PageViewport} PageViewport */
1919
// eslint-disable-next-line max-len
2020
/** @typedef {import("../../../web/text_accessibility.js").TextAccessibilityManager} TextAccessibilityManager */
21-
/** @typedef {import("../../../web/interfaces").IL10n} IL10n */
2221
// eslint-disable-next-line max-len
2322
/** @typedef {import("../annotation_layer.js").AnnotationLayer} AnnotationLayer */
2423
/** @typedef {import("../draw_layer.js").DrawLayer} DrawLayer */
@@ -47,7 +46,7 @@ import { StampEditor } from "./stamp.js";
4746
* @property {boolean} enabled
4847
* @property {TextAccessibilityManager} [accessibilityManager]
4948
* @property {number} pageIndex
50-
* @property {IL10n} l10n
49+
* @property {L10n} l10n
5150
* @property {AnnotationLayer} [annotationLayer]
5251
* @property {HTMLDivElement} [textLayer]
5352
* @property {DrawLayer} drawLayer

web/annotation_editor_layer_builder.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
/** @typedef {import("../src/display/editor/tools.js").AnnotationEditorUIManager} AnnotationEditorUIManager */
2121
// eslint-disable-next-line max-len
2222
/** @typedef {import("./text_accessibility.js").TextAccessibilityManager} TextAccessibilityManager */
23-
/** @typedef {import("./interfaces").IL10n} IL10n */
2423
// eslint-disable-next-line max-len
2524
/** @typedef {import("../src/display/annotation_layer.js").AnnotationLayer} AnnotationLayer */
2625
// eslint-disable-next-line max-len
@@ -33,7 +32,7 @@ import { GenericL10n } from "web-null_l10n";
3332
* @typedef {Object} AnnotationEditorLayerBuilderOptions
3433
* @property {AnnotationEditorUIManager} [uiManager]
3534
* @property {PDFPageProxy} pdfPage
36-
* @property {IL10n} [l10n]
35+
* @property {L10n} [l10n]
3736
* @property {StructTreeLayerBuilder} [structTreeLayer]
3837
* @property {TextAccessibilityManager} [accessibilityManager]
3938
* @property {AnnotationLayer} [annotationLayer]

web/app.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
* limitations under the License.
1414
*/
1515

16-
/** @typedef {import("./interfaces.js").IL10n} IL10n */
1716
// eslint-disable-next-line max-len
1817
/** @typedef {import("../src/display/api.js").PDFDocumentProxy} PDFDocumentProxy */
1918
// eslint-disable-next-line max-len
@@ -160,7 +159,7 @@ const PDFViewerApplication = {
160159
secondaryToolbar: null,
161160
/** @type {EventBus} */
162161
eventBus: null,
163-
/** @type {IL10n} */
162+
/** @type {L10n} */
164163
l10n: null,
165164
/** @type {AnnotationEditorParams} */
166165
annotationEditorParams: null,

web/external_services.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
* limitations under the License.
1414
*/
1515

16-
/** @typedef {import("./interfaces.js").IL10n} IL10n */
17-
1816
class BaseExternalServices {
1917
constructor() {
2018
if (
@@ -36,7 +34,7 @@ class BaseExternalServices {
3634
reportText(data) {}
3735

3836
/**
39-
* @returns {Promise<IL10n>}
37+
* @returns {Promise<L10n>}
4038
*/
4139
async createL10n() {
4240
throw new Error("Not implemented: createL10n");

web/genericl10n.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
* limitations under the License.
1414
*/
1515

16-
/** @typedef {import("./interfaces").IL10n} IL10n */
17-
1816
import { FeatureTest, fetchData } from "pdfjs-lib";
1917
import { FluentBundle, FluentResource } from "fluent-bundle";
2018
import { DOMLocalization } from "fluent-dom";
@@ -49,9 +47,6 @@ function createBundle(lang, text) {
4947
return bundle;
5048
}
5149

52-
/**
53-
* @implements {IL10n}
54-
*/
5550
class GenericL10n extends L10n {
5651
constructor(lang) {
5752
super({ lang });

web/interfaces.js

Lines changed: 1 addition & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -71,49 +71,6 @@ class IDownloadManager {
7171
download(data, url, filename) {}
7272
}
7373

74-
/**
75-
* @interface
76-
*/
77-
class IL10n {
78-
/**
79-
* @returns {string} - The current locale.
80-
*/
81-
getLanguage() {}
82-
83-
/**
84-
* @returns {string} - 'rtl' or 'ltr'.
85-
*/
86-
getDirection() {}
87-
88-
/**
89-
* Translates text identified by the key and adds/formats data using the args
90-
* property bag. If the key was not found, translation falls back to the
91-
* fallback text.
92-
* @param {Array | string} ids
93-
* @param {Object | null} [args]
94-
* @param {string} [fallback]
95-
* @returns {Promise<string>}
96-
*/
97-
async get(ids, args = null, fallback) {}
98-
99-
/**
100-
* Translates HTML element.
101-
* @param {HTMLElement} element
102-
* @returns {Promise<void>}
103-
*/
104-
async translate(element) {}
105-
106-
/**
107-
* Pause the localization.
108-
*/
109-
pause() {}
110-
111-
/**
112-
* Resume the localization.
113-
*/
114-
resume() {}
115-
}
116-
11774
/**
11875
* @interface
11976
*/
@@ -129,4 +86,4 @@ class IPDFPrintServiceFactory {
12986
}
13087
}
13188

132-
export { IDownloadManager, IL10n, IPDFPrintServiceFactory, IRenderableView };
89+
export { IDownloadManager, IPDFPrintServiceFactory, IRenderableView };

web/l10n.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,9 @@
1313
* limitations under the License.
1414
*/
1515

16-
/** @typedef {import("./interfaces").IL10n} IL10n */
17-
1816
/**
1917
* NOTE: The L10n-implementations should use lowercase language-codes
2018
* internally.
21-
* @implements {IL10n}
2219
*/
2320
class L10n {
2421
#dir;

web/pdf_document_properties.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
*/
1515

1616
/** @typedef {import("./event_utils.js").EventBus} EventBus */
17-
/** @typedef {import("./interfaces.js").IL10n} IL10n */
1817
/** @typedef {import("./overlay_manager.js").OverlayManager} OverlayManager */
1918
// eslint-disable-next-line max-len
2019
/** @typedef {import("../src/display/api.js").PDFDocumentProxy} PDFDocumentProxy */
@@ -58,7 +57,7 @@ class PDFDocumentProperties {
5857
* @param {PDFDocumentPropertiesOptions} options
5958
* @param {OverlayManager} overlayManager - Manager for the viewer overlays.
6059
* @param {EventBus} eventBus - The application event bus.
61-
* @param {IL10n} l10n - Localization service.
60+
* @param {L10n} l10n - Localization service.
6261
* @param {function} fileNameLookup - The function that is used to lookup
6362
* the document fileName.
6463
*/

web/pdf_page_view.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
// eslint-disable-next-line max-len
1919
/** @typedef {import("../src/display/optional_content_config").OptionalContentConfig} OptionalContentConfig */
2020
/** @typedef {import("./event_utils").EventBus} EventBus */
21-
/** @typedef {import("./interfaces").IL10n} IL10n */
2221
/** @typedef {import("./interfaces").IRenderableView} IRenderableView */
2322
// eslint-disable-next-line max-len
2423
/** @typedef {import("./pdf_rendering_queue").PDFRenderingQueue} PDFRenderingQueue */
@@ -98,7 +97,7 @@ import { XfaLayerBuilder } from "./xfa_layer_builder.js";
9897
* @property {Object} [pageColors] - Overwrites background and foreground colors
9998
* with user defined ones in order to improve readability in high contrast
10099
* mode.
101-
* @property {IL10n} [l10n] - Localization service.
100+
* @property {L10n} [l10n] - Localization service.
102101
* @property {Object} [layerProperties] - The object that is used to lookup
103102
* the necessary layer-properties.
104103
* @property {boolean} [enableAutoLinking] - Enable creation of hyperlinks from

web/pdf_viewer.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
/** @typedef {import("../src/display/optional_content_config").OptionalContentConfig} OptionalContentConfig */
2222
/** @typedef {import("./event_utils").EventBus} EventBus */
2323
/** @typedef {import("./interfaces").IDownloadManager} IDownloadManager */
24-
/** @typedef {import("./interfaces").IL10n} IL10n */
2524
// eslint-disable-next-line max-len
2625
/** @typedef {import("./pdf_find_controller").PDFFindController} PDFFindController */
2726
// eslint-disable-next-line max-len
@@ -134,7 +133,7 @@ function isValidAnnotationEditorMode(mode) {
134133
* rendering will keep track of which areas of the page each PDF operation
135134
* affects. Then, when rendering a partial page (if `enableDetailCanvas` is
136135
* enabled), it will only run through the operations that affect that portion.
137-
* @property {IL10n} [l10n] - Localization service.
136+
* @property {L10n} [l10n] - Localization service.
138137
* @property {boolean} [enablePermissions] - Enables PDF document permissions,
139138
* when they exist. The default value is `false`.
140139
* @property {Object} [pageColors] - Overwrites background and foreground colors

0 commit comments

Comments
 (0)