1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-19 22:58:07 +02:00

Move the metric-locale check into PDFDocumentProperties.#parsePageSize

With the introduction of Fluent the `getLanguage`-method became synchronous, hence it no longer seems necessary to do the metric-locale check eagerly in the constructor and it can instead be "delayed" until actually needed.
This commit is contained in:
Jonas Jenwald 2024-08-29 12:57:57 +02:00
parent a6e54160cc
commit 39ac3ef1a6

View file

@ -87,8 +87,6 @@ class PDFDocumentProperties {
eventBus._on("rotationchanging", evt => {
this._pagesRotation = evt.pagesRotation;
});
this._isNonMetricLocale = NON_METRIC_LOCALES.includes(l10n.getLanguage());
}
/**
@ -251,7 +249,8 @@ class PDFDocumentProperties {
height: pageSizeInches.width,
};
}
const isPortrait = isPortraitOrientation(pageSizeInches);
const isPortrait = isPortraitOrientation(pageSizeInches),
nonMetric = NON_METRIC_LOCALES.includes(this.l10n.getLanguage());
let sizeInches = {
width: Math.round(pageSizeInches.width * 100) / 100,
@ -305,9 +304,9 @@ class PDFDocumentProperties {
}
const [{ width, height }, unit, name, orientation] = await Promise.all([
this._isNonMetricLocale ? sizeInches : sizeMillimeters,
nonMetric ? sizeInches : sizeMillimeters,
this.l10n.get(
this._isNonMetricLocale
nonMetric
? "pdfjs-document-properties-page-size-unit-inches"
: "pdfjs-document-properties-page-size-unit-millimeters"
),