Display the names, for a couple of standard page sizes, in the document properties dialog
Please note that this patch *purposely* doesn't add every standard (or semi-standard) page name in existence, but rather only a few common ones. This is done to lessen the burden on localizers, since it's quite possible that all of the page names could need translation (depending on locale). It's easy to add more standard page sizes in the future, but we should take care to *only* add those that are very commonly used in actual PDF files.
This commit is contained in:
parent
fc0038d609
commit
d86b816c2b
@ -94,10 +94,18 @@ document_properties_page_size_unit_inches=in
|
|||||||
document_properties_page_size_unit_millimeters=mm
|
document_properties_page_size_unit_millimeters=mm
|
||||||
document_properties_page_size_orientation_portrait=portrait
|
document_properties_page_size_orientation_portrait=portrait
|
||||||
document_properties_page_size_orientation_landscape=landscape
|
document_properties_page_size_orientation_landscape=landscape
|
||||||
|
document_properties_page_size_name_a3=A3
|
||||||
|
document_properties_page_size_name_a4=A4
|
||||||
|
document_properties_page_size_name_letter=Letter
|
||||||
|
document_properties_page_size_name_legal=Legal
|
||||||
# LOCALIZATION NOTE (document_properties_page_size_dimension_string):
|
# LOCALIZATION NOTE (document_properties_page_size_dimension_string):
|
||||||
# "{{width}}", "{{height}}", {{unit}}, and {{orientation}} will be replaced by
|
# "{{width}}", "{{height}}", {{unit}}, and {{orientation}} will be replaced by
|
||||||
# the size, respectively their unit of measurement and orientation, of the (current) page.
|
# the size, respectively their unit of measurement and orientation, of the (current) page.
|
||||||
document_properties_page_size_dimension_string={{width}} × {{height}} {{unit}} ({{orientation}})
|
document_properties_page_size_dimension_string={{width}} × {{height}} {{unit}} ({{orientation}})
|
||||||
|
# LOCALIZATION NOTE (document_properties_page_size_dimension_name_string):
|
||||||
|
# "{{width}}", "{{height}}", {{unit}}, {{name}}, and {{orientation}} will be replaced by
|
||||||
|
# the size, respectively their unit of measurement, name, and orientation, of the (current) page.
|
||||||
|
document_properties_page_size_dimension_name_string={{width}} × {{height}} {{unit}} ({{name}}, {{orientation}})
|
||||||
document_properties_close=Close
|
document_properties_close=Close
|
||||||
|
|
||||||
print_progress_message=Preparing document for printing…
|
print_progress_message=Preparing document for printing…
|
||||||
|
@ -94,10 +94,18 @@ document_properties_page_size_unit_inches=tum
|
|||||||
document_properties_page_size_unit_millimeters=mm
|
document_properties_page_size_unit_millimeters=mm
|
||||||
document_properties_page_size_orientation_portrait=stående
|
document_properties_page_size_orientation_portrait=stående
|
||||||
document_properties_page_size_orientation_landscape=liggande
|
document_properties_page_size_orientation_landscape=liggande
|
||||||
|
document_properties_page_size_name_a3=A3
|
||||||
|
document_properties_page_size_name_a4=A4
|
||||||
|
document_properties_page_size_name_letter=Letter
|
||||||
|
document_properties_page_size_name_legal=Legal
|
||||||
# LOCALIZATION NOTE (document_properties_page_size_dimension_string):
|
# LOCALIZATION NOTE (document_properties_page_size_dimension_string):
|
||||||
# "{{width}}", "{{height}}", {{unit}}, and {{orientation}} will be replaced by
|
# "{{width}}", "{{height}}", {{unit}}, and {{orientation}} will be replaced by
|
||||||
# the size, respectively their unit of measurement and orientation, of the (current) page.
|
# the size, respectively their unit of measurement and orientation, of the (current) page.
|
||||||
document_properties_page_size_dimension_string={{width}} × {{height}} {{unit}} ({{orientation}})
|
document_properties_page_size_dimension_string={{width}} × {{height}} {{unit}} ({{orientation}})
|
||||||
|
# LOCALIZATION NOTE (document_properties_page_size_dimension_name_string):
|
||||||
|
# "{{width}}", "{{height}}", {{unit}}, {{name}}, and {{orientation}} will be replaced by
|
||||||
|
# the size, respectively their unit of measurement, name, and orientation, of the (current) page.
|
||||||
|
document_properties_page_size_dimension_name_string={{width}} × {{height}} {{unit}} ({{name}}, {{orientation}})
|
||||||
document_properties_close=Stäng
|
document_properties_close=Stäng
|
||||||
|
|
||||||
print_progress_message=Förbereder sidor för utskrift…
|
print_progress_message=Förbereder sidor för utskrift…
|
||||||
|
@ -24,6 +24,24 @@ const DEFAULT_FIELD_CONTENT = '-';
|
|||||||
// See https://en.wikibooks.org/wiki/Lentis/Conversion_to_the_Metric_Standard_in_the_United_States
|
// See https://en.wikibooks.org/wiki/Lentis/Conversion_to_the_Metric_Standard_in_the_United_States
|
||||||
const NON_METRIC_LOCALES = ['en-us', 'en-lr', 'my'];
|
const NON_METRIC_LOCALES = ['en-us', 'en-lr', 'my'];
|
||||||
|
|
||||||
|
// Should use the format: `width x height`, in portrait orientation.
|
||||||
|
// See https://en.wikipedia.org/wiki/Paper_size
|
||||||
|
const US_PAGE_NAMES = {
|
||||||
|
'8.5x11': 'Letter',
|
||||||
|
'8.5x14': 'Legal',
|
||||||
|
};
|
||||||
|
const METRIC_PAGE_NAMES = {
|
||||||
|
'297x420': 'A3',
|
||||||
|
'210x297': 'A4',
|
||||||
|
};
|
||||||
|
|
||||||
|
function getPageName(size, isPortrait, pageNames) {
|
||||||
|
const width = (isPortrait ? size.width : size.height);
|
||||||
|
const height = (isPortrait ? size.height : size.width);
|
||||||
|
|
||||||
|
return pageNames[`${width}x${height}`];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {Object} PDFDocumentPropertiesOptions
|
* @typedef {Object} PDFDocumentPropertiesOptions
|
||||||
* @property {string} overlayName - Name/identifier for the overlay.
|
* @property {string} overlayName - Name/identifier for the overlay.
|
||||||
@ -279,21 +297,33 @@ class PDFDocumentProperties {
|
|||||||
height: Math.round(pageSizeInches.height * 25.4 * 10) / 10,
|
height: Math.round(pageSizeInches.height * 25.4 * 10) / 10,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let pageName = null;
|
||||||
|
const name = getPageName(sizeInches, isPortrait, US_PAGE_NAMES) ||
|
||||||
|
getPageName(sizeMillimeters, isPortrait, METRIC_PAGE_NAMES);
|
||||||
|
if (name) {
|
||||||
|
pageName = this.l10n.get('document_properties_page_size_name_' +
|
||||||
|
name.toLowerCase(), null, name);
|
||||||
|
}
|
||||||
|
|
||||||
return Promise.all([
|
return Promise.all([
|
||||||
(this._isNonMetricLocale ? sizeInches : sizeMillimeters),
|
(this._isNonMetricLocale ? sizeInches : sizeMillimeters),
|
||||||
this.l10n.get('document_properties_page_size_unit_' +
|
this.l10n.get('document_properties_page_size_unit_' +
|
||||||
(this._isNonMetricLocale ? 'inches' : 'millimeters'), null,
|
(this._isNonMetricLocale ? 'inches' : 'millimeters'), null,
|
||||||
this._isNonMetricLocale ? 'in' : 'mm'),
|
this._isNonMetricLocale ? 'in' : 'mm'),
|
||||||
|
pageName,
|
||||||
this.l10n.get('document_properties_page_size_orientation_' +
|
this.l10n.get('document_properties_page_size_orientation_' +
|
||||||
(isPortrait ? 'portrait' : 'landscape'), null,
|
(isPortrait ? 'portrait' : 'landscape'), null,
|
||||||
isPortrait ? 'portrait' : 'landscape'),
|
isPortrait ? 'portrait' : 'landscape'),
|
||||||
]).then(([{ width, height, }, unit, orientation]) => {
|
]).then(([{ width, height, }, unit, name, orientation]) => {
|
||||||
return this.l10n.get('document_properties_page_size_dimension_string', {
|
return this.l10n.get('document_properties_page_size_dimension_' +
|
||||||
|
(name ? 'name_' : '') + 'string', {
|
||||||
width: width.toLocaleString(),
|
width: width.toLocaleString(),
|
||||||
height: height.toLocaleString(),
|
height: height.toLocaleString(),
|
||||||
unit,
|
unit,
|
||||||
|
name,
|
||||||
orientation,
|
orientation,
|
||||||
}, '{{width}} × {{height}} {{unit}} ({{orientation}})');
|
}, '{{width}} × {{height}} {{unit}} (' +
|
||||||
|
(name ? '{{name}}, ' : '') + '{{orientation}})');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user