Merge pull request #18643 from Snuffleupagus/l10n-translateOnce
Introduce a `L10n`-method to translate an element once, and use that in `PDFLayerViewer`
This commit is contained in:
commit
f11baea3e3
@ -80,6 +80,15 @@ class L10n {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @inheritdoc */
|
||||||
|
async translateOnce(element) {
|
||||||
|
try {
|
||||||
|
await this.#l10n.translateElements([element]);
|
||||||
|
} catch (ex) {
|
||||||
|
console.error(`translateOnce: "${ex}".`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** @inheritdoc */
|
/** @inheritdoc */
|
||||||
async destroy() {
|
async destroy() {
|
||||||
for (const element of this.#elements) {
|
for (const element of this.#elements) {
|
||||||
|
|||||||
@ -93,13 +93,16 @@ class PDFLayerViewer extends BaseTreeViewer {
|
|||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
async _setNestedName(element, { name = null }) {
|
_setNestedName(element, { name = null }) {
|
||||||
if (typeof name === "string") {
|
if (typeof name === "string") {
|
||||||
element.textContent = this._normalizeTextContent(name);
|
element.textContent = this._normalizeTextContent(name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
element.textContent = await this._l10n.get("pdfjs-additional-layers");
|
element.setAttribute("data-l10n-id", "pdfjs-additional-layers");
|
||||||
element.style.fontStyle = "italic";
|
element.style.fontStyle = "italic";
|
||||||
|
// Trigger translation manually, since translation is paused when
|
||||||
|
// the final layer-tree is appended to the DOM.
|
||||||
|
this._l10n.translateOnce(element);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user