use super::{has_cyrillic, is_opaque_option, split_words};
pub(super) fn feature(name: &str, driver_label: &str) -> String {
feature_name(name)
.map(str::to_owned)
.or_else(|| driver_english(driver_label))
.unwrap_or_else(|| humanize(name))
}
pub(super) fn option(feature: &str, name: &str, driver_label: &str) -> String {
contextual_option(feature, name)
.or_else(|| option_name(name))
.or_else(|| translated_driver_option(driver_label))
.map(str::to_owned)
.or_else(|| driver_english(driver_label))
.unwrap_or_else(|| {
if is_opaque_option(name) {
format!("Option {}", &name[1..])
} else {
humanize(name)
}
})
}
pub(super) fn parameter(name: &str, driver_label: &str) -> String {
parameter_name(name)
.map(str::to_owned)
.or_else(|| driver_english(driver_label))
.unwrap_or_else(|| humanize(name))
}
fn contextual_option(feature: &str, name: &str) -> Option<&'static str> {
Some(match (feature, name) {
("JobPageOrder", "Standard") => "Standard (1, 2, 3)",
("JobPageOrder", "Reverse") => "Reverse (3, 2, 1)",
("PresentationDirection", "RightBottom") => "Left to right, then down",
("PresentationDirection", "BottomRight") => "Top to bottom, then right",
("PresentationDirection", "LeftBottom") => "Right to left, then down",
("PresentationDirection", "BottomLeft") => "Top to bottom, then left",
("PresentationDirection", "RightTop") => "Left to right, then up",
("PageDefaultSource" | "PageInputBin", "AUTO") => "Auto select",
("PageMediaType", "OFF") => "Unspecified",
("PageMediaType", "NORMAL") => "Plain paper",
("PageMediaType", "THICK") => "Thick paper (90–120 g/m²)",
("PageMediaType", "THIN") => "Thin paper (60–69 g/m²)",
("PageMediaType", "BOND") => "Bond paper",
("PageMediaType", "COLOR") => "Colored paper",
("PageMediaType", "CARD") => "Cardstock (121–163 g/m²)",
("PageMediaType", "LABEL") => "Labels",
("PageMediaType", "ENV") => "Envelope",
("PageMediaType", "USED") => "Preprinted paper",
("PageMediaType", "RECYCLED") => "Recycled paper",
("PageResolution", "1_600x600_dpi") => "Standard",
("PageResolution", "0_1200x1200_dpi") => "High resolution",
_ => return None,
})
}
fn feature_name(name: &str) -> Option<&'static str> {
Some(match name {
"DocumentColorAdjust" => "Color adjustment",
"UsePreferredColor" => "Preferred colors",
"PageOutputColor" => "Color mode",
"DocumentBlackOptimization" => "Black optimization",
"DocumentFirstPageColorOnly" => "Color first page only",
"DocumentCmykColorPreservation" => "Preserve CMYK colors",
"DocumentCollate" => "Collate",
"DocumentDarkenText" => "Clear text",
"JobDuplexPrinterDefault" => "Duplex printer default",
"JobDuplexAllDocumentsContiguously" => "Double-sided printing",
"DocumentDuplexReverse" => "Reverse duplex printing",
"DocumentDuplexIgnoreOrientation" => "Ignore orientation for duplex printing",
"DocumentPreventPopup" => "Suppress driver popups",
"DocumentFirstPageInputBin" => "First-page paper source",
"JobHighAltitude" => "Altitude correction",
"DocumentBinding" => "Binding",
"DocumentNUp" => "Pages per sheet",
"PresentationDirection" => "Presentation direction",
"PageBorder" => "Page border",
"PageScaling" | "ScalingOptions" => "Scaling",
"ScaleOffsetAlignment" => "Scale offset alignment",
"PageOrientation" => "Orientation",
"DocumentOverlay" | "DocumentDeviceOverlay" => "Overlay",
"ConfirmPrintOverlay" => "Confirm overlay printing",
"PageRange1" => "Page range 1",
"PageRange2" => "Page range 2",
"PageMediaSize" => "Paper size",
"PageDefaultSource" | "PageInputBin" => "Paper source",
"PageMediaType" => "Paper type",
"JobPreviewLayout" => "Preview units",
"DocumentAllTextToBlack" => "Print all text in black",
"JobPageOrder" => "Page order",
"PageResolution" | "PageIResolution" => "Print quality",
"DocumentTonerSave" => "Toner saving",
"PageWatermark" => "Watermark",
"TransparencyType" => "Watermark placement",
"Layering" => "Watermark layer",
"PageApply" => "Apply to",
"DrawPerSide" => "Draw on each side",
"Type" => "Content type",
"Alignment" => "Alignment",
"HeaderFooter" => "Headers and footers",
"LeftHeader" => "Left header",
"CenterHeader" => "Center header",
"RightHeader" => "Right header",
"LeftFooter" => "Left footer",
"CenterFooter" => "Center footer",
"RightFooter" => "Right footer",
"DocumentSkipBlankPages" => "Skip blank pages",
"DocumentFineEdge" => "Edge enhancement",
"JobAutoConfiguration" => "Automatic configuration",
_ => return None,
})
}
fn option_name(name: &str) -> Option<&'static str> {
Some(match name {
"Auto" | "AUTO" => "Auto",
"AutoSelect" => "Auto select",
"Manual" => "Manual",
"On" => "On",
"Off" | "OFF" => "Off",
"None" | "NoOverlay" => "None",
"Grayscale" => "Grayscale",
"Collated" => "Collated",
"Uncollated" => "Uncollated",
"Minimum" => "Minimum",
"Maximum" => "Maximum",
"OneSided" => "One-sided",
"TwoSidedLongEdge" => "Long-edge binding",
"TwoSidedShortEdge" => "Short-edge binding",
"MPTray" => "Multipurpose tray",
"Normal" => "Normal",
"HIGH_a32_1" => "Altitude 1",
"HIGH_a32_2" => "Altitude 2",
"HIGH_a32_3" => "Altitude 3",
"Booklet" => "Booklet",
"SolidLine" => "Solid line",
"DashedLine" => "Dashed line",
"DottedLine" => "Dotted line",
"ChainLine" => "Dash-dot line",
"ChainDoubleDashedLine" => "Double dash-dot line",
"3DimensionalLine" => "3D line",
"Transparent" => "Transparent",
"DoubleSolidLine" => "Double solid line",
"CropMarks" => "Crop marks",
"CornerMarks" => "Corner marks",
"CustomSquare" => "Custom scale",
"FitToPage" => "Fit to page",
"BottomCenter" => "Bottom center",
"Center" => "Center",
"LeftCenter" => "Center left",
"RightCenter" => "Center right",
"TopCenter" => "Top center",
"TopLeft" => "Top left",
"TopRight" => "Top right",
"Landscape" => "Landscape",
"Portrait" => "Portrait",
"ReverseLandscape" => "Reverse landscape",
"ReversePortrait" => "Reverse portrait",
"LoadOverlay" => "Use overlay",
"CreateOverlay" => "Create overlay",
"AllPages" | "AllPage" => "All pages",
"FirstPage" => "First page",
"FirstPageOnly" => "First page only",
"AllExceptFirstPages" => "All except first page",
"OddPages" => "Odd pages",
"EvenPages" => "Even pages",
"FrontPages" => "Front pages",
"BackPages" => "Back pages",
"ISOC5Envelope" => "C5 envelope",
"ISOC4Envelope" => "C4 envelope",
"ISODLEnvelope" => "DL envelope",
"NorthAmericaNumber10Envelope" => "No. 10 envelope",
"NorthAmericaMonarchEnvelope" => "Monarch envelope",
"CustomMediaSize" => "Custom size",
"Millimeter" => "Millimeters",
"Inch" => "Inches",
"PageIResolutionValue" => "Resolution value",
"Text" => "Text",
"Underlying" | "Underlay" => "Below content",
"Floating" | "Overlay" => "Above content",
"Date" => "Date",
"LogonName" => "User name",
"JobAccountingName" => "Job account name",
"ImageTemplate" => "Image template",
"Image" => "Image",
"Top" => "Top",
"Left" => "Left",
"Right" => "Right",
"BottomLeft" => "Bottom left",
"Bottom" => "Bottom",
"BottomRight" => "Bottom right",
"Options" => "Options",
"ShortDate" => "Short date",
"LongDate" => "Long date",
"ShortTime" => "Short time",
"LongTime" => "Long time",
"PageNumber" => "Page number",
"ComputerName" => "Computer name",
_ => return None,
})
}
fn translated_driver_option(label: &str) -> Option<&'static str> {
Some(match label.trim() {
"Авто" => "Auto",
"Автовыбор" | "Автоматический выбор" => "Auto select",
"Вручную" => "Manual",
"Вкл." | "Включено" => "On",
"Выкл." | "Выключено" => "Off",
"Да" => "Yes",
"Нет" => "None",
"Стандартный" => "Standard",
"Высокое разрешение" => "High resolution",
"Обычный" => "Normal",
"Оттенки серого" => "Grayscale",
"По копиям" => "Collated",
"По страницам" => "Uncollated",
"Минимум" => "Minimum",
"Максимум" => "Maximum",
"Односторонняя" => "One-sided",
"По длинной кромке" => "Long-edge binding",
"По короткой кромке" => "Short-edge binding",
"Универсальный лоток" => "Multipurpose tray",
"Высота 1" => "Altitude 1",
"Высота 2" => "Altitude 2",
"Высота 3" => "Altitude 3",
"Брошюра" => "Booklet",
"Сплошная линия" => "Solid line",
"Штриховая линия" => "Dashed line",
"Пунктирная линия" => "Dotted line",
"Штрихпунктирная линия" => "Dash-dot line",
"Двойная штрихпунктирная линия" => "Double dash-dot line",
"Объёмная линия" => "3D line",
"Прозрачная" => "Transparent",
"Двойная сплошная линия" => "Double solid line",
"Метки обрезки" => "Crop marks",
"Угловые метки" => "Corner marks",
"Пользовательский масштаб" => "Custom scale",
"По размеру страницы" => "Fit to page",
"Снизу по центру" => "Bottom center",
"По центру" => "Center",
"Слева по центру" => "Center left",
"Справа по центру" => "Center right",
"Сверху по центру" => "Top center",
"Сверху слева" => "Top left",
"Сверху справа" => "Top right",
"Альбомная" => "Landscape",
"Книжная" => "Portrait",
"Обратная альбомная" => "Reverse landscape",
"Обратная книжная" => "Reverse portrait",
"Использовать наложение" => "Use overlay",
"Создать наложение" => "Create overlay",
"Все страницы" => "All pages",
"Первая страница" => "First page",
"Только первая страница" => "First page only",
"Все, кроме первой" => "All except first page",
"Нечётные страницы" => "Odd pages",
"Чётные страницы" => "Even pages",
"Лицевые стороны" => "Front pages",
"Обратные стороны" => "Back pages",
"Пользовательский размер" => "Custom size",
"Миллиметры" => "Millimeters",
"Дюймы" => "Inches",
"Значение разрешения" => "Resolution value",
"Текст" => "Text",
"Под содержимым" => "Below content",
"Над содержимым" => "Above content",
"Дата" => "Date",
"Имя пользователя" => "User name",
"Имя учётной записи задания" => "Job account name",
"Шаблон изображения" => "Image template",
"Изображение" => "Image",
"Сверху" => "Top",
"Слева" => "Left",
"Справа" => "Right",
"Снизу слева" => "Bottom left",
"Снизу" => "Bottom",
"Снизу справа" => "Bottom right",
"Параметры" => "Options",
"Короткая дата" => "Short date",
"Полная дата" => "Long date",
"Короткое время" => "Short time",
"Полное время" => "Long time",
"Номер страницы" => "Page number",
"Имя компьютера" => "Computer name",
_ => return None,
})
}
fn parameter_name(name: &str) -> Option<&'static str> {
Some(match name {
"DocumentColorAdjustBrightness" => "Brightness",
"DocumentColorAdjustContrast" => "Contrast",
"DocumentColorAdjustSaturation" => "Saturation",
"DocumentColorAdjustRedValue" => "Red",
"DocumentColorAdjustGreenValue" => "Green",
"DocumentColorAdjustBlueValue" => "Blue",
"DocumentColorAdjustPreferredColorSkin" => "Skin tones",
"DocumentColorAdjustPreferredColorGrass" => "Grass tones",
"DocumentColorAdjustPreferredColorSky" => "Sky tones",
"JobCopiesAllDocuments" => "Copies",
"PagePosterOverlapValue" => "Poster overlap",
"PageScalingOffsetWidth" => "Horizontal offset",
"PageScalingOffsetHeight" => "Vertical offset",
"PageScalingScale" => "Scale",
"PageScalingTargetMediaSizeId" => "Target paper size ID",
"PageScalingTargetMediaSizeWidth" => "Target paper width",
"PageScalingTargetMediaSizeHeight" => "Target paper height",
"PageScalingTargetMediaSizeName" => "Target paper size",
"PageScalingTargetMediaSizeXOffset" => "Horizontal margin",
"PageScalingTargetMediaSizeYOffset" => "Vertical margin",
"DocumentOverlayOverlayPath" => "Overlay file",
"PageMediaSizeMediaSizeWidth" => "Custom paper width",
"PageMediaSizeMediaSizeHeight" => "Custom paper height",
"PageIResolutionIResolution" => "Image resolution",
"PageIResolutionBPP" => "Color depth",
"PageIResolutionImageQuality" => "Image quality",
"PageWatermarkTextColor" => "Watermark color",
"PageWatermarkTextFontSize" => "Watermark font size",
"PageWatermarkTextText" => "Watermark text",
"PageWatermarkTextAngle" => "Watermark angle",
"PageWatermarkTextFontFace" => "Watermark font",
"PageWatermarkTextFontCharset" => "Font encoding",
"PageWatermarkTextFontWeight" => "Font weight",
"PageWatermarkTextFontItalic" => "Italic",
"PageWatermarkTextWatermarkName" => "Watermark name",
"PageWatermarkTextImageScale" => "Watermark scale",
"PageWatermarkTextTransparencyLevel" => "Watermark transparency",
"PageHeaderFooterOptionsFontFace" => "Header and footer font",
"PageHeaderFooterOptionsFontSize" => "Header and footer font size",
"PageHeaderFooterOptionsFontColor" => "Header and footer color",
"PageHeaderFooterOptionsFontCharset" => "Header and footer encoding",
_ => return None,
})
}
fn driver_english(label: &str) -> Option<String> {
(!label.trim().is_empty() && !has_cyrillic(label)).then(|| label.to_owned())
}
fn humanize(value: &str) -> String {
split_words(value).join(" ")
}