Support localization for annotation labels and text

Replaced hardcoded annotation labels and text with localized values, falling back to English defaults if not available. Date formatting now adapts to the current locale using getCurrentCulture().
This commit is contained in:
2026-02-16 17:33:43 +01:00
parent f175e39de2
commit 8f94317e80

View File

@@ -112,7 +112,7 @@ async function createAnnotations(document, envelopeId, receiverId) {
const formFieldDateLabel = new PSPDFKit.FormFields.TextFormField({ const formFieldDateLabel = new PSPDFKit.FormFields.TextFormField({
name: id_date_label, name: id_date_label,
annotationIds: PSPDFKit.Immutable.List([annotation_date_label.id]), annotationIds: PSPDFKit.Immutable.List([annotation_date_label.id]),
value: "Date", value: localized.date ?? "Date",
readOnly: true readOnly: true
}) })
//#endregion //#endregion
@@ -134,7 +134,7 @@ async function createAnnotations(document, envelopeId, receiverId) {
const formFieldCityLabel = new PSPDFKit.FormFields.TextFormField({ const formFieldCityLabel = new PSPDFKit.FormFields.TextFormField({
name: id_city_label, name: id_city_label,
annotationIds: PSPDFKit.Immutable.List([annotation_city_label.id]), annotationIds: PSPDFKit.Immutable.List([annotation_city_label.id]),
value: "Ort", value: localized.city ?? "City",
readOnly: true, readOnly: true,
color: PSPDFKit.Color.BLACK color: PSPDFKit.Color.BLACK
}) })
@@ -157,7 +157,7 @@ async function createAnnotations(document, envelopeId, receiverId) {
const formFieldPositionLabel = new PSPDFKit.FormFields.TextFormField({ const formFieldPositionLabel = new PSPDFKit.FormFields.TextFormField({
name: id_position_label, name: id_position_label,
annotationIds: PSPDFKit.Immutable.List([annotation_position_label.id]), annotationIds: PSPDFKit.Immutable.List([annotation_position_label.id]),
value: "Position", value: localized.position ?? "Position",
readOnly: true readOnly: true
}) })
//#endregion //#endregion
@@ -251,7 +251,7 @@ async function createAnnotationFrameBlob(receiverName, receiverSignature, timest
ctx.textRendering = "geometricPrecision" ctx.textRendering = "geometricPrecision"
const date = timestamp const date = timestamp
const dateString = date.toLocaleString('de-DE') const dateString = date.toLocaleString(getCurrentCulture())
const signatureLength = 100 * scale const signatureLength = 100 * scale
const signatureString = receiverSignature.substring(0, 15) + "…" const signatureString = receiverSignature.substring(0, 15) + "…"
@@ -275,7 +275,7 @@ async function createAnnotationFrameBlob(receiverName, receiverSignature, timest
ctx.fillStyle = 'black' ctx.fillStyle = 'black'
ctx.font = `${fontSize * scale}px sans-serif` ctx.font = `${fontSize * scale}px sans-serif`
ctx.fillText('Signed by', 15 * scale, 10 * scale) ctx.fillText(localized.signedBy ?? 'Signed by', 15 * scale, 10 * scale)
ctx.fillText(receiverName, 15 * scale, 60 * scale) ctx.fillText(receiverName, 15 * scale, 60 * scale)
ctx.fillText(signatureString, 15 * scale, 70 * scale) ctx.fillText(signatureString, 15 * scale, 70 * scale)