Localization
The localization support for RadFilter lets you completely translate the user interface, or simply adapt a few strings.
Localization Property
The Localization property specifies the strings that appear in the runtime user interface of the filter, including the message pop-up dialogs and edit forms. By changing the values of each named sub-property, you change the appearance of the string the RadFilter uses:
<telerik:RadFilter RenderMode="Lightweight" ID="RadFilter1" runat="server">
<Localization GroupOperationAnd="My AND Operation" />
</telerik:RadFilter>
The RadFilter control extracts the header text from the grid column when filter container is the RadGrid control and use it as DisplayName. In case of other container control by default RadFilter uses the FieldName as DisplayName. In case of declarative field editors you could customize the name of the fields displayed in RadFilter as shown bellow:
<telerik:RadFilter RenderMode="Lightweight" ID="RadFilter1" runat="server" Culture="bg-BG">
<Localization GroupOperationAnd="My AND Operation" />
<FieldEditors>
<telerik:RadFilterTextFieldEditor FieldName="Name1" DisplayName="Custom Text" />
</FieldEditors>
</telerik:RadFilter>
To customize the name of the fields when using filter container control you could set meaningful HeaderText in the columns in RadGrid or handles OnFieldEditorCreated server-side event to modify the DisplayName of RadFilter editor programmatically.
<telerik:RadFilter RenderMode="Lightweight" runat="server" ID="RadFilter1" Culture="bg-BG" FilterContainerID="RadGrid1"
OnFieldEditorCreated="RadFilter1_FieldEditorCreated" ShowApplyButton="true">
</telerik:RadFilter>
Global Resource Files
The primary means for localization in ASP.NET is to use resource files. Resource files are simple XML files that can be easily edited and transferred to other applications. You can use resource files to change the default (English) localization for RadFilter that is stored in the Telerik.Web.UI assembly.
RadFilter's default Culture is taken from the page's CurrentUICulture .
To create a global resource file to localize the filter:
-
Create the App_GlobalResources folder in the root of your web application.
-
Copy the default resource RadFilter.Main.resx file into it. This file can be found in the App_GlobalResources folder of the directory where you installed the Telerik controls. Usually the path to the localization files is similar to (the version number differs):
C:\Program Files (x86)\Progress\Telerik UI for ASP.NET AJAX R2 2021\App_GlobalResources
- Make a copy of the file and rename the copy so that its name contains the Culture Identifier. The resource files used by RadFilter follow a strict naming convention:RadFilter.Main.
.resx
The Culture Identifier consists of a language code followed by a dash and the country code. Example: “en-US”, “fr-CA”, “bg-BG” and so on.
For example RadFilter.Main.bg-BG.resx. Both files should be present in the App_GlobalResources folder:
-
Edit the strings using the Visual Studio editor or your favorite text editor. Customize strings just as you would set the Localization property.
Make sure that the ReservedResource message is preserved. It is used for identification purposes and is never displayed.
You can now switch the filter so that it uses your new resource file by setting the active culture: