mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-07 17:05:38 +02:00
Utilize Fluent to format dates in the AnnotationLayer
The `AnnotationLayer` may not display correctly formatted data in PopupAnnotations, especially in the GENERIC viewer, since it's using native methods[1] that depend on the *browser* locale instead of the viewer locale as intended. With Fluent we're able to improve things since it's got built-in support for formatting dates. Not only does this simplify the JavaScript code slightly, but it also gives the localizer more fine-grained control of the desired output. Please find additional information here: - https://projectfluent.org/fluent/guide/builtins.html - https://projectfluent.org/fluent/guide/functions.html --- [1] `toLocaleDateString`, and `toLocaleTimeString`.
This commit is contained in:
parent
d96558836e
commit
6ce9f97943
2 changed files with 4 additions and 8 deletions
|
@ -283,9 +283,8 @@ pdfjs-rendering-error = An error occurred while rendering the page.
|
||||||
## Annotations
|
## Annotations
|
||||||
|
|
||||||
# Variables:
|
# Variables:
|
||||||
# $date (Date) - the modification date of the annotation
|
# $dateObj (Date) - the modification date and time of the annotation
|
||||||
# $time (Time) - the modification time of the annotation
|
pdfjs-annotation-date-time-string = { DATETIME($dateObj, dateStyle: "short", timeStyle: "medium") }
|
||||||
pdfjs-annotation-date-string = { $date }, { $time }
|
|
||||||
|
|
||||||
# .alt: This is used as a tooltip.
|
# .alt: This is used as a tooltip.
|
||||||
# Variables:
|
# Variables:
|
||||||
|
|
|
@ -2242,14 +2242,11 @@ class PopupElement {
|
||||||
modificationDate.classList.add("popupDate");
|
modificationDate.classList.add("popupDate");
|
||||||
modificationDate.setAttribute(
|
modificationDate.setAttribute(
|
||||||
"data-l10n-id",
|
"data-l10n-id",
|
||||||
"pdfjs-annotation-date-string"
|
"pdfjs-annotation-date-time-string"
|
||||||
);
|
);
|
||||||
modificationDate.setAttribute(
|
modificationDate.setAttribute(
|
||||||
"data-l10n-args",
|
"data-l10n-args",
|
||||||
JSON.stringify({
|
JSON.stringify({ dateObj: this.#dateObj.valueOf() })
|
||||||
date: this.#dateObj.toLocaleDateString(),
|
|
||||||
time: this.#dateObj.toLocaleTimeString(),
|
|
||||||
})
|
|
||||||
);
|
);
|
||||||
header.append(modificationDate);
|
header.append(modificationDate);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue