Scope of setting RadGridLocalizationProvider

3 posts, 0 answers
  1. Czeshirecat
    Czeshirecat avatar
    60 posts
    Member since:
    Jun 2016

    Posted 04 May 2018 Link to this post

    What is the scope of setting RadGridLocalizationProvider please?

    When setting it, it doesn't seem to be assigned to anything eg a particular window. So I'm a bit confused whether it should be set once on startup or if it should be set per form.

    On the surface the function "CurrentProvider" appears to be setting.a static variable somewhere, so does the function add the new instance to a list? or does it override a single instance and need resetting after a child form is disposed?

    Sorry if this seems like a dumb question.

      public class GeneralRadGridLocalizationProvider : RadGridLocalizationProvider
      {
        public override string GetLocalizedString(string id)
        {
          switch (id)
          {
            case RadGridStringId.ConditionalFormattingPleaseSetValidCellValue: return GuiResources.Please_set_a_valid_cell_value;
    //foo bar the remaining ids
            case RadGridStringId.ExpressionFormNotButton: return string.Empty; //if empty, default button image is used
          }
          return string.Empty;
        }
      }// class
     
    public function FooBar()
    {
      RadGridLocalizationProvider.CurrentProvider = new GeneralRadGridLocalizationProvider();
    }

  2. Dimitar
    Admin
    Dimitar avatar
    2598 posts

    Posted 04 May 2018 Link to this post

    Hello Claire,

    You need to set the provider only in one place. For example in your main form, and this can be done even before the InitializeComponent call. There is no list and this just a static generic property which is used for retrieving the strings. Here is a snippet from our source code:
    /// <summary>
    /// Gets or sets the current localization provider.
    /// </summary>
    [Browsable(false)]
    public static T CurrentProvider
    {
        get
        {
            return LocalizationProvider<T>.currentProvider;
        }
        set
        {
            if (value == null)
            {
                LocalizationProvider<T>.currentProvider =
                    LocalizationProvider<T>.CreateDefaultLocalizationProvider();
            }
            else
            {
                LocalizationProvider<T>.currentProvider = value;
            }
            LocalizationProvider<T>.OnCurrentProviderChanged();
        }
    }

    I hope this will be useful. Let me know if you have additional questions.

    Regards,
    Dimitar
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  3. Czeshirecat
    Czeshirecat avatar
    60 posts
    Member since:
    Jun 2016

    Posted 04 May 2018 in reply to Dimitar Link to this post

    Many thanks!
Back to Top