mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 17:30:09 +02:00
Introduce a L10n
-method to translate an element once, and use that in PDFLayerViewer
Currently we *manually* fetch the "pdfjs-additional-layers" string and update the DOM-element, which was needed since we want to avoid triggering a bunch of otherwise unnecessary translation when appending the entire layer-tree to the DOM. By introducing a new helper method in the `L10n`-class we can avoid this, and instead use a "data-l10n-id" attribute on the element (as most other viewer code does nowadays).
This commit is contained in:
parent
908f453384
commit
fabbe544ab
2 changed files with 14 additions and 2 deletions
|
@ -80,6 +80,15 @@ class L10n {
|
|||
}
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
async translateOnce(element) {
|
||||
try {
|
||||
await this.#l10n.translateElements([element]);
|
||||
} catch (ex) {
|
||||
console.error(`translateOnce: "${ex}".`);
|
||||
}
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
async destroy() {
|
||||
for (const element of this.#elements) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue