How to localize WebParts attributes within the PropertyEditorPart?
Is there any way to localize the text displayed within the PropertyEditorPart
?
[Personalizable(true),
WebBrowsable(true),
WebDisplayName("To Date: "),
WebDescription("Please enter To Date value.")]
public string To开发者_开发技巧Date
{
get { return toDate; }
set { toDate = value; }
}
To achieve this, these attributes (Category, WebDisplayName and WebDescription) should be extended so they take advantage of the localization features.
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)]
public sealed class LocalizedWebDisplayNameAttribute
: WebDisplayNameAttribute {
bool m_isLocalized ;
public LocalizedWebDisplayNameAttribute(string displayName)
: base(displayName) {
}
public override string DisplayName {
get {
if (!m_isLocalized) {
this.DisplayNameValue =
Resources.ResourceManager.GetString(
base.DisplayName, Resources.Culture);
m_isLocalized = true;
}
return base.DisplayName;
}
}
}
More details, Web Part Properties - part 5 - localization
精彩评论