Localizing "Attributes" tab of InfoWindow

Change-Id: I38bacade1f7e9648e7ef80ca39cc197410e7114f
Reviewed-on: https://review.haiku-os.org/c/haiku/+/1923
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
This commit is contained in:
Humdinger 2019-10-20 10:15:32 +02:00 committed by humdinger
parent 8208b16279
commit 894c9f268c

View File

@ -6,6 +6,7 @@
#include "AttributesView.h"
#include <Catalog.h>
#include <ColumnListView.h>
#include <ColumnTypes.h>
#include <DateTimeFormat.h>
@ -14,6 +15,9 @@
#include <Node.h>
#undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "AttributesView"
int kValueColumn = 1;
int kTypeColumn = 2;
@ -23,20 +27,21 @@ AttributesView::AttributesView(Model* model)
BGroupView(B_VERTICAL, 0),
fListView(new BColumnListView("attrs", 0, B_PLAIN_BORDER, false))
{
SetName("Attributes");
SetName(B_TRANSLATE("Attributes"));
AddChild(fListView);
float nameWidth = StringWidth("SYS:PACKAGE_FILE") + 16;
float typeMaxWidth = StringWidth("Double-precision floating point number") + 16;
float typeWidth = StringWidth("64-bit unsigned integer") + 16;
float typeMaxWidth = StringWidth(B_TRANSLATE(
"Double-precision floating point number")) + 16;
float typeWidth = StringWidth(B_TRANSLATE("64-bit unsigned integer")) + 16;
float valueMaxWidth = StringWidth("W") * 64 + 16;
float valueWidth = StringWidth("(94.00, 95.00) (1920, 1080)") + 16;
BStringColumn* nameColumn = new BStringColumn("Name", nameWidth, nameWidth,
nameWidth, 0);
BStringColumn* typeColumn = new BStringColumn("Type", typeWidth, typeWidth,
typeMaxWidth, 0);
BStringColumn* valueColumn = new BStringColumn("Value", valueWidth,
valueWidth, valueMaxWidth, 0);
BStringColumn* nameColumn = new BStringColumn(B_TRANSLATE("Name"),
nameWidth, nameWidth, nameWidth, 0);
BStringColumn* typeColumn = new BStringColumn(B_TRANSLATE("Type"),
typeWidth, typeWidth, typeMaxWidth, 0);
BStringColumn* valueColumn = new BStringColumn(B_TRANSLATE("Value"),
valueWidth, valueWidth, valueMaxWidth, 0);
fListView->AddColumn(nameColumn, 0);
fListView->AddColumn(valueColumn, 1);
@ -79,10 +84,11 @@ AttributesView::AttributesView(Model* model)
if (info.size == sizeof(bool)) {
bool value;
node->ReadAttr(name, info.type, 0, &value, sizeof(value));
representation = value ? "yes" : "no";
representation = value ? B_TRANSLATE("yes")
: B_TRANSLATE("no");
} else {
representation.SetToFormat("<%" B_PRIdOFF " values>",
info.size / sizeof(bool));
representation.SetToFormat(B_TRANSLATE(
"<%" B_PRIdOFF " values>"), info.size / sizeof(bool));
}
break;
}
@ -93,8 +99,8 @@ AttributesView::AttributesView(Model* model)
node->ReadAttr(name, info.type, 0, &value, sizeof(value));
representation.SetToFormat("%" B_PRId16, value);
} else {
representation.SetToFormat("<%" B_PRIdOFF " values>",
info.size / sizeof(int16));
representation.SetToFormat(B_TRANSLATE(
"<%" B_PRIdOFF " values>"), info.size / sizeof(int16));
}
break;
}
@ -105,8 +111,8 @@ AttributesView::AttributesView(Model* model)
node->ReadAttr(name, info.type, 0, &value, sizeof(value));
representation.SetToFormat("%" B_PRId32, value);
} else {
representation.SetToFormat("<%" B_PRIdOFF " values>",
info.size / sizeof(int32));
representation.SetToFormat(B_TRANSLATE(
"<%" B_PRIdOFF " values>"), info.size / sizeof(int32));
}
break;
}
@ -117,8 +123,8 @@ AttributesView::AttributesView(Model* model)
node->ReadAttr(name, info.type, 0, &value, sizeof(value));
representation.SetToFormat("%" B_PRId64, value);
} else {
representation.SetToFormat("<%" B_PRIdOFF " values>",
info.size / sizeof(int64));
representation.SetToFormat(B_TRANSLATE(
"<%" B_PRIdOFF " values>"), info.size / sizeof(int64));
}
break;
}
@ -129,8 +135,8 @@ AttributesView::AttributesView(Model* model)
node->ReadAttr(name, info.type, 0, &value, sizeof(value));
representation.SetToFormat("%" B_PRId8, value);
} else {
representation.SetToFormat("<%" B_PRIdOFF " values>",
info.size / sizeof(int8));
representation.SetToFormat(B_TRANSLATE(
"<%" B_PRIdOFF " values>"), info.size / sizeof(int8));
}
break;
}
@ -142,8 +148,8 @@ AttributesView::AttributesView(Model* model)
representation.SetToFormat("(%g,%g) (%g,%g)", value.left,
value.top, value.right, value.bottom);
} else {
representation.SetToFormat("<%" B_PRIdOFF " rectangles>",
info.size / sizeof(BRect));
representation.SetToFormat(B_TRANSLATE(
"<%" B_PRIdOFF " rectangles>"), info.size / sizeof(BRect));
}
break;
}
@ -154,8 +160,8 @@ AttributesView::AttributesView(Model* model)
node->ReadAttr(name, info.type, 0, &value, sizeof(value));
representation.SetToFormat("%f", value);
} else {
representation.SetToFormat("<%" B_PRIdOFF " values>",
info.size / sizeof(double));
representation.SetToFormat(B_TRANSLATE(
"<%" B_PRIdOFF " values>"), info.size / sizeof(double));
}
break;
}
@ -166,8 +172,8 @@ AttributesView::AttributesView(Model* model)
node->ReadAttr(name, info.type, 0, &value, sizeof(value));
representation.SetToFormat("%f", value);
} else {
representation.SetToFormat("<%" B_PRIdOFF " values>",
info.size / sizeof(float));
representation.SetToFormat(B_TRANSLATE(
"<%" B_PRIdOFF " values>"), info.size / sizeof(float));
}
break;
}
@ -185,8 +191,8 @@ AttributesView::AttributesView(Model* model)
dateTimeFormatter.Format(representation, value,
B_SHORT_DATE_FORMAT, B_SHORT_TIME_FORMAT);
} else {
representation.SetToFormat("<%" B_PRIdOFF " dates>",
info.size / sizeof(time_t));
representation.SetToFormat(B_TRANSLATE(
"<%" B_PRIdOFF " dates>"), info.size / sizeof(time_t));
}
break;
}
@ -197,8 +203,8 @@ AttributesView::AttributesView(Model* model)
node->ReadAttr(name, info.type, 0, &value, sizeof(value));
representation.SetToFormat("%" B_PRIu16, value);
} else {
representation.SetToFormat("<%" B_PRIdOFF " values>",
info.size / sizeof(uint16));
representation.SetToFormat(B_TRANSLATE(
"<%" B_PRIdOFF " values>"), info.size / sizeof(uint16));
}
break;
}
@ -209,8 +215,8 @@ AttributesView::AttributesView(Model* model)
node->ReadAttr(name, info.type, 0, &value, sizeof(value));
representation.SetToFormat("%" B_PRIu32, value);
} else {
representation.SetToFormat("<%" B_PRIdOFF " values>",
info.size / sizeof(uint32));
representation.SetToFormat(B_TRANSLATE(
"<%" B_PRIdOFF " values>"), info.size / sizeof(uint32));
}
break;
}
@ -221,8 +227,8 @@ AttributesView::AttributesView(Model* model)
node->ReadAttr(name, info.type, 0, &value, sizeof(value));
representation.SetToFormat("%" B_PRIu64, value);
} else {
representation.SetToFormat("<%" B_PRIdOFF " values>",
info.size / sizeof(int64));
representation.SetToFormat(B_TRANSLATE(
"<%" B_PRIdOFF " values>"), info.size / sizeof(int64));
}
break;
}
@ -233,187 +239,222 @@ AttributesView::AttributesView(Model* model)
node->ReadAttr(name, info.type, 0, &value, sizeof(value));
representation.SetToFormat("%" B_PRIu8, value);
} else {
representation.SetToFormat("<%" B_PRIdOFF " values>",
info.size / sizeof(int8));
representation.SetToFormat(B_TRANSLATE(
"<%" B_PRIdOFF " values>"), info.size / sizeof(int8));
}
break;
}
default:
representation.SetToFormat("<%" B_PRIdOFF " bytes of data>",
info.size);
representation.SetToFormat(B_TRANSLATE(
"<%" B_PRIdOFF " bytes of data>"), info.size);
break;
}
row->SetField(new BStringField(representation), kValueColumn);
switch(info.type) {
case B_AFFINE_TRANSFORM_TYPE:
row->SetField(new BStringField("Affine transform"),
row->SetField(new BStringField(B_TRANSLATE("Affine transform")),
kTypeColumn);
break;
case B_ALIGNMENT_TYPE:
row->SetField(new BStringField("Alignment"), kTypeColumn);
row->SetField(new BStringField(B_TRANSLATE("Alignment")),
kTypeColumn);
break;
case B_ANY_TYPE:
row->SetField(new BStringField("Any"), kTypeColumn);
row->SetField(new BStringField(B_TRANSLATE("Any")),
kTypeColumn);
break;
case B_ATOM_TYPE:
row->SetField(new BStringField("Atom"), kTypeColumn);
row->SetField(new BStringField(B_TRANSLATE("Atom")),
kTypeColumn);
break;
case B_ATOMREF_TYPE:
row->SetField(new BStringField("Atom reference"), kTypeColumn);
row->SetField(new BStringField(B_TRANSLATE("Atom reference")),
kTypeColumn);
break;
case B_BOOL_TYPE:
row->SetField(new BStringField("Boolean"), kTypeColumn);
row->SetField(new BStringField(B_TRANSLATE("Boolean")),
kTypeColumn);
break;
case B_CHAR_TYPE:
row->SetField(new BStringField("Character"), kTypeColumn);
row->SetField(new BStringField(B_TRANSLATE("Character")),
kTypeColumn);
break;
case B_COLOR_8_BIT_TYPE:
row->SetField(new BStringField("Palette-indexed picture"),
kTypeColumn);
row->SetField(new BStringField(B_TRANSLATE(
"Palette-indexed picture")), kTypeColumn);
break;
case B_DOUBLE_TYPE:
row->SetField(new BStringField(
"Double-precision floating point number"), kTypeColumn);
row->SetField(new BStringField(B_TRANSLATE(
"Double-precision floating point number")), kTypeColumn);
break;
case B_FLOAT_TYPE:
row->SetField(new BStringField("Floating point number"),
kTypeColumn);
row->SetField(new BStringField(B_TRANSLATE(
"Floating point number")), kTypeColumn);
break;
case B_GRAYSCALE_8_BIT_TYPE:
row->SetField(new BStringField("Grayscale picture"),
kTypeColumn);
row->SetField(new BStringField(B_TRANSLATE(
"Grayscale picture")), kTypeColumn);
break;
case B_INT16_TYPE:
row->SetField(new BStringField("16-bit integer"), kTypeColumn);
row->SetField(new BStringField(B_TRANSLATE("16-bit integer")),
kTypeColumn);
break;
case B_INT32_TYPE:
row->SetField(new BStringField("32-bit integer"), kTypeColumn);
row->SetField(new BStringField(B_TRANSLATE("32-bit integer")),
kTypeColumn);
break;
case B_INT64_TYPE:
row->SetField(new BStringField("64-bit integer"), kTypeColumn);
row->SetField(new BStringField(B_TRANSLATE("64-bit integer")),
kTypeColumn);
break;
case B_INT8_TYPE:
row->SetField(new BStringField("8-bit integer"), kTypeColumn);
row->SetField(new BStringField(B_TRANSLATE("8-bit integer")),
kTypeColumn);
break;
case B_LARGE_ICON_TYPE:
row->SetField(new BStringField("Bitmap icon"), kTypeColumn);
row->SetField(new BStringField(B_TRANSLATE("Bitmap icon")),
kTypeColumn);
break;
case B_MEDIA_PARAMETER_GROUP_TYPE:
row->SetField(new BStringField("Media parameter group"),
kTypeColumn);
row->SetField(new BStringField(B_TRANSLATE(
"Media parameter group")), kTypeColumn);
break;
case B_MEDIA_PARAMETER_TYPE:
row->SetField(new BStringField("Media parameter"), kTypeColumn);
row->SetField(new BStringField(B_TRANSLATE("Media parameter")),
kTypeColumn);
break;
case B_MEDIA_PARAMETER_WEB_TYPE:
row->SetField(new BStringField("Media parameter web"),
kTypeColumn);
row->SetField(new BStringField(B_TRANSLATE(
"Media parameter web")), kTypeColumn);
break;
case B_MESSAGE_TYPE:
row->SetField(new BStringField("Message"), kTypeColumn);
row->SetField(new BStringField(B_TRANSLATE("Message")),
kTypeColumn);
break;
case B_MESSENGER_TYPE:
row->SetField(new BStringField("Messenger"), kTypeColumn);
row->SetField(new BStringField(B_TRANSLATE("Messenger")),
kTypeColumn);
break;
case B_MIME_TYPE:
row->SetField(new BStringField("MIME Type"), kTypeColumn);
row->SetField(new BStringField(B_TRANSLATE("MIME Type")),
kTypeColumn);
break;
case B_MINI_ICON_TYPE:
row->SetField(new BStringField("Small bitmap icon"),
kTypeColumn);
row->SetField(new BStringField(B_TRANSLATE(
"Small bitmap icon")), kTypeColumn);
break;
case B_MONOCHROME_1_BIT_TYPE:
row->SetField(new BStringField("Monochrome picture"),
kTypeColumn);
row->SetField(new BStringField(B_TRANSLATE(
"Monochrome picture")), kTypeColumn);
break;
case B_OBJECT_TYPE:
row->SetField(new BStringField("Object"), kTypeColumn);
row->SetField(new BStringField(B_TRANSLATE("Object")),
kTypeColumn);
break;
case B_OFF_T_TYPE:
row->SetField(new BStringField("File offset"), kTypeColumn);
row->SetField(new BStringField(B_TRANSLATE("File offset")),
kTypeColumn);
break;
case B_PATTERN_TYPE:
row->SetField(new BStringField("Drawing pattern"), kTypeColumn);
row->SetField(new BStringField(B_TRANSLATE("Drawing pattern")),
kTypeColumn);
break;
case B_POINTER_TYPE:
row->SetField(new BStringField("Memory pointer"), kTypeColumn);
row->SetField(new BStringField(B_TRANSLATE("Memory pointer")),
kTypeColumn);
break;
case B_POINT_TYPE:
row->SetField(new BStringField("Point"), kTypeColumn);
row->SetField(new BStringField(B_TRANSLATE("Point")),
kTypeColumn);
break;
case B_PROPERTY_INFO_TYPE:
row->SetField(new BStringField("Property info"), kTypeColumn);
row->SetField(new BStringField(B_TRANSLATE("Property info")),
kTypeColumn);
break;
case B_RAW_TYPE:
row->SetField(new BStringField("Raw data"), kTypeColumn);
row->SetField(new BStringField(B_TRANSLATE("Raw data")),
kTypeColumn);
break;
case B_RECT_TYPE:
row->SetField(new BStringField("Rectangle"), kTypeColumn);
row->SetField(new BStringField(B_TRANSLATE("Rectangle")),
kTypeColumn);
break;
case B_REF_TYPE:
row->SetField(new BStringField("Reference"), kTypeColumn);
row->SetField(new BStringField(B_TRANSLATE("Reference")),
kTypeColumn);
break;
case B_RGB_32_BIT_TYPE:
row->SetField(new BStringField("True-color picture"),
kTypeColumn);
row->SetField(new BStringField(B_TRANSLATE(
"True-color picture")), kTypeColumn);
break;
case B_RGB_COLOR_TYPE:
row->SetField(new BStringField("Color"), kTypeColumn);
row->SetField(new BStringField(B_TRANSLATE("Color")),
kTypeColumn);
break;
case B_SIZE_TYPE:
row->SetField(new BStringField("Geometric size"), kTypeColumn);
row->SetField(new BStringField(B_TRANSLATE("Geometric size")),
kTypeColumn);
break;
case B_SIZE_T_TYPE:
row->SetField(new BStringField("Memory size"), kTypeColumn);
row->SetField(new BStringField(B_TRANSLATE("Memory size")),
kTypeColumn);
break;
case B_SSIZE_T_TYPE:
row->SetField(new BStringField("Signed memory size"),
kTypeColumn);
row->SetField(new BStringField(B_TRANSLATE(
"Signed memory size")), kTypeColumn);
break;
case B_STRING_TYPE:
row->SetField(new BStringField("Plain text"), kTypeColumn);
row->SetField(new BStringField(B_TRANSLATE("Plain text")),
kTypeColumn);
break;
case B_STRING_LIST_TYPE:
row->SetField(new BStringField("Text list"), kTypeColumn);
row->SetField(new BStringField(B_TRANSLATE("Text list")),
kTypeColumn);
break;
case B_TIME_TYPE:
row->SetField(new BStringField("Time"), kTypeColumn);
row->SetField(new BStringField(B_TRANSLATE("Time")),
kTypeColumn);
break;
case B_UINT16_TYPE:
row->SetField(new BStringField("16-bit unsigned integer"),
kTypeColumn);
row->SetField(new BStringField(B_TRANSLATE(
"16-bit unsigned integer")), kTypeColumn);
break;
case B_UINT32_TYPE:
row->SetField(new BStringField("32-bit unsigned integer"),
kTypeColumn);
row->SetField(new BStringField(B_TRANSLATE(
"32-bit unsigned integer")), kTypeColumn);
break;
case B_UINT64_TYPE:
row->SetField(new BStringField("64-bit unsigned integer"),
kTypeColumn);
row->SetField(new BStringField(B_TRANSLATE(
"64-bit unsigned integer")), kTypeColumn);
break;
case B_UINT8_TYPE:
row->SetField(new BStringField("8-bit unsigned integer"),
kTypeColumn);
row->SetField(new BStringField(B_TRANSLATE(
"8-bit unsigned integer")), kTypeColumn);
break;
case B_VECTOR_ICON_TYPE:
row->SetField(new BStringField("Icon"), kTypeColumn);
break;
case B_XATTR_TYPE:
row->SetField(new BStringField("Extended attribute"),
row->SetField(new BStringField(B_TRANSLATE("Icon")),
kTypeColumn);
break;
case B_XATTR_TYPE:
row->SetField(new BStringField(B_TRANSLATE(
"Extended attribute")), kTypeColumn);
break;
case B_NETWORK_ADDRESS_TYPE:
row->SetField(new BStringField("Network address"), kTypeColumn);
row->SetField(new BStringField(B_TRANSLATE("Network address")),
kTypeColumn);
break;
case B_MIME_STRING_TYPE:
row->SetField(new BStringField("MIME String"), kTypeColumn);
row->SetField(new BStringField(B_TRANSLATE("MIME String")),
kTypeColumn);
break;
case B_ASCII_TYPE:
row->SetField(new BStringField("ASCII Text"), kTypeColumn);
row->SetField(new BStringField(B_TRANSLATE("ASCII Text")),
kTypeColumn);
break;
default:
row->SetField(new BStringField("(unknown)"), kTypeColumn);
row->SetField(new BStringField(B_TRANSLATE("(unknown)")),
kTypeColumn);
break;
}
fListView->AddRow(row);