Hi,
I want to change the language of the filter in a excel like grid. I try this solutions :
-----------------------------------------------------------------------------------------------
Thread.CurrentThread.CurrentCulture = new CultureInfo("fr-FR");
Thread.CurrentThread.CurrentUICulture = new CultureInfo("fr-FR");
-----------------------------------------------------------------------------------------------
The culture is fr-FR but the calendar and the labels of the filters are in english.
Can I have some help ? Thank you
Best regards,
Audrey
2 Answers, 1 is accepted
Hi Audrey,
In order to Localize the Grid, you can do that using Global Resources and/or Resource files.
Please check out the following articles:
- Localization through Global Resources - documentation
- Localization through Resource Files - documentation
- Grid - Localization online demo.
For your convenience, I have attached the French resource file to my response. Add this to the App_GlobalResources folder in your project.
Here is the result using Global Resources:
I hope this will be helpful.
Kind regards,
Attila Antal
Progress Telerik
Hi Attila,
Is it posible to localize the 'Check All' and 'Search'? I can't find it in the resx file.
Kind regards,
Dieter
Hi Audrey,
Due to the current implementation, the CheckBox items in the ListBox do not take the Culture from the Grid's "Culture" property, however, if you apply the culture to the page, directly, the Checkboxes will render with that culture.
Setting the Culture in the Page directive
<%@ Page Language="C#" AutoEventWireup="true" Culture="fr-FR" UICulture="fr-FR" CodeFile="Default.aspx.cs" Inherits="Default" %>
Setting the culture programmatically
protected void Page_Init(object sender, EventArgs e)
{
System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.GetCultureInfo("fr-FR");
System.Threading.Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.GetCultureInfo("fr-FR");
}
Resource file
Besides setting the culture, you will also need to have the Resource file for the ListBox, e.g. "RadListBox.fr-FR.resx"
Change the "CheckAll" string to anything you like:
Result
I hope this will prove helpful.
Regards,
Attila Antal
Progress Telerik
Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.
Hi Attila,
Thanks for the answers, the translations are working almost perfectly.
What about the "Search" in the TextBox ?
I tried to find a translation in RadSearchBox.resx file, but I didn't find any.
Regards,
Bandelier Matthieu
CLA Clinical Laboratory Automation SA
Hi Mat,
The Search part of the Filter is actually a RadTextBox and the EmptyMessage is hardcoded to "Search" in the source code.
If you'd like to change the text, you can do that in the PreRenderComplete event of the Page's LifeCycle.
protected override void OnPreRenderComplete(EventArgs e)
{
RadContextMenu menu = RadGrid1.HeaderContextMenu;
RadTextBox filterCheckListSearch = menu.FindItemByValue("FilterList").FindControl("filterCheckListSearch") as RadTextBox;
filterCheckListSearch.EmptyMessage = "New Text";
base.OnPreRenderComplete(e);
}
Or if you would like to use the Global Resources file, you can point to the resource like this:
filterCheckListSearch.EmptyMessage = Resources.RadGrid.Main.FilterCheckListSearch;
Add the "FilterCheckListSearch" entry to both the RadGrid.Main.resx and RadGrid.Main.fr-FR.resx files.
RadGrid.Main.resx
RadGrid.Main.fr-FR.resx
Then you can switch between different Cultures:
<%@ Page Culture="en-US" UICulture="en-US"
Result
<%@ Page Culture="fr-FR" UICulture="fr-FR"
Result
Thx for your quick answer. It works like a charm !
I had to adapt your code a little bit because I can't override OnPreRenderComplete directly in a UserControl.
I hope I do things right :
public class MyControl : UserControl
{
protected override void OnInit(EventArgs e)
{
this.Page.PreRenderComplete += new EventHandler(OnPreRenderComplete);
}
protected void OnPreRenderComplete(Object sender, EventArgs e)
{
RadContextMenu menu = myGridInsideMyControl.HeaderContextMenu;
RadTextBox filterCheckListSearch = menu.FindItemByValue("FilterList").FindControl("filterCheckListSearch") as RadTextBox;
filterCheckListSearch.EmptyMessage = "New Text"
}
}
Hi Mat.
Yes, you're doing it right.