Is it in this place that I need to localize trueval and falseval in
Actually, no. The "right" place depends on the app. In the more
complex case, if you need to support multiple cultures *at the same
time* then the correct approach would be to use the culture passed
into ConvertTo/ConvertFrom. However, if you only need to support a
single culture (typical for a windows client), then I would use some
static fields:
(this example uses resx file)
// public ctor (required to work)
public MyBooleanConverter() { }
// private static true/false values
private static readonly string trueVal, falseVal;
static MyBooleanConverter()
{
trueVal =
WindowsFormsApplication1.Properties.Resources.TrueText;
falseVal =
WindowsFormsApplication1.Properties.Resources.FalseText;
}
Is it for the CategoryAttribute ?
The one I posted (DisplayName) controls the name that appears for the
property. Category is done slightly differently:
(this example just shows simple case - but you can generalise using
Properties.Resources.ResourceManager.GetString(whatever))
class MyCategoryAttribute : CategoryAttribute
{
public MyCategoryAttribute(string category) : base(category) { }
protected override string GetLocalizedString(string value)
{
return "Translated";
}
}
If you return null from GetLocalizedString() then it uses the original
text as a default. If you return an empty string ("") it dispays
"Misc".