[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:
Jonas Jenwald 2023-10-19 16:30:57 +02:00
parent 898cc2e399
commit 17af706070
17 changed files with 117 additions and 149 deletions

View file

@ -19,7 +19,6 @@ import { BaseTreeViewer } from "./base_tree_viewer.js";
* @typedef {Object} PDFLayerViewerOptions
* @property {HTMLDivElement} container - The viewer element.
* @property {EventBus} eventBus - The application event bus.
* @property {IL10n} l10n - Localization service.
*/
/**
@ -32,7 +31,6 @@ import { BaseTreeViewer } from "./base_tree_viewer.js";
class PDFLayerViewer extends BaseTreeViewer {
constructor(options) {
super(options);
this.l10n = options.l10n;
this.eventBus._on("optionalcontentconfigchanged", evt => {
this.#updateLayers(evt.promise);
@ -89,7 +87,7 @@ class PDFLayerViewer extends BaseTreeViewer {
/**
* @private
*/
async _setNestedName(element, { name = null }) {
_setNestedName(element, { name = null }) {
if (typeof name === "string") {
element.textContent = this._normalizeTextContent(name);
return;