Missing pluralization in Tracker InfoWindow

Fixes #16086

Change-Id: I1984ff7a9a5f6614e7a278efae45e6c7100d759f
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2769
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
This commit is contained in:
Adrien Destugues 2020-05-21 20:59:55 +02:00 committed by waddlesplash
parent e1bb846d71
commit fc5ce31970

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2019 Adrien Destugues <pulkomandy@pulkomandy.tk>
* Copyright (C) 2019-2020 Adrien Destugues <pulkomandy@pulkomandy.tk>
*
* Distributed under terms of the MIT license.
*/
@ -13,6 +13,7 @@
#include <FormattingConventions.h>
#include <fs_attr.h>
#include <Node.h>
#include <StringFormat.h>
#undef B_TRANSLATION_CONTEXT
@ -55,8 +56,12 @@ AttributesView::AttributesView(Model* model)
node->RewindAttrs();
char name[B_ATTR_NAME_LENGTH];
// Initialize formatters only once for all attributes
BDateTimeFormat dateTimeFormatter;
// Initialize only once for all attributes
BStringFormat multiValueFormat(B_TRANSLATE(
"{0, plural, other{<# values>}}"));
while (node->GetNextAttrName(name) == B_OK) {
// Skip well-known attributes already shown elsewhere in the window
if (strcmp(name, "BEOS:TYPE") == 0)
@ -88,8 +93,8 @@ AttributesView::AttributesView(Model* model)
representation = value ? B_TRANSLATE("yes")
: B_TRANSLATE("no");
} else {
representation.SetToFormat(B_TRANSLATE(
"<%" B_PRIdOFF " values>"), info.size / sizeof(bool));
multiValueFormat.Format(representation,
info.size / sizeof(bool));
}
break;
}
@ -100,8 +105,8 @@ AttributesView::AttributesView(Model* model)
node->ReadAttr(name, info.type, 0, &value, sizeof(value));
representation.SetToFormat("%" B_PRId16, value);
} else {
representation.SetToFormat(B_TRANSLATE(
"<%" B_PRIdOFF " values>"), info.size / sizeof(int16));
multiValueFormat.Format(representation,
info.size / sizeof(int16));
}
break;
}
@ -112,8 +117,8 @@ AttributesView::AttributesView(Model* model)
node->ReadAttr(name, info.type, 0, &value, sizeof(value));
representation.SetToFormat("%" B_PRId32, value);
} else {
representation.SetToFormat(B_TRANSLATE(
"<%" B_PRIdOFF " values>"), info.size / sizeof(int32));
multiValueFormat.Format(representation,
info.size / sizeof(int32));
}
break;
}
@ -124,8 +129,8 @@ AttributesView::AttributesView(Model* model)
node->ReadAttr(name, info.type, 0, &value, sizeof(value));
representation.SetToFormat("%" B_PRId64, value);
} else {
representation.SetToFormat(B_TRANSLATE(
"<%" B_PRIdOFF " values>"), info.size / sizeof(int64));
multiValueFormat.Format(representation,
info.size / sizeof(int64));
}
break;
}
@ -136,8 +141,8 @@ AttributesView::AttributesView(Model* model)
node->ReadAttr(name, info.type, 0, &value, sizeof(value));
representation.SetToFormat("%" B_PRId8, value);
} else {
representation.SetToFormat(B_TRANSLATE(
"<%" B_PRIdOFF " values>"), info.size / sizeof(int8));
multiValueFormat.Format(representation,
info.size / sizeof(int8));
}
break;
}
@ -149,8 +154,10 @@ AttributesView::AttributesView(Model* model)
representation.SetToFormat("(%g,%g) (%g,%g)", value.left,
value.top, value.right, value.bottom);
} else {
representation.SetToFormat(B_TRANSLATE(
"<%" B_PRIdOFF " rectangles>"), info.size / sizeof(BRect));
BStringFormat multiRectFormat(B_TRANSLATE(
"{0, plural, other{<# rectangles>}}"));
multiRectFormat.Format(representation,
info.size / sizeof(BRect));
}
break;
}
@ -161,8 +168,8 @@ AttributesView::AttributesView(Model* model)
node->ReadAttr(name, info.type, 0, &value, sizeof(value));
representation.SetToFormat("%f", value);
} else {
representation.SetToFormat(B_TRANSLATE(
"<%" B_PRIdOFF " values>"), info.size / sizeof(double));
multiValueFormat.Format(representation,
info.size / sizeof(double));
}
break;
}
@ -173,8 +180,8 @@ AttributesView::AttributesView(Model* model)
node->ReadAttr(name, info.type, 0, &value, sizeof(value));
representation.SetToFormat("%f", value);
} else {
representation.SetToFormat(B_TRANSLATE(
"<%" B_PRIdOFF " values>"), info.size / sizeof(float));
multiValueFormat.Format(representation,
info.size / sizeof(float));
}
break;
}
@ -192,8 +199,10 @@ AttributesView::AttributesView(Model* model)
dateTimeFormatter.Format(representation, value,
B_SHORT_DATE_FORMAT, B_SHORT_TIME_FORMAT);
} else {
representation.SetToFormat(B_TRANSLATE(
"<%" B_PRIdOFF " dates>"), info.size / sizeof(time_t));
BStringFormat multiDateFormat(B_TRANSLATE(
"{0, plural, other{<# dates>}}"));
multiDateFormat.Format(representation,
info.size / sizeof(time_t));
}
break;
}
@ -204,8 +213,8 @@ AttributesView::AttributesView(Model* model)
node->ReadAttr(name, info.type, 0, &value, sizeof(value));
representation.SetToFormat("%" B_PRIu16, value);
} else {
representation.SetToFormat(B_TRANSLATE(
"<%" B_PRIdOFF " values>"), info.size / sizeof(uint16));
multiValueFormat.Format(representation,
info.size / sizeof(uint16));
}
break;
}
@ -216,8 +225,8 @@ AttributesView::AttributesView(Model* model)
node->ReadAttr(name, info.type, 0, &value, sizeof(value));
representation.SetToFormat("%" B_PRIu32, value);
} else {
representation.SetToFormat(B_TRANSLATE(
"<%" B_PRIdOFF " values>"), info.size / sizeof(uint32));
multiValueFormat.Format(representation,
info.size / sizeof(uint32));
}
break;
}
@ -228,8 +237,8 @@ AttributesView::AttributesView(Model* model)
node->ReadAttr(name, info.type, 0, &value, sizeof(value));
representation.SetToFormat("%" B_PRIu64, value);
} else {
representation.SetToFormat(B_TRANSLATE(
"<%" B_PRIdOFF " values>"), info.size / sizeof(int64));
multiValueFormat.Format(representation,
info.size / sizeof(uint64));
}
break;
}
@ -240,16 +249,19 @@ AttributesView::AttributesView(Model* model)
node->ReadAttr(name, info.type, 0, &value, sizeof(value));
representation.SetToFormat("%" B_PRIu8, value);
} else {
representation.SetToFormat(B_TRANSLATE(
"<%" B_PRIdOFF " values>"), info.size / sizeof(int8));
multiValueFormat.Format(representation,
info.size / sizeof(uint8));
}
break;
}
default:
representation.SetToFormat(B_TRANSLATE(
"<%" B_PRIdOFF " bytes of data>"), info.size);
{
BStringFormat sizeFormat(B_TRANSLATE(
"{0, plural, one{<# data byte>} other{<# bytes of data>}}"));
sizeFormat.Format(representation, info.size);
break;
}
}
row->SetField(new BStringField(representation), kValueColumn);
switch(info.type) {