How to localize my text in DropDownList

1 Answer 31 Views
DropDownList
Fabian
Top achievements
Rank 1
Fabian asked on 27 Feb 2025, 12:30 PM

A DropDownList receives a List of Items and then displays the field I select via Reflection. In the example below that would be the "Text" field. How would I create a localized text in an easy way. I already inject the IStringLocalizer into this component but I cannot pass a method call to the dropdownlist as far as I know. Is there a way to tell Telerik globally to use my Localizer to translate all strings that would be rendered or sth like that? I have several ideas how I could add Localizations but they all seem rather complicated and I would like to know the intended way.

 <TelerikDropDownList Data="@Data"
                                         @bind-Value="@SelectedValue"
                                          TextField="@nameof(MyType.Text)"/>

1 Answer, 1 is accepted

Sort by
0
Tsvetomir
Telerik team
answered on 04 Mar 2025, 07:46 AM

Hello Fabian,

To add localization to your application, refer to our localization documentation to gather more information and follow the step-by-step approach - Localization. Also, you can find sample runnable projects for both server-side Blazor and for WebAssembly in the Telerik Blazor UI Samples Repo.

I hope the provided information helps you to move forward with your requirements.

Regards,
Tsvetomir
Progress Telerik

Enjoyed our products? Share your experience on G2 and receive a $25 Amazon gift card for a limited time!

Fabian
Top achievements
Rank 1
commented on 04 Mar 2025, 04:01 PM | edited

I followed the Localization guide and it help me with the localization of text/strings which are being used by Telerik internally. I also checked out the server-side sample project and it contains exactly my problem. If you look into the weather page component lines 20- 24, we are giving the GridColumn only the name of the field and then the column is being filled with the appropriate values. In my case I want to be able to translate these column values similar to how the dates change due to the culture change. In your example the "summary" column values are also not being translated. I also want to avoid using Templates if possible
Tsvetomir
Telerik team
commented on 07 Mar 2025, 06:06 AM

Hello Fabian,

The localization feature in Telerik components works with localization keys, which target labels, messages, and internal text generated by the component itself—it does not apply to the actual data bound to the Grid. This is why the column values (such as the "summary" column in the example) are not automatically translated. The dates appear localized because they are formatted based on the culture settings of the machine.

For translating the data within the Grid, there are two possible alternatives:

  • Use localization keys for each value – This means mapping each column value to a corresponding localization key and providing translations in your resource files.
  • Use Templates – While you prefer to avoid templates, this approach allows you to manually translate values dynamically based on the selected culture.

Regards,

Tsvetomir

Tags
DropDownList
Asked by
Fabian
Top achievements
Rank 1
Answers by
Tsvetomir
Telerik team
Share this question
or