Files
radzen-blazor/Radzen.Blazor/ServiceCollectionExtensions.cs
Atanas Korchev 43647e292a Add localization service for RadzenSpreadsheet
Introduce a generic localization infrastructure that ships built-in English
defaults via .resx and allows user overrides through a public ILocalizer
interface. The service is designed to work across all Radzen components.

- Add ILocalizer interface for custom translation overrides
- Add internal Localizer class with fallback chain: custom → .resx → key
- Add RadzenStrings.resx with ~120 spreadsheet string keys
- Add UICulture/DefaultUICulture cascading parameter to RadzenComponent
- Add ISpreadsheet.Localize() for sub-component access
- Replace all hardcoded strings in spreadsheet tools, dialogs, and menus
- Register Localizer in AddRadzenComponents() with graceful fallback
- Works with zero configuration; user overrides are optional
2026-06-15 18:45:06 +03:00

30 lines
951 B
C#

using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
namespace Radzen;
/// <summary>
/// Class with IServiceCollection extensions methods.
/// </summary>
public static class ServiceCollectionExtensions
{
/// <summary>
/// Add Radzen Blazor components services
/// </summary>
/// <param name="services">Service collection</param>
/// <returns>The service collection for chaining.</returns>
public static IServiceCollection AddRadzenComponents(this IServiceCollection services)
{
services.AddScoped<DialogService>();
services.AddScoped<NotificationService>();
services.AddScoped<TooltipService>();
services.AddScoped<ContextMenuService>();
services.AddScoped<ThemeService>();
services.TryAddScoped(sp => new Localizer(sp.GetService<ILocalizer>()));
services.AddAIChatService();
return services;
}
}