Patch by Mike Roll: i18n PowerStatus. Thanks!

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39939 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Adrien Destugues
2010-12-24 10:04:00 +00:00
parent 95fcf73946
commit 3bd54e05be
5 changed files with 84 additions and 50 deletions
+8 -3
View File
@@ -12,11 +12,16 @@
#include <stdio.h>
#include <Autolock.h>
#include <Catalog.h>
#include <Directory.h>
#include <Entry.h>
#include <Path.h>
#undef B_TRANSLATE_CONTEXT
#define B_TRANSLATE_CONTEXT "PowerStatus"
RateBuffer::RateBuffer()
:
fPosition(0),
@@ -138,7 +143,7 @@ Battery::_Init()
if (fInitStatus != B_OK)
return;
printf("ACPI driver found\n");
printf(B_TRANSLATE("ACPI driver found\n"));
}
@@ -157,7 +162,7 @@ const char* kDriverDir = "/dev/power";
status_t
ACPIDriverInterface::Connect()
{
printf("ACPI connect\n");
printf(B_TRANSLATE("ACPI connect\n"));
return _FindDrivers(kDriverDir);
}
@@ -240,7 +245,7 @@ ACPIDriverInterface::_FindDrivers(const char* path)
else {
int32 handler = open(path.Path(), O_RDWR);
if (handler >= 0) {
printf("try %s\n", path.Path());
printf(B_TRANSLATE("try %s\n"), path.Path());
Battery* battery = new Battery(handler);
if (battery->InitCheck() == B_OK) {
fDriverList.AddItem(battery);
+34 -28
View File
@@ -10,10 +10,15 @@
#include "ExtendedInfoWindow.h"
#include <Box.h>
#include <Catalog.h>
#include <GroupView.h>
#include <SpaceLayoutItem.h>
#undef B_TRANSLATE_CONTEXT
#define B_TRANSLATE_CONTEXT "PowerStatus"
const int kLineSpacing = 5;
@@ -111,13 +116,13 @@ BatteryInfoView::_FillStringList()
BString rateUnit;
switch (fBatteryExtendedInfo.power_unit) {
case 0:
powerUnit = " mWh";
rateUnit = " mW";
powerUnit = B_TRANSLATE(" mWh");
rateUnit = B_TRANSLATE(" mW");
break;
case 1:
powerUnit = " mAh";
rateUnit = " mA";
powerUnit = B_TRANSLATE(" mAh");
rateUnit = B_TRANSLATE(" mA");
break;
}
@@ -128,28 +133,28 @@ BatteryInfoView::_FillStringList()
fontString->font = be_bold_font;
if (fBatteryInfo.state & BATTERY_CHARGING)
fontString->string = "Battery charging";
fontString->string = B_TRANSLATE("Battery charging");
else if (fBatteryInfo.state & BATTERY_DISCHARGING)
fontString->string = "Battery discharging";
fontString->string = B_TRANSLATE("Battery discharging");
else if (fBatteryInfo.state & BATTERY_CRITICAL_STATE)
fontString->string = "Empty battery slot";
fontString->string = B_TRANSLATE("Empty battery slot");
else
fontString->string = "Battery unused";
fontString->string = B_TRANSLATE("Battery unused");
fontString = new FontString;
fontString->string = "Capacity: ";
fontString->string = B_TRANSLATE("Capacity: ");
fontString->string << fBatteryInfo.capacity;
fontString->string << powerUnit;
_AddToStringList(fontString);
fontString = new FontString;
fontString->string = "Last full charge: ";
fontString->string = B_TRANSLATE("Last full charge: ");
fontString->string << fBatteryInfo.full_capacity;
fontString->string << powerUnit;
_AddToStringList(fontString);
fontString = new FontString;
fontString->string = "Current rate: ";
fontString->string = B_TRANSLATE("Current rate: ");
fontString->string << fBatteryInfo.current_rate;
fontString->string << rateUnit;
_AddToStringList(fontString);
@@ -159,68 +164,68 @@ BatteryInfoView::_FillStringList()
_AddToStringList(fontString);
fontString = new FontString;
fontString->string = "Design capacity: ";
fontString->string = B_TRANSLATE("Design capacity: ");
fontString->string << fBatteryExtendedInfo.design_capacity;
fontString->string << powerUnit;
_AddToStringList(fontString);
fontString = new FontString;
fontString->string = "Technology: ";
fontString->string = B_TRANSLATE("Technology: ");
if (fBatteryExtendedInfo.technology == 0)
fontString->string << "non-rechargeable";
fontString->string << B_TRANSLATE("non-rechargeable");
else if (fBatteryExtendedInfo.technology == 1)
fontString->string << "rechargeable";
fontString->string << B_TRANSLATE("rechargeable");
else
fontString->string << "?";
_AddToStringList(fontString);
fontString = new FontString;
fontString->string = "Design voltage: ";
fontString->string = B_TRANSLATE("Design voltage: ");
fontString->string << fBatteryExtendedInfo.design_voltage;
fontString->string << " mV";
fontString->string << B_TRANSLATE(" mV");
_AddToStringList(fontString);
fontString = new FontString;
fontString->string = "Design capacity warning: ";
fontString->string = B_TRANSLATE("Design capacity warning: ");
fontString->string << fBatteryExtendedInfo.design_capacity_warning;
fontString->string << powerUnit;
_AddToStringList(fontString);
fontString = new FontString;
fontString->string = "Design capacity low warning: ";
fontString->string = B_TRANSLATE("Design capacity low warning: ");
fontString->string << fBatteryExtendedInfo.design_capacity_low;
fontString->string << powerUnit;
_AddToStringList(fontString);
fontString = new FontString;
fontString->string = "Capacity granularity 1: ";
fontString->string = B_TRANSLATE("Capacity granularity 1: ");
fontString->string << fBatteryExtendedInfo.capacity_granularity_1;
fontString->string << powerUnit;
_AddToStringList(fontString);
fontString = new FontString;
fontString->string = "Capacity granularity 2: ";
fontString->string = B_TRANSLATE("Capacity granularity 2: ");
fontString->string << fBatteryExtendedInfo.capacity_granularity_2;
fontString->string << powerUnit;
_AddToStringList(fontString);
fontString = new FontString;
fontString->string = "Model number: ";
fontString->string = B_TRANSLATE("Model number: ");
fontString->string << fBatteryExtendedInfo.model_number;
_AddToStringList(fontString);
fontString = new FontString;
fontString->string = "Serial number: ";
fontString->string = B_TRANSLATE("Serial number: ");
fontString->string << fBatteryExtendedInfo.serial_number;
_AddToStringList(fontString);
fontString = new FontString;
fontString->string = "Type: ";
fontString->string = B_TRANSLATE("Type: ");
fontString->string += fBatteryExtendedInfo.type;
_AddToStringList(fontString);
fontString = new FontString;
fontString->string = "OEM info: ";
fontString->string = B_TRANSLATE("OEM info: ");
fontString->string += fBatteryExtendedInfo.oem_info;
_AddToStringList(fontString);
@@ -325,7 +330,8 @@ ExtPowerStatusView::Update(bool force)
ExtendedInfoWindow::ExtendedInfoWindow(PowerStatusDriverInterface* interface)
:
BWindow(BRect(100, 150, 500, 500), "Extended battery info", B_TITLED_WINDOW,
BWindow(BRect(100, 150, 500, 500), B_TRANSLATE("Extended battery info"),
B_TITLED_WINDOW,
B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_AVOID_FRONT |
B_ASYNCHRONOUS_CONTROLS),
fDriverInterface(interface),
@@ -344,8 +350,8 @@ ExtendedInfoWindow::ExtendedInfoWindow(PowerStatusDriverInterface* interface)
BRect rect = Bounds();
rect.InsetBy(5, 5);
BBox *infoBox = new BBox(rect, "Power status box");
infoBox->SetLabel("Battery info");
BBox *infoBox = new BBox(rect, B_TRANSLATE("Power status box"));
infoBox->SetLabel(B_TRANSLATE("Battery info"));
BGroupLayout* infoLayout = new BGroupLayout(B_HORIZONTAL);
infoLayout->SetInsets(10, infoBox->TopBorderOffset() * 2 + 10, 10, 10);
infoLayout->SetSpacing(10);
+10 -2
View File
@@ -13,6 +13,14 @@ Application PowerStatus :
PowerStatusWindow.cpp
PowerStatusView.cpp
PowerStatus.cpp
: be $(TARGET_LIBSUPC++)
: be $(TARGET_LIBSUPC++) $(HAIKU_LOCALE_LIBS)
: PowerStatus.rdef
;
;
DoCatalogs PowerStatus :
x-vnd.Haiku-PowerStatus
:
ACPIDriverInterface.cpp
ExtendedInfoWindow.cpp
PowerStatus.cpp
PowerStatusView.cpp
;
+10 -3
View File
@@ -12,6 +12,7 @@
#include <Alert.h>
#include <Application.h>
#include <Catalog.h>
#include <Deskbar.h>
#include <Entry.h>
@@ -20,6 +21,10 @@
#include <string.h>
#undef B_TRANSLATE_CONTEXT
#define B_TRANSLATE_CONTEXT "PowerStatus"
class PowerStatus : public BApplication {
public:
PowerStatus();
@@ -80,9 +85,11 @@ PowerStatus::ReadyToRun()
}
if (isDeskbarRunning && !isInstalled) {
BAlert* alert = new BAlert("", "You can run PowerStatus in a window "
"or install it in the Deskbar.", "Run in window",
"Install in Deskbar", NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
BAlert* alert = new BAlert("",
B_TRANSLATE("You can run PowerStatus in a window "
"or install it in the Deskbar."), B_TRANSLATE("Run in window"),
B_TRANSLATE("Install in Deskbar"), NULL, B_WIDTH_AS_USUAL,
B_WARNING_ALERT);
alert->SetShortcut(0, B_ESCAPE);
if (alert->Go()) {
+22 -14
View File
@@ -18,6 +18,7 @@
#include <Alert.h>
#include <Application.h>
#include <Catalog.h>
#include <ControlLook.h>
#include <Deskbar.h>
#include <Dragger.h>
@@ -36,6 +37,10 @@
#include "PowerStatus.h"
#undef B_TRANSLATE_CONTEXT
#define B_TRANSLATE_CONTEXT "PowerStatus"
extern "C" _EXPORT BView *instantiate_deskbar_item(void);
const uint32 kMsgToggleLabel = 'tglb';
@@ -376,16 +381,16 @@ PowerStatusView::Update(bool force)
const char* state = NULL;
if ((fBatteryInfo.state & BATTERY_CHARGING) != 0)
state = "charging";
state = B_TRANSLATE("charging");
else if ((fBatteryInfo.state & BATTERY_DISCHARGING) != 0)
state = "discharging";
state = B_TRANSLATE("discharging");
if (state != NULL) {
snprintf(text + length, sizeof(text) - length, "\n%s",
state);
}
} else
strcpy(text, "no battery");
strcpy(text, B_TRANSLATE("no battery"));
SetToolTip(text);
}
if (width == 0) {
@@ -573,25 +578,27 @@ PowerStatusReplicant::MouseDown(BPoint point)
menu->SetFont(be_plain_font);
BMenuItem* item;
menu->AddItem(item = new BMenuItem("Show text label",
menu->AddItem(item = new BMenuItem(B_TRANSLATE("Show text label"),
new BMessage(kMsgToggleLabel)));
if (fShowLabel)
item->SetMarked(true);
menu->AddItem(item = new BMenuItem("Show status icon",
menu->AddItem(item = new BMenuItem(B_TRANSLATE("Show status icon"),
new BMessage(kMsgToggleStatusIcon)));
if (fShowStatusIcon)
item->SetMarked(true);
menu->AddItem(new BMenuItem(!fShowTime ? "Show time" : "Show percent",
menu->AddItem(new BMenuItem(!fShowTime ? B_TRANSLATE("Show time") :
B_TRANSLATE("Show percent"),
new BMessage(kMsgToggleTime)));
menu->AddSeparatorItem();
menu->AddItem(new BMenuItem("Battery info" B_UTF8_ELLIPSIS,
menu->AddItem(new BMenuItem(B_TRANSLATE("Battery info" B_UTF8_ELLIPSIS),
new BMessage(kMsgToggleExtInfo)));
menu->AddSeparatorItem();
menu->AddItem(new BMenuItem("About" B_UTF8_ELLIPSIS,
menu->AddItem(new BMenuItem(B_TRANSLATE("About" B_UTF8_ELLIPSIS),
new BMessage(B_ABOUT_REQUESTED)));
menu->AddItem(new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED)));
menu->AddItem(new BMenuItem(B_TRANSLATE("Quit"),
new BMessage(B_QUIT_REQUESTED)));
menu->SetTargetForItems(this);
ConvertToScreen(&point);
@@ -602,9 +609,10 @@ PowerStatusReplicant::MouseDown(BPoint point)
void
PowerStatusReplicant::_AboutRequested()
{
BAlert* alert = new BAlert("about", "PowerStatus\n"
"written by Axel Dörfler, Clemens Zeidler\n"
"Copyright 2006, Haiku, Inc.\n", "OK");
BAlert* alert = new BAlert(B_TRANSLATE("about"),
B_TRANSLATE("PowerStatus\n"
"written by Axel Dörfler, Clemens Zeidler\n"
"Copyright 2006, Haiku, Inc.\n"), B_TRANSLATE("OK"));
BTextView *view = alert->TextView();
BFont font;
@@ -627,7 +635,7 @@ PowerStatusReplicant::_Init()
delete fDriverInterface;
fDriverInterface = new APMDriverInterface;
if (fDriverInterface->Connect() != B_OK) {
fprintf(stderr, "No power interface found.\n");
fprintf(stderr, B_TRANSLATE("No power interface found.\n"));
_Quit();
}
}
@@ -660,7 +668,7 @@ PowerStatusReplicant::_GetSettings(BFile& file, int mode)
if (status != B_OK)
return status;
path.Append("PowerStatus settings");
path.Append(B_TRANSLATE("PowerStatus settings"));
return file.SetTo(path.Path(), mode);
}