Ticket #5912: devicesLocalization.patch

File devicesLocalization.patch, 17.0 KB (added by Karvjorm, 12 years ago)

Third devices localization patch

  • src/apps/devices/Device.cpp

     
    99
    1010#include "Device.h"
    1111
     12#include <Catalog.h>
     13#include <Locale.h>
    1214#include <iostream>
    1315
     16#undef B_TRANSLATE_CONTEXT
     17#define B_TRANSLATE_CONTEXT "Device"
    1418
    1519// This list comes from the pciid list, except for the last one
    1620const char* kCategoryString[] = {
    17     "Unclassified device",                  // 0x00
    18     "Mass storage controller",              // 0x01
    19     "Network controller",                   // 0x02
    20     "Display controller",                   // 0x03
    21     "Multimedia controller",                // 0x04
    22     "Memory controller",                    // 0x05
    23     "Bridge",                               // 0x06
    24     "Communication controller",             // 0x07
    25     "Generic system peripheral",            // 0x08
    26     "Input device controller",              // 0x09
    27     "Docking station",                      // 0x0a
    28     "Processor",                            // 0x0b
    29     "Serial bus controller",                // 0x0c
    30     "Wireless controller",                  // 0x0d
    31     "Intelligent controller",               // 0x0e
    32     "Satellite communications controller",  // 0x0f
    33     "Encryption controller",                // 0x10
    34     "Signal processing controller",         // 0x11
    35     "Computer"                              // 0x12 (added later)
     21    B_TRANSLATE_MARK("Unclassified device"),                // 0x00
     22    B_TRANSLATE_MARK("Mass storage controller"),            // 0x01
     23    B_TRANSLATE_MARK("Network controller"),                 // 0x02
     24    B_TRANSLATE_MARK("Display controller"),                 // 0x03
     25    B_TRANSLATE_MARK("Multimedia controller"),              // 0x04
     26    B_TRANSLATE_MARK("Memory controller"),                  // 0x05
     27    B_TRANSLATE_MARK("Bridge"),                             // 0x06
     28    B_TRANSLATE_MARK("Communication controller"),           // 0x07
     29    B_TRANSLATE_MARK("Generic system peripheral"),          // 0x08
     30    B_TRANSLATE_MARK("Input device controller"),            // 0x09
     31    B_TRANSLATE_MARK("Docking station"),                    // 0x0a
     32    B_TRANSLATE_MARK("Processor"),                          // 0x0b
     33    B_TRANSLATE_MARK("Serial bus controller"),              // 0x0c
     34    B_TRANSLATE_MARK("Wireless controller"),                // 0x0d
     35    B_TRANSLATE_MARK("Intelligent controller"),             // 0x0e
     36    B_TRANSLATE_MARK("Satellite communications controller"),// 0x0f
     37    B_TRANSLATE_MARK("Encryption controller"),              // 0x10
     38    B_TRANSLATE_MARK("Signal processing controller"),       // 0x11
     39    B_TRANSLATE_MARK("Computer")                            // 0x12 (added later) 
    3640};
    3741
    3842
     
    7175Device::GetBasicAttributes()
    7276{
    7377    Attributes attributes;
    74     attributes.push_back(Attribute("Device name:", GetName()));
    75     attributes.push_back(Attribute("Manufacturer:", GetManufacturer()));
     78    BString _unknown = B_TRANSLATE("unknown");
     79    if (GetName() == "unknown")
     80        attributes.push_back(Attribute("Device name:", _unknown));
     81    else
     82        attributes.push_back(Attribute("Device name:", GetName()));
     83    if (GetManufacturer() == "unknown")
     84        attributes.push_back(Attribute("Manufacturer:", _unknown));
     85    else   
     86        attributes.push_back(Attribute("Manufacturer:", GetManufacturer()));
    7687    return attributes;
    7788}
    7889
     
    101112BString
    102113Device::GetBasicStrings()
    103114{
    104     BString str;
    105     str << "Device Name\t\t\t\t: " << GetName() << "\n";
    106     str << "Manufacturer\t\t\t: " << GetManufacturer() << "\n";
    107     str << "Driver used\t\t\t\t: " << GetDriverUsed() << "\n";
    108     str << "Device paths\t: " << GetDevPathsPublished();
     115    BString _unknown = B_TRANSLATE("unknown");
     116    BString str = B_TRANSLATE("Device Name\t\t\t\t: %1\n"
     117        "Manufacturer\t\t\t: %2\n"
     118        "Driver used\t\t\t\t: %3\n"
     119        "Device paths\t: %4\n");
     120    if (GetName() == "unknown")
     121        str.ReplaceFirst("%1", _unknown);
     122    else
     123        str.ReplaceFirst("%1", GetName());
     124    if (GetManufacturer() == "unknown")
     125        str.ReplaceFirst("%2", _unknown);
     126    else
     127        str.ReplaceFirst("%2", GetManufacturer());
     128    if (GetDriverUsed() == "unknown")
     129        str.ReplaceFirst("%3", _unknown);
     130    else
     131        str.ReplaceFirst("%3", GetDriverUsed());
     132    if (GetDevPathsPublished() == "unknown")
     133        str.ReplaceFirst("%4", _unknown);
     134    else
     135        str.ReplaceFirst("%4", GetDevPathsPublished());
    109136    return str;
    110137}
    111138
    112139BString
    113140Device::GetBusStrings()
    114141{
    115     return "None";
     142    return B_TRANSLATE("None");
    116143}
    117144
    118145
     
    126153    }
    127154    return str;
    128155}
     156
     157
     158BString
     159Device::GetBusTabName()
     160{
     161    return B_TRANSLATE("Bus Information");
     162}
  • src/apps/devices/DevicePCI.h

     
    2020    virtual BString     GetBusStrings();
    2121    virtual void        InitFromAttributes();
    2222   
    23     virtual BString     GetBusTabName()
    24                             { return "PCI Information"; }
     23    virtual BString     GetBusTabName();
    2524
    2625private:
    2726    uint16              fClassBaseId;
  • src/apps/devices/PropertyListPlain.cpp

     
    99
    1010#include "PropertyListPlain.h"
    1111
     12#include <Catalog.h>
    1213#include <GridLayout.h>
    1314#include <GridLayoutBuilder.h>
    1415#include <GroupLayout.h>
    1516#include <GroupLayoutBuilder.h>
     17#include <Locale.h>
    1618#include <Message.h>
    1719#include <SpaceLayoutItem.h>
    1820#include <String.h>
     
    2022
    2123#include "Device.h"
    2224
     25#undef B_TRANSLATE_CONTEXT
     26#define B_TRANSLATE_CONTEXT "PropertyListPlain"
    2327
    2428PropertyListPlain::PropertyListPlain(const char* name)
    2529    :
     
    4852       
    4953        BString tempViewName(name);
    5054        BStringView *nameView = new BStringView(tempViewName.String(), name);
    51         tempViewName.Append("Value");
     55        tempViewName.Append(B_TRANSLATE("Value"));
    5256        BStringView *valueView = new BStringView(tempViewName.String(), value);
    5357
    5458        nameView->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT,
  • src/apps/devices/Device.h

     
    8686    virtual BString         GetBusStrings();
    8787    virtual BString         GetAllStrings();
    8888   
    89     virtual BString         GetBusTabName()
    90                                 { return "Bus Information"; }
     89    virtual BString         GetBusTabName();
    9190
    9291    virtual Attribute       GetAttribute(const BString& name)
    9392                                { return Attribute(name.String(),
  • src/apps/devices/DevicesApplication.cpp

     
    88
    99#include <Alert.h>
    1010#include <Application.h>
     11#include <Catalog.h>
     12#include <Locale.h>
    1113#include <TextView.h>
    1214
    1315#include "DevicesView.h"
    1416
     17#undef B_TRANSLATE_CONTEXT
     18#define B_TRANSLATE_CONTEXT "DevicesApplication"
    1519
    1620class DevicesApplication : public BApplication {
    1721public:
     
    5054void
    5155DevicesApplication::ShowAbout()
    5256{
    53     BAlert* alert = new BAlert("about", "Devices\n"
    54         "\twritten by Pieter Panman\n"
    55         "\n"
    56         "\tBased on listdev by Jérôme Duval\n"
     57    BString str1 = B_TRANSLATE("Devices\n"
     58        "\twritten by %1\n\n"
     59        "\tBased on listdev by %2\n"
    5760        "\tand the previous Devices preference\n"
    58         "\tby Jérôme Duval and Sikosis\n"
    59         "\tCopyright 2009, Haiku, Inc.\n", "OK");
     61        "\tby %3 and %4\n"
     62        "\tCopyright %5, Haiku, Inc.\n");
     63    str1.ReplaceFirst("%1", "Pieter Panman");
     64    str1.ReplaceFirst("%2", "Jérôme Duval");
     65    str1.ReplaceFirst("%3", "Jérôme Duval");
     66    str1.ReplaceFirst("%4", "Sikosis");
     67    str1.ReplaceFirst("%5", "2009");
     68    BAlert* alert = new BAlert("about", str1, B_TRANSLATE("OK"));
    6069    BTextView* view = alert->TextView();
    6170    BFont font;
    6271
     
    7382
    7483DevicesWindow::DevicesWindow()
    7584    :
    76     BWindow(BRect(50, 50, 750, 550), "Devices", B_TITLED_WINDOW,
     85    BWindow(BRect(50, 50, 750, 550), B_TRANSLATE("Devices"), B_TITLED_WINDOW,
    7786        B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS
    7887            | B_QUIT_ON_WINDOW_CLOSE)
    7988{
  • src/apps/devices/DevicesView.cpp

     
    88
    99
    1010#include <Application.h>
     11#include <Catalog.h>
     12#include <Locale.h>
    1113#include <MenuBar.h>
    1214
    1315#include <iostream>
    1416
    1517#include "DevicesView.h"
    1618
     19#undef B_TRANSLATE_CONTEXT
     20#define B_TRANSLATE_CONTEXT "DevicesView"
    1721
    1822DevicesView::DevicesView(const BRect& rect)
    1923    : BView(rect, "DevicesView", B_FOLLOW_ALL, B_WILL_DRAW | B_FRAME_EVENTS)
     
    3034    SetLayout(new BGroupLayout(B_VERTICAL));
    3135
    3236    BMenuBar* menuBar = new BMenuBar("menu");
    33     BMenu* menu = new BMenu("Devices");
     37    BMenu* menu = new BMenu(B_TRANSLATE("Devices"));
    3438    BMenuItem* item;
    35     menu->AddItem(new BMenuItem("Refresh devices", new BMessage(kMsgRefresh), 'R'));
    36     menu->AddItem(item = new BMenuItem("Report compatibility",
     39    menu->AddItem(new BMenuItem(B_TRANSLATE("Refresh devices"),
     40        new BMessage(kMsgRefresh), 'R'));
     41    menu->AddItem(item = new BMenuItem(B_TRANSLATE("Report compatibility"),
    3742        new BMessage(kMsgReportCompatibility)));
    3843    item->SetEnabled(false);
    39     menu->AddItem(item = new BMenuItem("Generate system information",
     44    menu->AddItem(item = new BMenuItem(
     45        B_TRANSLATE("Generate system information"),
    4046        new BMessage(kMsgGenerateSysInfo)));
    4147    item->SetEnabled(false);
    4248    menu->AddSeparatorItem();
    43     menu->AddItem(item = new BMenuItem("About Devices" B_UTF8_ELLIPSIS,
     49    menu->AddItem(item = new BMenuItem(
     50        B_TRANSLATE("About Devices" B_UTF8_ELLIPSIS),
    4451        new BMessage(B_ABOUT_REQUESTED)));
    4552    menu->AddSeparatorItem();
    46     menu->AddItem(new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED), 'Q'));
     53    menu->AddItem(new BMenuItem(B_TRANSLATE("Quit"),
     54        new BMessage(B_QUIT_REQUESTED), 'Q'));
    4755    menu->SetTargetForItems(this);
    4856    item->SetTarget(be_app);
    4957    menuBar->AddItem(menu);
     
    6068    // why? Bug? In scrollview or in outlinelistview?
    6169
    6270    BPopUpMenu* orderByPopupMenu = new BPopUpMenu("orderByMenu");
    63     BMenuItem* byCategory = new BMenuItem("Category",
     71    BMenuItem* byCategory = new BMenuItem(B_TRANSLATE("Category"),
    6472        new BMessage(kMsgOrderCategory));
    65     BMenuItem* byConnection = new BMenuItem("Connection",
     73    BMenuItem* byConnection = new BMenuItem(B_TRANSLATE("Connection"),
    6674        new BMessage(kMsgOrderConnection));
    6775    byCategory->SetMarked(true);
    6876    fOrderBy = byCategory->IsMarked() ? ORDER_BY_CATEGORY :
    6977        ORDER_BY_CONNECTION;
    7078    orderByPopupMenu->AddItem(byCategory);
    7179    orderByPopupMenu->AddItem(byConnection);
    72     fOrderByMenu = new BMenuField("Order by:", orderByPopupMenu);
     80    fOrderByMenu = new BMenuField(B_TRANSLATE("Order by:"), orderByPopupMenu);
    7381
    7482    fTabView = new BTabView("fTabView", B_WIDTH_FROM_LABEL);
    7583
    7684    fBasicTab = new BTab();
    7785    fBasicView = new PropertyListPlain("basicView");
    7886    fTabView->AddTab(fBasicView, fBasicTab);
    79     fBasicTab->SetLabel("Basic information");
     87    fBasicTab->SetLabel(B_TRANSLATE("Basic information"));
    8088
    8189    fDeviceTypeTab = new BTab();
    8290    fBusView = new PropertyListPlain("busView");
    8391    fTabView->AddTab(fBusView, fDeviceTypeTab);
    84     fDeviceTypeTab->SetLabel("Bus");
     92    fDeviceTypeTab->SetLabel(B_TRANSLATE("Bus"));
    8593
    8694    fDetailedTab = new BTab();
    8795    fAttributesView = new PropertyList("attributesView");
    8896    fTabView->AddTab(fAttributesView, fDetailedTab);
    89     fDetailedTab->SetLabel("Detailed");
     97    fDetailedTab->SetLabel(B_TRANSLATE("Detailed"));
    9098
    9199    AddChild(BGroupLayoutBuilder(B_VERTICAL,0)
    92100                .Add(menuBar)
     
    269277                attrString << attr.value.ui64;
    270278                break;
    271279            default:
    272                 attrString << "Raw data";
     280                attrString << B_TRANSLATE("Raw data");
    273281        }
    274282        attributes.push_back(Attribute(attr.name, attrString));
    275283    }
     
    279287        // Devices Root
    280288        if (attributes[i].fName == "device/pretty name"
    281289                && attributes[i].fValue == "Devices Root") {
    282             newDevice = new Device(parent, BUS_NONE, CAT_COMPUTER, "Computer");
     290            newDevice = new Device(parent, BUS_NONE, CAT_COMPUTER,
     291                B_TRANSLATE("Computer"));
    283292            break;
    284293        }
    285294
    286295        // PCI bus
    287296        if (attributes[i].fName == "device/pretty name"
    288297                && attributes[i].fValue == "PCI") {
    289             newDevice = new Device(parent, BUS_PCI, CAT_BUS, "PCI bus");
     298            newDevice = new Device(parent, BUS_PCI, CAT_BUS,
     299                B_TRANSLATE("PCI bus"));
    290300            break;
    291301        }
    292302
    293303        // ISA bus
    294304        if (attributes[i].fName == "device/bus"
    295305                && attributes[i].fValue == "isa") {
    296             newDevice = new Device(parent, BUS_ISA, CAT_BUS, "ISA bus");
     306            newDevice = new Device(parent, BUS_ISA, CAT_BUS,
     307                B_TRANSLATE("ISA bus"));
    297308            break;
    298309        }
    299310
     
    306317    }
    307318
    308319    if (newDevice == NULL) {
    309         newDevice = new Device(parent, BUS_NONE, CAT_NONE, "Unknown device");
     320        newDevice = new Device(parent, BUS_NONE, CAT_NONE,
     321            B_TRANSLATE("Unknown device"));
    310322    }
    311323
    312324    // Add its attributes to the device, initialize it and add to the list.
  • src/apps/devices/PropertyList.cpp

     
    99
    1010#include "PropertyList.h"
    1111
     12#include <Catalog.h>
    1213#include <ColumnTypes.h>
     14#include <Locale.h>
    1315
    1416//#include <stdio.h>
    1517
     18#undef B_TRANSLATE_CONTEXT
     19#define B_TRANSLATE_CONTEXT "PropertyList"
    1620
    1721PropertyRow::PropertyRow(const char* name, const char* value)
    1822    : BRow(),
     
    4953        B_NO_BORDER, true)
    5054{
    5155    BStringColumn* nameColumn;
    52     AddColumn(nameColumn = new BStringColumn("Name", 150, 50, 500,
    53             B_TRUNCATE_MIDDLE),
    54         kNameColumn);
    55     AddColumn(new BStringColumn("Value", 150, 50, 500, B_TRUNCATE_END),
    56         kValueColumn);
     56   
     57    SetName(B_TRANSLATE("Properties"));
     58   
     59    AddColumn(nameColumn = new BStringColumn(B_TRANSLATE("Name"), 150, 50, 500,
     60            B_TRUNCATE_MIDDLE), kNameColumn);
     61    AddColumn(new BStringColumn(B_TRANSLATE("Value"), 150, 50, 500,
     62        B_TRUNCATE_END), kValueColumn);
    5763    SetSortColumn(nameColumn, false, true);
    5864}
    5965
  • src/apps/devices/Jamfile

     
    6868    Device.cpp
    6969    PropertyList.cpp
    7070    PropertyListPlain.cpp
    71     : be libcolumnlistview.a tracker $(TARGET_LIBSUPC++) $(TARGET_LIBSTDC++)
     71    : be libcolumnlistview.a tracker $(TARGET_LIBSUPC++) $(TARGET_LIBSTDC++) $(HAIKU_LOCALE_LIBS)
    7272    : Devices.rdef
    7373;
    7474
     75DoCatalogs Devices :
     76    x-vnd.Haiku-Devices
     77    :
     78    DevicesApplication.cpp
     79    DevicesView.cpp
     80    DevicePCI.cpp
     81    PropertyList.cpp
     82    PropertyListPlain.cpp
     83;
     84
    7585Includes [ FGristFiles DevicesInfo.cpp ] : [ FGristFiles isapnpids.h usbdevs.h
    7686    usbdevs_data.h ] ;
    7787Includes [ FGristFiles ConfigurationWindow.cpp ] : [ FGristFiles pcihdr.h ] ;
  • src/apps/devices/DevicePCI.cpp

     
    1010#include <sstream>
    1111#include <stdlib.h>
    1212
     13#include <Catalog.h>
     14#include <Locale.h>
    1315#include "DevicePCI.h"
    1416
    1517extern "C" {
     
    1820#include "pci-utils.h"
    1921}
    2022
     23#undef B_TRANSLATE_CONTEXT
     24#define B_TRANSLATE_CONTEXT "DevicePCI"
    2125
    2226DevicePCI::DevicePCI(Device* parent)
    2327    :
     
    6670
    6771    // Fetch ClassInfo 
    6872    char classInfo[64];
    69     get_class_info(fClassBaseId, fClassSubId, fClassApiId, classInfo, sizeof(classInfo));
     73    get_class_info(fClassBaseId, fClassSubId, fClassApiId, classInfo,
     74        sizeof(classInfo));
    7075   
    7176    // Fetch ManufacturerName
    7277    BString ManufacturerName;
     
    7479    const char *venFull;
    7580    get_vendor_info(fVendorId, &venShort, &venFull);
    7681    if (!venShort && !venFull) {
    77         ManufacturerName << "Unknown";
     82        ManufacturerName << B_TRANSLATE("Unknown");
    7883    } else if (venShort && venFull) {
    7984        ManufacturerName << venFull << "(" << venShort << ")";
    8085    } else {
     
    8590    BString DeviceName;
    8691    const char *devShort;
    8792    const char *devFull;
    88     get_device_info(fVendorId, fDeviceId, fSubsystemVendorId, fSubSystemId, &devShort, &devFull);
     93    get_device_info(fVendorId, fDeviceId, fSubsystemVendorId, fSubSystemId,
     94        &devShort, &devFull);
    8995    if (!devShort && !devFull) {
    90         DeviceName << "Unknown";
     96        DeviceName << B_TRANSLATE("Unknown");
    9197    } else if (devShort && devFull) {
    9298        DeviceName << devFull << "(" << devShort << ")";
    9399    } else {
     
    96102   
    97103    SetAttribute("Device name", DeviceName);
    98104    SetAttribute("Manufacturer", ManufacturerName);
    99     SetAttribute("Driver used", "Not implemented");
    100     SetAttribute("Device paths", "Not implemented");
     105    SetAttribute("Driver used", B_TRANSLATE("Not implemented"));
     106    SetAttribute("Device paths", B_TRANSLATE("Not implemented"));
    101107    SetAttribute("Class info", classInfo);
    102108    fCategory = (Category)fClassBaseId;
    103109    BString outlineName;
     
    123129DevicePCI::GetBusStrings()
    124130{
    125131    BString str;
    126     str << "Class Info:\t\t\t\t: " << fAttributeMap["Class Info"];
     132    str << B_TRANSLATE("Class Info:");
     133    str << "\t\t\t\t: " << fAttributeMap["Class Info"];
    127134    return str;
    128135}
     136
     137
     138BString
     139DevicePCI::GetBusTabName()
     140{
     141    return B_TRANSLATE("PCI Information");
     142}