From 8d2c390382e6f97658ff5415aef73f33dbe90da6 Mon Sep 17 00:00:00 2001 From: Michael Pfeiffer Date: Fri, 28 May 2010 13:45:21 +0000 Subject: [PATCH] * Applied slightly modifed patch from ticket #6089 by Karvjorm. Thank you. - Added translation comment to paper sizes. - Localized scripting comments. - Improved localization of job info. - Localized parts of about dialog text. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36963 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/servers/print/ConfigWindow.cpp | 97 ++++++++++++------- src/servers/print/Jamfile | 4 +- .../print/PrintServerApp.Scripting.cpp | 29 ++++-- src/servers/print/Printer.Scripting.cpp | 35 +++++-- 4 files changed, 112 insertions(+), 53 deletions(-) diff --git a/src/servers/print/ConfigWindow.cpp b/src/servers/print/ConfigWindow.cpp index ee92552104..ebb948af26 100644 --- a/src/servers/print/ConfigWindow.cpp +++ b/src/servers/print/ConfigWindow.cpp @@ -27,6 +27,7 @@ // Haiku #include #include +#include #include #include @@ -68,18 +69,30 @@ static struct PageFormat float height; } pageFormat[] = { - {B_TRANSLATE_MARK("Letter"), letter_width, letter_height }, - {B_TRANSLATE_MARK("Legal"), legal_width, legal_height }, - {B_TRANSLATE_MARK("Ledger"), ledger_width, ledger_height }, - {B_TRANSLATE_MARK("Tabloid"), tabloid_width, tabloid_height }, - {B_TRANSLATE_MARK("A0"), a0_width, a0_height }, - {B_TRANSLATE_MARK("A1"), a1_width, a1_height }, - {B_TRANSLATE_MARK("A2"), a2_width, a2_height }, - {B_TRANSLATE_MARK("A3"), a3_width, a3_height }, - {B_TRANSLATE_MARK("A4"), a4_width, a4_height }, - {B_TRANSLATE_MARK("A5"), a5_width, a5_height }, - {B_TRANSLATE_MARK("A6"), a6_width, a6_height }, - {B_TRANSLATE_MARK("B5"), b5_width, b5_height }, + {B_TRANSLATE_MARK_COMMENT("Letter", "ANSI A (letter), a North American " + "paper size"), letter_width, letter_height }, + {B_TRANSLATE_MARK_COMMENT("Legal", "A North American paper size (216 x 356" + " mm, or 8.5 x 14 in)"), legal_width, legal_height }, + {B_TRANSLATE_MARK_COMMENT("Ledger", "ANSI B (ledger), a North American " + "paper size"), ledger_width, ledger_height }, + {B_TRANSLATE_MARK_COMMENT("Tabloid", "ANSI B (tabloid), a North American " + "paper size"), tabloid_width, tabloid_height }, + {B_TRANSLATE_MARK_COMMENT("A0", "ISO 216 paper size"), + a0_width, a0_height }, + {B_TRANSLATE_MARK_COMMENT("A1", "ISO 216 paper size"), + a1_width, a1_height }, + {B_TRANSLATE_MARK_COMMENT("A2", "ISO 216 paper size"), + a2_width, a2_height }, + {B_TRANSLATE_MARK_COMMENT("A3", "ISO 216 paper size"), + a3_width, a3_height }, + {B_TRANSLATE_MARK_COMMENT("A4", "ISO 216 paper size"), + a4_width, a4_height }, + {B_TRANSLATE_MARK_COMMENT("A5", "ISO 216 paper size"), + a5_width, a5_height }, + {B_TRANSLATE_MARK_COMMENT("A6", "ISO 216 paper size"), + a6_width, a6_height }, + {B_TRANSLATE_MARK_COMMENT("B5", "ISO 216 paper size"), + b5_width, b5_height }, }; @@ -124,7 +137,7 @@ ConfigWindow::ConfigWindow(config_setup_kind kind, Printer* defaultPrinter, { MimeTypeForSender(settings, fSenderMimeType); PrinterForMimeType(); - + if (kind == kJobSetup) SetTitle(B_TRANSLATE("Print setup")); @@ -284,20 +297,17 @@ void ConfigWindow::MessageReceived(BMessage* m) } -static const char* -kAbout = -"Printer server\n" -"© 2001-2010 Haiku, Inc.\n" -"\n" -"\tIthamar R. Adema\n" -"\tMichael Pfeiffer\n" -; - - void ConfigWindow::AboutRequested() { - BAlert *about = new BAlert("About printer server", kAbout, + BString text = B_TRANSLATE("Printer server"); + text << "\n" + "© 2001-2010 Haiku, Inc.\n" + "\n" + "\tIthamar R. Adema\n" + "\tMichael Pfeiffer\n"; + + BAlert *about = new BAlert("About printer server", text.String(), B_TRANSLATE("OK")); about->Go(); } @@ -490,26 +500,45 @@ void ConfigWindow::UpdateUI() } fPageFormatText->SetText(pageFormat.String()); - // display information about job + // display information about job if (fKind == kJobSetup) { BString job; - int32 first, last; + int32 first, last, copies; if (fJobSettings.FindInt32(PSRV_FIELD_FIRST_PAGE, &first) == B_OK && fJobSettings.FindInt32(PSRV_FIELD_LAST_PAGE, &last) == B_OK) { - if (first >= 1 && first <= last && last != INT_MAX) { - job << B_TRANSLATE("Page") << " " << first << " " << - B_TRANSLATE("to") << " " << last; - } else { - job << B_TRANSLATE("All pages"); - } - int32 copies; + + bool printRange = first >= 1 && first <= last && last != INT_MAX; + char number[12]; if (fJobSettings.FindInt32(PSRV_FIELD_COPIES, &copies) == B_OK && copies > 1) { - job << ", " << copies << " " << B_TRANSLATE("copies"); + if (printRange) { + job = B_TRANSLATE("Page %1 to %2, %3 copies"); + sprintf(number, "%d", (int)first); + job.ReplaceFirst("%1", number); + sprintf(number, "%d", (int)last); + job.ReplaceFirst("%2", number); + sprintf(number, "%d", (int)copies); + job.ReplaceFirst("%3", number); + } else { + job = B_TRANSLATE("All pages, %1 copies"); + sprintf(number, "%d", (int)copies); + job.ReplaceFirst("%1", number); + } + } else { + if (printRange) { + job = B_TRANSLATE("Page %1 to %2"); + sprintf(number, "%d", (int)first); + job.ReplaceFirst("%1", number); + sprintf(number, "%d", (int)last); + job.ReplaceFirst("%2", number); + } else { + job = B_TRANSLATE("All pages"); + } } } else { job << B_TRANSLATE("Undefined"); } + fJobSetupText->SetText(job.String()); } } diff --git a/src/servers/print/Jamfile b/src/servers/print/Jamfile index 8e435b9e83..74d648caa4 100644 --- a/src/servers/print/Jamfile +++ b/src/servers/print/Jamfile @@ -1,5 +1,7 @@ SubDir HAIKU_TOP src servers print ; +SubDirHdrs HAIKU_TOP headers os locale ; + UsePrivateHeaders shared print ; SubDirHdrs [ FDirName $(HAIKU_TOP) headers libs print libprint ] ; @@ -24,7 +26,7 @@ LinkAgainst print_server : be root translation - liblocale.so + locale libprint.a libprintutils.a $(TARGET_LIBSUPC++) diff --git a/src/servers/print/PrintServerApp.Scripting.cpp b/src/servers/print/PrintServerApp.Scripting.cpp index 0e8b0a2857..6d953689a3 100644 --- a/src/servers/print/PrintServerApp.Scripting.cpp +++ b/src/servers/print/PrintServerApp.Scripting.cpp @@ -11,28 +11,33 @@ #include "Printer.h" // BeOS API +#include +#include #include // ANSI C #include +#define B_TRANSLATE_CONTEXT "PrintServerApp Scripting" + + static property_info prop_list[] = { { "ActivePrinter", { B_GET_PROPERTY, B_SET_PROPERTY }, { B_DIRECT_SPECIFIER }, - "Retrieve or select the active printer" }, + B_TRANSLATE_MARK("Retrieve or select the active printer") }, { "Printer", { B_GET_PROPERTY }, { B_INDEX_SPECIFIER, B_NAME_SPECIFIER, B_REVERSE_INDEX_SPECIFIER }, - "Retrieve a specific printer" }, + B_TRANSLATE_MARK("Retrieve a specific printer") }, { "Printer", { B_CREATE_PROPERTY }, { B_DIRECT_SPECIFIER }, - "Create a new printer" }, + B_TRANSLATE_MARK("Create a new printer") }, { "Printer", { B_DELETE_PROPERTY }, { B_INDEX_SPECIFIER, B_NAME_SPECIFIER, B_REVERSE_INDEX_SPECIFIER }, - "Delete a specific printer" }, + B_TRANSLATE_MARK("Delete a specific printer") }, { "Printers", { B_COUNT_PROPERTIES }, { B_DIRECT_SPECIFIER }, - "Return the number of available printers" }, + B_TRANSLATE_MARK("Return the number of available printers") }, { "Transport", { B_GET_PROPERTY }, { B_INDEX_SPECIFIER, B_NAME_SPECIFIER, B_REVERSE_INDEX_SPECIFIER }, - "Retrieve a specific transport" }, + B_TRANSLATE_MARK("Retrieve a specific transport") }, { "Transports", { B_COUNT_PROPERTIES }, { B_DIRECT_SPECIFIER }, - "Return the number of available transports" }, + B_TRANSLATE_MARK("Return the number of available transports") }, { "UseConfigWindow", { B_GET_PROPERTY, B_SET_PROPERTY }, { B_DIRECT_SPECIFIER }, - "Show configuration window" }, + B_TRANSLATE_MARK("Show configuration window") }, { 0 } // terminate list }; @@ -234,6 +239,14 @@ PrintServerApp::GetSupportedSuites(BMessage* msg) { msg->AddString("suites", "suite/vnd.OpenBeOS-printserver"); + static bool localized = false; + if (!localized) { + localized = true; + for (int i = 0; prop_list[i].name != NULL; i ++) + prop_list[i].usage = be_catalog->GetString(prop_list[i].usage, + B_TRANSLATE_CONTEXT); + } + BPropertyInfo prop_info(prop_list); msg->AddFlat("messages", &prop_info); diff --git a/src/servers/print/Printer.Scripting.cpp b/src/servers/print/Printer.Scripting.cpp index 1b38ccac03..71f5f5ef4d 100644 --- a/src/servers/print/Printer.Scripting.cpp +++ b/src/servers/print/Printer.Scripting.cpp @@ -11,25 +11,32 @@ #include "pr_server.h" // BeOS API -#include -#include -#include #include +#include +#include +#include +#include +#include + + +#define B_TRANSLATE_CONTEXT "Printer Scripting" + static property_info prop_list[] = { { "Name", { B_GET_PROPERTY }, { B_DIRECT_SPECIFIER }, - "Get name of printer" }, + B_TRANSLATE_MARK("Get name of printer") }, { "TransportAddon", { B_GET_PROPERTY }, { B_DIRECT_SPECIFIER }, - "Get name of the transport add-on used for this printer" }, + B_TRANSLATE_MARK("Get name of the transport add-on used for this printer") }, { "TransportConfig", { B_GET_PROPERTY }, { B_DIRECT_SPECIFIER }, - "Get the transport configuration for this printer" }, + B_TRANSLATE_MARK("Get the transport configuration for this printer") }, { "PrinterAddon", { B_GET_PROPERTY }, { B_DIRECT_SPECIFIER }, - "Get name of the printer add-on used for this printer" }, + B_TRANSLATE_MARK("Get name of the printer add-on used for this printer") }, { "Comments", { B_GET_PROPERTY }, { B_DIRECT_SPECIFIER }, - "Get comments about this printer" }, + B_TRANSLATE_MARK("Get comments about this printer") }, { 0 } // terminate list }; + void Printer::HandleScriptingCommand(BMessage* msg) { status_t rc = B_ERROR; @@ -52,7 +59,7 @@ void Printer::HandleScriptingCommand(BMessage* msg) rc = SpoolDir()->ReadAttrString(PSRV_PRINTER_ATTR_DRV_NAME, &result); else if (propName == "Comments") rc = SpoolDir()->ReadAttrString(PSRV_PRINTER_ATTR_COMMENTS, &result); - else { // If unknown scripting request, let superclas handle it + else { // If unknown scripting request, let super class handle it Inherited::MessageReceived(msg); break; } @@ -94,7 +101,15 @@ BHandler* Printer::ResolveSpecifier(BMessage* msg, int32 index, BMessage* spec, status_t Printer::GetSupportedSuites(BMessage* msg) { msg->AddString("suites", "application/x-vnd.OpenBeOS-printer"); - + + static bool localized = false; + if (!localized) { + localized = true; + for (int i = 0; prop_list[i].name != NULL; i ++) + prop_list[i].usage = be_catalog->GetString(prop_list[i].usage, + B_TRANSLATE_CONTEXT); + } + BPropertyInfo prop_info(prop_list); msg->AddFlat("messages", &prop_info);