Skip to main content
All docs
V25.2
  • DxBlazorViewerLocalizerLocalizationService Class

    Allows you to change localizable text at runtime.

    Namespace: DevExpress.Blazor.Localization

    Assembly: DevExpress.Blazor.v25.2.Viewer.dll

    NuGet Package: DevExpress.Blazor.Viewer

    Declaration

    public class DxBlazorViewerLocalizerLocalizationService :
        IDxViewerLocalizationService,
        IDxLocalizationService

    Remarks

    The DxBlazorViewerStringId enumeration lists the Viewer’s localizable strings. You can implement and register a custom service to replace a specific localizable string with custom text at runtime.

    Create a custom class CustomLocalizationService that inherits from the DxBlazorViewerLocalizerLocalizationService class and override the GetString method:

    using DevExpress.Blazor.Reporting.Localization;
    // ...
    public class CustomLocalizationService: DxBlazorReportViewerLocalizerLocalizationService
    {
        protected override string GetString(string key)
        {
            // The 'key' value identifies a localized string
            switch (key)
            {
                // Customize the specific resource string
                case "DxBlazorViewerStringId.Toolbar_Print":
                    return "Print Document";
                    break;
                // Use the built-in localization for all other strings
                default:
                    return base.GetString(key);
                    break;
            }
        }            
    }
    

    Register the CustomLocalizationService at application startup:

    using Microsoft.AspNetCore.Hosting;
    using DevExpress.Blazor.Localization;
    
    var builder = WebApplication.CreateBuilder(args);
    builder.Services.AddScoped<IDxReportingLocalizationService, CustomLocalizationService>();
    builder.Services.AddScoped<IDxViewerLocalizationService, CustomLocalizationService>();
    var app = builder.Build();
    

    Inheritance

    Object
    DxBlazorViewerLocalizerLocalizationService
    See Also