mirror of
https://github.com/radzenhq/radzen-blazor.git
synced 2026-07-08 18:16:08 +00:00
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
15 lines
449 B
C#
15 lines
449 B
C#
using System.Globalization;
|
|
using System.Resources;
|
|
|
|
namespace Radzen;
|
|
|
|
internal class Localizer(ILocalizer? custom)
|
|
{
|
|
internal static readonly Localizer Default = new(null);
|
|
|
|
private readonly ILocalizer? custom = custom;
|
|
private readonly ResourceManager resources = Blazor.RadzenStrings.ResourceManager;
|
|
|
|
public string Get(string key, CultureInfo culture) => custom?.Get(key, culture) ?? resources.GetString(key, culture) ?? key;
|
|
}
|