RadTimePicker Localization Close Button Text

13 posts, 1 answers
  1. Peter
    Peter avatar
    16 posts
    Member since:
    Apr 2012

    Posted 27 Apr 2012 Link to this post

    Hi,

    I use the RadControls for WinForms Q1 2012 SP1. I've localized my RadTimePicker Strings in C# exactly as you recommended it here. But the close button doesn't change to the localized string. Can you help me? 

    Best, 

    Peter 
  2. Answer
    Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 27 Apr 2012 Link to this post

    Hi Peter, 

    Using version 2012.1.321.40 this all seems to be working as expected. If you are not on the latest version, I would suggest upgrading. Can you please try this sample. 

    public Form1()
    {
        InitializeComponent();
        RadTimePickerLocalizationProvider.CurrentProvider = new MyTimePickerLocalizationProvider();
    }

    class MyTimePickerLocalizationProvider : RadTimePickerLocalizationProvider
     {
         public override string GetLocalizedString(string id)
         {
             switch (id)
             {
                 case RadTimePickerStringId.HourHeaderText: return "Hours (local)";
                 case RadTimePickerStringId.MinutesHeaderText: return "Minutes (local)";
                 case RadTimePickerStringId.CloseButtonText: return "Close (local)";
                 default: return string.Empty;
             }
         }
     }

    If this resolves your issue, please remember to mark as answer. If you need further help, please let me know
    Richard
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Peter
    Peter avatar
    16 posts
    Member since:
    Apr 2012

    Posted 27 Apr 2012 Link to this post

    The Mistake was to do it like this: 

    static Form1()
    {
        RadTimePickerLocalizationProvider.CurrentProvider = new MyTimePickerLocalizationProvider();
    }
     
    public Form1()
    {
        InitializeComponent();
    }

    Also this doesn't work (close button doesn't get localized):

    public Form1()
    {
        RadTimePickerLocalizationProvider.CurrentProvider = new MyTimePickerLocalizationProvider();
        InitializeComponent();
    }

    Just this version works fine (everything localized):

    public Form1()
    {
        InitializeComponent();
        RadTimePickerLocalizationProvider.CurrentProvider = new MyTimePickerLocalizationProvider();
    }


    Thank you for your help.

    Best,

    Peter
  5. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 02 May 2012 Link to this post

    Hello Peter,

    That is correct. You need to set the localization provider after the InitializeComponent call because before this call the control is not yet initialized.

    I hope this helps.
     
    All the best,
    Stefan
    the Telerik team
    RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
  6. acasegra
    acasegra avatar
    4 posts
    Member since:
    Apr 2011

    Posted 25 May 2012 Link to this post

    hello,
    can you help to me?
      hi, im test it but close button
      case RadTimePickerStringId.HourHeaderText: return "Hora"; >>>>>>its ok
      case RadTimePickerStringId.MinutesHeaderText: return "Minutos";>>>>>>its ok
      case RadTimePickerStringId.CloseButtonText: return "Cerrar";>>>>>>don't  work
    best regards.
    Alfonso
  7. Peter
    Admin
    Peter avatar
    1148 posts

    Posted 30 May 2012 Link to this post

    Hi Peter,

    Thank you for contacting Telerik support.

    We are aware of this issue and we provided a fix for it in our latest internal release (v2012.1.517)
    As a workaround in your version you can set the localization provider after the InitializeComponent method, for example:

    public partial class Form1 : Form
       {
           public Form1()
           {
               InitializeComponent();
     
               RadTimePickerLocalizationProvider.CurrentProvider = new MyRadTimePickerLocalizationProvider();
           }
       }

    I hope this helps. Greetings,
    Peter
    the Telerik team
    RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
  8. acasegra
    acasegra avatar
    4 posts
    Member since:
    Apr 2011

    Posted 30 May 2012 Link to this post

    i do it and so
    the 2 first line work fine
    case RadTimePickerStringId.HourHeaderText: return "Hora"; //its ok
      case RadTimePickerStringId.MinutesHeaderText: return "Minutos";//ts ok

    but the 3rd dont work

      case RadTimePickerStringId.CloseButtonText: return "Cerrar"; //don't  work

    best regards Alfonso
  9. Peter
    Admin
    Peter avatar
    1148 posts

    Posted 31 May 2012 Link to this post

    Hello,

    As I mentioned before, we provided a fix for it in our latest internal build (v2012.1.517)

    I hope this helps.

    Greetings,
    Peter
    the Telerik team
    RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
  10. Matthew Compton
    Matthew Compton avatar
    7 posts
    Member since:
    Aug 2012

    Posted 13 Jul 2012 Link to this post

    Is there any way around upgrading the controls?  We are at a point in our dev cycle where it is not feasible. 

    I was able to translate content in the CellEditorInitialized event for a RadDateTimePicker.   Is there a way to do the same with the RadTimePicker. 

    I am on version v2012.1.12.215
            
    RadDateTimeEditorElement editorElement = (RadDateTimeEditorElement)editor.EditorElement;
    RadDateTimePickerCalendar calenderBehaviour = (RadDateTimePickerCalendar)editorElement.GetCurrentBehavior();
    RadCalendar calendar = (RadCalendar)calenderBehaviour.Calendar;
    calendar.TodayButton.Text = LocSystemLabels.GetString("Today");
    calendar.ClearButton.Text = LocSystemLabels.GetString("Clear");
  11. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 16 Jul 2012 Link to this post

    Hello Matthew,

    Yes, there is a way. Here is how to do that:
    void radGridView1_EditorRequired(object sender, EditorRequiredEventArgs e)
    {
        if (e.EditorType == typeof(RadDateTimeEditor))
        {
            e.Editor = new RadTimePickerElement();
        }
    }
     
    void radGridView1_CellEditorInitialized(object sender, GridViewCellEventArgs e)
    {
        RadTimePickerElement el = e.ActiveEditor as RadTimePickerElement;
        if (el != null)
        {
            el.PopupOpened -= new EventHandler(el_PopupOpened);
            el.PopupOpened += new EventHandler(el_PopupOpened);
             
        }
    }
     
    void el_PopupOpened(object sender, EventArgs e)
    {
        RadTimePickerElement el = sender as RadTimePickerElement;
        el.PopupContentElement.HoursTable.TableHeader.HeaderElement.Text = "your text here";
        el.PopupContentElement.MinutesTable.TableHeader.HeaderElement.Text = "your text here";
        el.PopupContentElement.FooterPanel.ButtonElement.Text = "your text here";
    }

    I hope this helps.

    Kind regards,
    Stefan
    the Telerik team
    RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
  12. Matthew Compton
    Matthew Compton avatar
    7 posts
    Member since:
    Aug 2012

    Posted 16 Jul 2012 Link to this post

    Great, thanks Stefan.  That does help, although I am experiencing a little different behaviour when changing this code.  When using the TimePickerEditor I am able to use the arrow keys to change the time without loading the TimePicker.  Is there a way to have the best of both worlds?

    void radGridView1_EditorRequired(object sender, EditorRequiredEventArgs e)
    {
        if (e.EditorType == typeof(RadDateTimeEditor))
        {
            //e.Editor = new RadTimePickerElement();
            e.Editor = new TimePickerEditor();
        }
    }
  13. Matthew Compton
    Matthew Compton avatar
    7 posts
    Member since:
    Aug 2012

    Posted 18 Jul 2012 Link to this post

    You can disregard this.  I am overloading the timepicker already and moved the localization code in there.   thanks for your help.
  14. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 19 Jul 2012 Link to this post

    You are welcome. Should you have any other questions, do not hesitate to contact us.

    Greetings,
    Stefan
    the Telerik team
    RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
Back to Top
UI for WinForms is Visual Studio 2017 Ready