mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-10 02:05:37 +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
|
@ -18,13 +18,12 @@
|
|||
import { FluentBundle, FluentResource } from "fluent-bundle";
|
||||
import { DOMLocalization } from "fluent-dom";
|
||||
import { L10n } from "./l10n.js";
|
||||
import { shadow } from "pdfjs-lib";
|
||||
|
||||
/**
|
||||
* @implements {IL10n}
|
||||
*/
|
||||
class ConstL10n extends L10n {
|
||||
static #instance;
|
||||
|
||||
constructor(lang) {
|
||||
super({ lang });
|
||||
this.setL10n(
|
||||
|
@ -51,7 +50,7 @@ class ConstL10n extends L10n {
|
|||
}
|
||||
|
||||
static get instance() {
|
||||
return (this.#instance ||= new ConstL10n("en-US"));
|
||||
return shadow(this, "instance", new ConstL10n("en-US"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue