mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +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
|
@ -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…
Add table
Add a link
Reference in a new issue