This is a migrated thread and some comments may be shown as answers.

DefaultValue annotations doesn't used for localization.

4 Answers 102 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Dzianis
Top achievements
Rank 1
Dzianis asked on 28 Aug 2015, 05:14 PM

Hello. Could you help me, please?

I don't see DefaultValue annotations for elements of interface.

As example I see "DatePopupButtonToolTip" instead of the annotation [DefaultValue("Open the calendar popup.")]

public class DateTimePicker : RadDateTimePicker
{
    private DateTimePicker.BDDatePickingCalendar _calendar;
    private DateTimePicker.BDRadDateInput _dateInput;
 
    public override RadCalendar Calendar
    {
        get
        {
            if (_calendar == null)
            {
                _calendar = new DateTimePicker.BDDatePickingCalendar();
            }
            return _calendar;
        }
    }
 
    public override RadDateInput DateInput
    {
        get
        {
            if (_dateInput == null)
            {
                _dateInput = new DateTimePicker.BDRadDateInput();
            }
            return _dateInput;
        }
    }
 
    public override DateTime? SelectedDate
    {
        get
        {
            return DateInput.SelectedDate;
        }
        set
        {
            base.SelectedDate = value;
            DateInput.SelectedDate = value;
        }
    }
 
    private class BDRadDateInput : RadDateInput
    {
        private string GetClientControlType()
        {
            Attribute clientScriptResource = TypeDescriptor.GetAttributes(this)[typeof(ClientScriptResourceAttribute)];
            return ((ClientScriptResourceAttribute)clientScriptResource).ComponentType;
        }
 
        protected override IEnumerable<ScriptDescriptor> GetScriptDescriptors()
        {
            var descriptor = new DateTimePicker.BDControlScriptDescriptor(GetClientControlType(), ClientID);
            ((IControl)this).DescribeComponent(descriptor);
            return new List<ScriptDescriptor>(new ScriptDescriptor[] { descriptor });
        }
    }
 
    private class BDDatePickingCalendar : DatePickingCalendar
    {
        private string GetClientControlType()
        {
            Attribute clientScriptResource = TypeDescriptor.GetAttributes(this)[typeof(ClientScriptResourceAttribute)];
            return ((ClientScriptResourceAttribute)clientScriptResource).ComponentType;
        }
 
        protected override IEnumerable<ScriptDescriptor> GetScriptDescriptors()
        {
            var descriptor = new DateTimePicker.BDControlScriptDescriptor(GetClientControlType(), ClientID);
            ((IControl)this).DescribeComponent(descriptor);
            return new List<ScriptDescriptor>(new ScriptDescriptor[] { descriptor });
        }
    }
 
    private class BDControlScriptDescriptor : ScriptControlDescriptor, IScriptDescriptor
    {
        public BDControlScriptDescriptor(string type, string elementID)
            : base(type, elementID)
        {
        }
 
        protected override string GetScript()
        {
            return base.GetScript().Replace(@" ", " ");
        }
    }
 
    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);
        EnableAjaxSkinRendering = true;
        Calendar.EnableAjaxSkinRendering = true;
        DateInput.EnableAjaxSkinRendering = true;
    }
} 

4 Answers, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 02 Sep 2015, 07:31 AM
Hello Dzianis,

Thank you for contacting us.

Although that inherited controls are not supported, I have tested the code snippet that you have provided with our latest version and everything is working correctly and the "DatePopupButtonToolTip" is displayed as "Open the calendar popup". Furthermore, I have tested with global resources file and again, no problems occurred. 

If the problem on your side persists, please try with our latest version and see if it will have any difference. If not, please open a regular support ticket and attach a sample, runnable project that replicates the problem, so we can test it locally.


Regards,
Konstantin Dikov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Dzianis
Top achievements
Rank 1
answered on 03 Sep 2015, 04:45 AM

Thank you, Konstantin!

At the moment I resolved the problem by manual translation of values.
I think, the problem can be related with our own global localization mechanism.

Thanks!

0
Dzianis
Top achievements
Rank 1
answered on 03 Sep 2015, 06:15 AM
As you can see on the screenshot. We have square brackets for the value  "[DatePopupButtonToolTip]". I think our code inject the brackets before your code and your code can't find a needed value. :)
0
Konstantin Dikov
Telerik team
answered on 07 Sep 2015, 02:50 PM
Hi Dzianis,

Can you please elaborate on the way that you are setting your custom string values in the control and if you were able to isolate the exact cause of the problem?


Regards,
Konstantin Dikov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Calendar
Asked by
Dzianis
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Dzianis
Top achievements
Rank 1
Share this question
or