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

Scope of setting RadGridLocalizationProvider

2 Answers 18 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Czeshirecat
Top achievements
Rank 1
Czeshirecat asked on 04 May 2018, 11:33 AM

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 Answers, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 04 May 2018, 12:16 PM
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.
0
Czeshirecat
Top achievements
Rank 1
answered on 04 May 2018, 12:46 PM
Many thanks!
Tags
GridView
Asked by
Czeshirecat
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Czeshirecat
Top achievements
Rank 1
Share this question
or