Localization on all Telerik component with Blazor

1 Answer 43 Views
Grid
Glendys
Top achievements
Rank 1
Iron
Glendys asked on 14 Mar 2024, 10:49 AM | edited on 14 Mar 2024, 11:00 AM

I implemented the Localization on my project, and I got almost all of them. But the Column Menus and some drop downs aren't translating.

How can I achieve that?

Implementation

Program.cs

            // register a custom localizer for the Telerik components, after registering the Telerik services
            builder.Services.AddSingleton<ITelerikStringLocalizer, TelerikLocalizer>();
            builder.Services.AddLocalization();

TelerikLocalizer.cs

public class TelerikLocalizer : ITelerikStringLocalizer
{
    private readonly IStringLocalizer<Resources> globalLocalizer;

    public TelerikLocalizer(IStringLocalizer<Resources> globalLocalizer)
    {
        this.globalLocalizer = globalLocalizer;
    }

    public string this[string name] => GetStringFromResource(name);

    public string GetStringFromResource(string key)
    {
        var localString = Resources.ResourceManager.GetString(key, Resources.Culture);
        if (string.IsNullOrWhiteSpace(localString))
        {
            return globalLocalizer.GetString(key);
        }
        return localString;
    }
}

I have a list of about 19 languages

Source: https://github.com/telerik/blazor-ui/tree/master/common/localization

1 Answer, 1 is accepted

Sort by
1
Accepted
Hristian Stefanov
Telerik team
answered on 19 Mar 2024, 07:57 AM

Hi Glendys,

From the provided information, it seems that the reason for the problem is that the following keys are missing (or empty) from the .resx resource files because the sample you are referring to does not use a column menu:

  • ColumnMenu_Apply
  • ColumnMenu_ColumnMenu
  • ColumnMenu_Columns
  • ColumnMenu_GroupColumn
  • ColumnMenu_Lock
  • ColumnMenu_ReorderNext
  • ColumnMenu_ReorderPrevious
  • ColumnMenu_Reset
  • ColumnMenu_SetColumnPosition
  • ColumnMenu_SortAscending
  • ColumnMenu_SortDescending
  • ColumnMenu_UngroupColumn
  • ColumnMenu_Unlock

Therefore, ensure to add these keys to the .resx file of each language along with their corresponding translations.

Additionally, for reference, there are two places to obtain localization files:

  • The offline version of our demo site - is maintained by us and contains a limited number of localization files, just as an example of how to implement them. Unfortunately, we are not language experts, so the resx files contain all the localization keys, but we don't vouch that the translations are perfect.
  • The blazor-ui-messages GitHub repository - is maintained by the community. There are more localization files at different levels of "up-to-date-ness", so some localization keys may be missing.

Regards,
Hristian Stefanov
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Telerik family, check out our getting started resources!
Tags
Grid
Asked by
Glendys
Top achievements
Rank 1
Iron
Answers by
Hristian Stefanov
Telerik team
Share this question
or