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

Grid Excel like filter - change the language

2 Answers 266 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Audrey
Top achievements
Rank 1
Audrey asked on 17 Oct 2019, 12:00 PM

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

Sort by
0
Attila Antal
Telerik team
answered on 22 Oct 2019, 08:10 AM

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:

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

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Jos
Top achievements
Rank 1
commented on 16 Feb 2022, 11:00 AM

Hi Attila,

Is it posible to localize the 'Check All' and 'Search'? I can't find it in the resx file.

Kind regards,

Dieter

0
Attila Antal
Telerik team
answered on 21 Feb 2022, 09:31 AM

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.

Mat
Top achievements
Rank 1
commented on 06 Jul 2022, 11:16 AM | edited

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

Attila Antal
Telerik team
commented on 06 Jul 2022, 01:36 PM

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


Mat
Top achievements
Rank 1
commented on 08 Jul 2022, 07:18 AM | edited

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" } }


Attila Antal
Telerik team
commented on 08 Jul 2022, 07:29 AM

Hi Mat. 

Yes, you're doing it right.

Tags
Grid
Asked by
Audrey
Top achievements
Rank 1
Answers by
Attila Antal
Telerik team
Share this question
or