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
@ -283,9 +283,8 @@ pdfjs-rendering-error = An error occurred while rendering the page.
|
||||
## Annotations
|
||||
|
||||
# Variables:
|
||||
# $date (Date) - the modification date of the annotation
|
||||
# $time (Time) - the modification time of the annotation
|
||||
pdfjs-annotation-date-string = { $date }, { $time }
|
||||
# $dateObj (Date) - the modification date and time of the annotation
|
||||
pdfjs-annotation-date-time-string = { DATETIME($dateObj, dateStyle: "short", timeStyle: "medium") }
|
||||
|
||||
# .alt: This is used as a tooltip.
|
||||
# Variables:
|
||||
|
||||
@ -2242,14 +2242,11 @@ class PopupElement {
|
||||
modificationDate.classList.add("popupDate");
|
||||
modificationDate.setAttribute(
|
||||
"data-l10n-id",
|
||||
"pdfjs-annotation-date-string"
|
||||
"pdfjs-annotation-date-time-string"
|
||||
);
|
||||
modificationDate.setAttribute(
|
||||
"data-l10n-args",
|
||||
JSON.stringify({
|
||||
date: this.#dateObj.toLocaleDateString(),
|
||||
time: this.#dateObj.toLocaleTimeString(),
|
||||
})
|
||||
JSON.stringify({ dateObj: this.#dateObj.valueOf() })
|
||||
);
|
||||
header.append(modificationDate);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user