Reduce the duplication for the document_properties_page_size_* strings, by defining the units separately

This commit is contained in:
Jonas Jenwald 2018-03-20 13:30:55 +01:00
parent 77d025dc14
commit b7b5d93231
3 changed files with 31 additions and 26 deletions

View File

@ -90,12 +90,12 @@ document_properties_producer=PDF Producer:
document_properties_version=PDF Version: document_properties_version=PDF Version:
document_properties_page_count=Page Count: document_properties_page_count=Page Count:
document_properties_page_size=Page Size: document_properties_page_size=Page Size:
# LOCALIZATION NOTE (document_properties_page_size_in_2): "{{width}}" and "{{height}}" document_properties_page_size_unit_inches=in
# will be replaced by the size of the (current) page, in inches. document_properties_page_size_unit_millimeters=mm
document_properties_page_size_in_2={{width}} × {{height}} in # LOCALIZATION NOTE (document_properties_page_size_dimension_string):
# LOCALIZATION NOTE (document_properties_page_size_mm_2): "{{width}}" and "{{height}}" # "{{width}}", "{{height}}", and {{unit}} will be replaced by the size,
# will be replaced by the size of the (current) page, in millimeters. # respectively their unit of measurement, of the (current) page.
document_properties_page_size_mm_2={{width}} × {{height}} mm document_properties_page_size_dimension_string={{width}} × {{height}} {{unit}}
document_properties_close=Close document_properties_close=Close
print_progress_message=Preparing document for printing… print_progress_message=Preparing document for printing…

View File

@ -90,12 +90,12 @@ document_properties_producer=PDF-producent:
document_properties_version=PDF-version: document_properties_version=PDF-version:
document_properties_page_count=Sidantal: document_properties_page_count=Sidantal:
document_properties_page_size=Sidstorlek: document_properties_page_size=Sidstorlek:
# LOCALIZATION NOTE (document_properties_page_size_in_2): "{{width}}" and "{{height}}" document_properties_page_size_unit_inches=tum
# will be replaced by the size of the (current) page, in inches. document_properties_page_size_unit_millimeters=mm
document_properties_page_size_in_2={{width}} × {{height}} tum # LOCALIZATION NOTE (document_properties_page_size_dimension_string):
# LOCALIZATION NOTE (document_properties_page_size_mm_2): "{{width}}" and "{{height}}" # "{{width}}", "{{height}}", and {{unit}} will be replaced by the size,
# will be replaced by the size of the (current) page, in millimeters. # respectively their unit of measurement, of the (current) page.
document_properties_page_size_mm_2={{width}} × {{height}} mm document_properties_page_size_dimension_string={{width}} × {{height}} {{unit}}
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…

View File

@ -247,20 +247,25 @@ class PDFDocumentProperties {
const { width, height, } = pageSizeInches; const { width, height, } = pageSizeInches;
return Promise.all([ return Promise.all([
this.l10n.get('document_properties_page_size_in_2', { this.l10n.get('document_properties_page_size_unit_inches', null, 'in'),
width: (Math.round(width * 100) / 100).toLocaleString(), this.l10n.get('document_properties_page_size_unit_millimeters', null,
height: (Math.round(height * 100) / 100).toLocaleString(), 'mm'),
}, '{{width}} × {{height}} in'), ]).then(([unitInches, unitMillimeters]) => {
// 1in = 25.4mm; no need to round to 2 decimals for millimeters. return Promise.all([
this.l10n.get('document_properties_page_size_mm_2', { this.l10n.get('document_properties_page_size_dimension_string', {
width: (Math.round(width * 25.4 * 10) / 10).toLocaleString(), width: (Math.round(width * 100) / 100).toLocaleString(),
height: (Math.round(height * 25.4 * 10) / 10).toLocaleString(), height: (Math.round(height * 100) / 100).toLocaleString(),
}, '{{width}} × {{height}} mm'), unit: unitInches,
]).then((sizes) => { }, '{{width}} × {{height}} {{unit}}'),
return { // 1in == 25.4mm; no need to round to 2 decimals for millimeters.
inch: sizes[0], this.l10n.get('document_properties_page_size_dimension_string', {
mm: sizes[1], width: (Math.round(width * 25.4 * 10) / 10).toLocaleString(),
}; height: (Math.round(height * 25.4 * 10) / 10).toLocaleString(),
unit: unitMillimeters,
}, '{{width}} × {{height}} {{unit}}'),
]);
}).then((sizes) => {
return { inch: sizes[0], mm: sizes[1], };
}); });
} }