mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-07 17:05:38 +02:00
Merge pull request #18638 from Snuffleupagus/PDFDocumentProperties-l10n-functions
Utilize Fluent to format numbers and dates in `PDFDocumentProperties`/`AnnotationLayer`
This commit is contained in:
commit
cd99be0aa5
3 changed files with 22 additions and 42 deletions
|
@ -113,14 +113,14 @@ pdfjs-document-properties-file-name = File name:
|
||||||
pdfjs-document-properties-file-size = File size:
|
pdfjs-document-properties-file-size = File size:
|
||||||
|
|
||||||
# Variables:
|
# Variables:
|
||||||
# $size_kb (Number) - the PDF file size in kilobytes
|
# $kb (Number) - the PDF file size in kilobytes
|
||||||
# $size_b (Number) - the PDF file size in bytes
|
# $b (Number) - the PDF file size in bytes
|
||||||
pdfjs-document-properties-kb = { $size_kb } KB ({ $size_b } bytes)
|
pdfjs-document-properties-size-kb = { NUMBER($kb, maximumSignificantDigits: 3) } KB ({ $b } bytes)
|
||||||
|
|
||||||
# Variables:
|
# Variables:
|
||||||
# $size_mb (Number) - the PDF file size in megabytes
|
# $mb (Number) - the PDF file size in megabytes
|
||||||
# $size_b (Number) - the PDF file size in bytes
|
# $b (Number) - the PDF file size in bytes
|
||||||
pdfjs-document-properties-mb = { $size_mb } MB ({ $size_b } bytes)
|
pdfjs-document-properties-size-mb = { NUMBER($mb, maximumSignificantDigits: 3) } MB ({ $b } bytes)
|
||||||
|
|
||||||
pdfjs-document-properties-title = Title:
|
pdfjs-document-properties-title = Title:
|
||||||
pdfjs-document-properties-author = Author:
|
pdfjs-document-properties-author = Author:
|
||||||
|
@ -130,9 +130,8 @@ pdfjs-document-properties-creation-date = Creation Date:
|
||||||
pdfjs-document-properties-modification-date = Modification Date:
|
pdfjs-document-properties-modification-date = Modification Date:
|
||||||
|
|
||||||
# Variables:
|
# Variables:
|
||||||
# $date (Date) - the creation/modification date of the PDF file
|
# $dateObj (Date) - the creation/modification date and time of the PDF file
|
||||||
# $time (Time) - the creation/modification time of the PDF file
|
pdfjs-document-properties-date-time-string = { DATETIME($dateObj, dateStyle: "short", timeStyle: "medium") }
|
||||||
pdfjs-document-properties-date-string = { $date }, { $time }
|
|
||||||
|
|
||||||
pdfjs-document-properties-creator = Creator:
|
pdfjs-document-properties-creator = Creator:
|
||||||
pdfjs-document-properties-producer = PDF Producer:
|
pdfjs-document-properties-producer = PDF Producer:
|
||||||
|
@ -284,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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -239,17 +239,12 @@ class PDFDocumentProperties {
|
||||||
return this.l10n.get(`pdfjs-document-properties-${id}`, args);
|
return this.l10n.get(`pdfjs-document-properties-${id}`, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
async #parseFileSize(fileSize = 0) {
|
async #parseFileSize(b = 0) {
|
||||||
const kb = fileSize / 1024,
|
const kb = b / 1024,
|
||||||
mb = kb / 1024;
|
mb = kb / 1024;
|
||||||
if (!kb) {
|
return kb
|
||||||
return undefined;
|
? this.#getL10nStr(`size-${mb >= 1 ? "mb" : "kb"}`, { mb, kb, b })
|
||||||
}
|
: undefined;
|
||||||
return this.#getL10nStr(mb >= 1 ? "mb" : "kb", {
|
|
||||||
size_mb: mb >= 1 && (+mb.toPrecision(3)).toLocaleString(),
|
|
||||||
size_kb: mb < 1 && (+kb.toPrecision(3)).toLocaleString(),
|
|
||||||
size_b: fileSize.toLocaleString(),
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async #parsePageSize(pageSizeInches, pagesRotation) {
|
async #parsePageSize(pageSizeInches, pagesRotation) {
|
||||||
|
@ -329,25 +324,15 @@ class PDFDocumentProperties {
|
||||||
|
|
||||||
return this.#getL10nStr(
|
return this.#getL10nStr(
|
||||||
`page-size-dimension-${name ? "name-" : ""}string`,
|
`page-size-dimension-${name ? "name-" : ""}string`,
|
||||||
{
|
{ width, height, unit, name, orientation }
|
||||||
width: width.toLocaleString(),
|
|
||||||
height: height.toLocaleString(),
|
|
||||||
unit,
|
|
||||||
name,
|
|
||||||
orientation,
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async #parseDate(inputDate) {
|
async #parseDate(inputDate) {
|
||||||
const dateObject = PDFDateString.toDateObject(inputDate);
|
const dateObj = PDFDateString.toDateObject(inputDate);
|
||||||
if (!dateObject) {
|
return dateObj
|
||||||
return undefined;
|
? this.#getL10nStr("date-time-string", { dateObj })
|
||||||
}
|
: undefined;
|
||||||
return this.#getL10nStr("date-string", {
|
|
||||||
date: dateObject.toLocaleDateString(),
|
|
||||||
time: dateObject.toLocaleTimeString(),
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#parseLinearization(isLinearized) {
|
#parseLinearization(isLinearized) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue