mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
[api-minor] Use "data-l10n-id"/"data-l10n-args", rather than manually updating DOM-elements, to trigger translation (PR 17146 follow-up)
This patch changes almost all viewer-components[1] to use "data-l10n-id"/"data-l10n-args" for localization, which means that in many cases we no longer need to pass around the `L10n`-instance any more. One part of the code-base where the `L10n`-instance is still being used "directly" is the AnnotationEditors, however while it might be possible to convert (most of) that code as well that's not attempted in this patch. --- [1] The one exception is the `PDFDocumentProperties` dialog, since the way it's currently implemented makes that less straightforward to fix without a lot of code changes.
This commit is contained in:
parent
898cc2e399
commit
17af706070
17 changed files with 117 additions and 149 deletions
|
@ -983,8 +983,11 @@ class TextAnnotationElement extends AnnotationElement {
|
|||
"annotation-" +
|
||||
this.data.name.toLowerCase() +
|
||||
".svg";
|
||||
image.dataset.l10nId = "pdfjs-text-annotation-type";
|
||||
image.dataset.l10nArgs = JSON.stringify({ type: this.data.name });
|
||||
image.setAttribute("data-l10n-id", "pdfjs-text-annotation-type");
|
||||
image.setAttribute(
|
||||
"data-l10n-args",
|
||||
JSON.stringify({ type: this.data.name })
|
||||
);
|
||||
|
||||
if (!this.data.popupRef && this.hasPopupData) {
|
||||
this._createPopup();
|
||||
|
@ -2158,11 +2161,17 @@ class PopupElement {
|
|||
if (this.#dateObj) {
|
||||
const modificationDate = document.createElement("span");
|
||||
modificationDate.classList.add("popupDate");
|
||||
modificationDate.dataset.l10nId = "pdfjs-annotation-date-string";
|
||||
modificationDate.dataset.l10nArgs = JSON.stringify({
|
||||
date: this.#dateObj.toLocaleDateString(),
|
||||
time: this.#dateObj.toLocaleTimeString(),
|
||||
});
|
||||
modificationDate.setAttribute(
|
||||
"data-l10n-id",
|
||||
"pdfjs-annotation-date-string"
|
||||
);
|
||||
modificationDate.setAttribute(
|
||||
"data-l10n-args",
|
||||
JSON.stringify({
|
||||
date: this.#dateObj.toLocaleDateString(),
|
||||
time: this.#dateObj.toLocaleTimeString(),
|
||||
})
|
||||
);
|
||||
header.append(modificationDate);
|
||||
}
|
||||
|
||||
|
@ -2889,14 +2898,12 @@ class AnnotationLayer {
|
|||
div,
|
||||
accessibilityManager,
|
||||
annotationCanvasMap,
|
||||
l10n,
|
||||
page,
|
||||
viewport,
|
||||
}) {
|
||||
this.div = div;
|
||||
this.#accessibilityManager = accessibilityManager;
|
||||
this.#annotationCanvasMap = annotationCanvasMap;
|
||||
this.l10n = l10n;
|
||||
this.page = page;
|
||||
this.viewport = viewport;
|
||||
this.zIndex = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue