Simplify localization of the "default-content" in FreeText editors
By using "data-l10n-attrs" it's possible to instruct Fluent to localize *custom* attributes, which means that we don't need to manually translate/update the "default-content" in FreeText editors.
This commit is contained in:
parent
f9659f4635
commit
2ef3fd2a81
@ -348,9 +348,9 @@ pdfjs-editor-free-highlight-thickness-input = Thickness
|
|||||||
pdfjs-editor-free-highlight-thickness-title =
|
pdfjs-editor-free-highlight-thickness-title =
|
||||||
.title = Change thickness when highlighting items other than text
|
.title = Change thickness when highlighting items other than text
|
||||||
|
|
||||||
pdfjs-free-text =
|
pdfjs-free-text2 =
|
||||||
.aria-label = Text Editor
|
.aria-label = Text Editor
|
||||||
pdfjs-free-text-default-content = Start typing…
|
.default-content = Start typing…
|
||||||
pdfjs-ink =
|
pdfjs-ink =
|
||||||
.aria-label = Draw Editor
|
.aria-label = Draw Editor
|
||||||
pdfjs-ink-canvas =
|
pdfjs-ink-canvas =
|
||||||
|
|||||||
@ -209,7 +209,7 @@ class AnnotationEditor {
|
|||||||
* Initialize the l10n stuff for this type of editor.
|
* Initialize the l10n stuff for this type of editor.
|
||||||
* @param {Object} l10n
|
* @param {Object} l10n
|
||||||
*/
|
*/
|
||||||
static initialize(l10n, _uiManager, options) {
|
static initialize(l10n, _uiManager) {
|
||||||
AnnotationEditor._l10nResizer ||= Object.freeze({
|
AnnotationEditor._l10nResizer ||= Object.freeze({
|
||||||
topLeft: "pdfjs-editor-resizer-top-left",
|
topLeft: "pdfjs-editor-resizer-top-left",
|
||||||
topMiddle: "pdfjs-editor-resizer-top-middle",
|
topMiddle: "pdfjs-editor-resizer-top-middle",
|
||||||
@ -236,11 +236,6 @@ class AnnotationEditor {
|
|||||||
].map(str => [str, l10n.get.bind(l10n, str)]),
|
].map(str => [str, l10n.get.bind(l10n, str)]),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (options?.strings) {
|
|
||||||
for (const str of options.strings) {
|
|
||||||
AnnotationEditor._l10nPromise.set(str, l10n.get(str));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (AnnotationEditor._borderLineWidth !== -1) {
|
if (AnnotationEditor._borderLineWidth !== -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -139,9 +139,7 @@ class FreeTextEditor extends AnnotationEditor {
|
|||||||
|
|
||||||
/** @inheritdoc */
|
/** @inheritdoc */
|
||||||
static initialize(l10n, uiManager) {
|
static initialize(l10n, uiManager) {
|
||||||
AnnotationEditor.initialize(l10n, uiManager, {
|
AnnotationEditor.initialize(l10n, uiManager);
|
||||||
strings: ["pdfjs-free-text-default-content"],
|
|
||||||
});
|
|
||||||
const style = getComputedStyle(document.documentElement);
|
const style = getComputedStyle(document.documentElement);
|
||||||
|
|
||||||
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
|
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
|
||||||
@ -563,12 +561,10 @@ class FreeTextEditor extends AnnotationEditor {
|
|||||||
this.editorDiv.className = "internal";
|
this.editorDiv.className = "internal";
|
||||||
|
|
||||||
this.editorDiv.setAttribute("id", this.#editorDivId);
|
this.editorDiv.setAttribute("id", this.#editorDivId);
|
||||||
this.editorDiv.setAttribute("data-l10n-id", "pdfjs-free-text");
|
this.editorDiv.setAttribute("data-l10n-id", "pdfjs-free-text2");
|
||||||
|
this.editorDiv.setAttribute("data-l10n-attrs", "default-content");
|
||||||
this.enableEditing();
|
this.enableEditing();
|
||||||
|
|
||||||
AnnotationEditor._l10nPromise
|
|
||||||
.get("pdfjs-free-text-default-content")
|
|
||||||
.then(msg => this.editorDiv?.setAttribute("default-content", msg));
|
|
||||||
this.editorDiv.contentEditable = true;
|
this.editorDiv.contentEditable = true;
|
||||||
|
|
||||||
const { style } = this.editorDiv;
|
const { style } = this.editorDiv;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user