mirror of
https://github.com/radzenhq/radzen-blazor.git
synced 2026-07-08 18:16:08 +00:00
Ship satellite resource files (RadzenStrings.{de,fr,es,it,ja}.resx) with all
535 strings translated, so components localize out of the box via the standard
.NET ResourceManager.
Make culture handling reactive everywhere:
- RadzenDatePicker rebuilds its month/year lists when Culture or the
DefaultCulture cascade changes (previously cached at init).
- Scheduler views, HtmlEditor tools and the spreadsheet ChartOverlay localize
through their parent component's UICulture instead of CurrentUICulture;
spreadsheet dialogs honor a DefaultUICulture cascade. UICulture is added to
IScheduler/ISpreadsheet as default interface members, so this is non-breaking.
Update the Localization demo with an interactive language switcher (cascading
DefaultUICulture + DefaultCulture) backed by an ILocalizer so it works in-place
on Blazor WebAssembly.
125 lines
4.0 KiB
C#
125 lines
4.0 KiB
C#
using System;
|
|
using Radzen;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.AspNetCore.Components;
|
|
using System.Globalization;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Radzen.Blazor;
|
|
|
|
namespace Radzen.Blazor
|
|
{
|
|
/// <summary>
|
|
/// A base class for <see cref="RadzenScheduler{TItem}" /> views.
|
|
/// </summary>
|
|
public abstract class SchedulerViewBase : ComponentBase, ISchedulerView, IDisposable
|
|
{
|
|
[Inject]
|
|
private IServiceProvider Services { get; set; } = default!;
|
|
|
|
private Localizer? localizer;
|
|
|
|
internal Localizer Localizer => localizer ??=
|
|
Services.GetService<Localizer>() ?? Localizer.Default;
|
|
|
|
/// <summary>
|
|
/// Gets a localized string for the specified resource key.
|
|
/// </summary>
|
|
public string Localize(string key) => Localizer.Get(key, Scheduler?.UICulture ?? CultureInfo.CurrentUICulture);
|
|
|
|
/// <summary>
|
|
/// Gets the title of the view. It is displayed in the RadzenScheduler title area.
|
|
/// </summary>
|
|
/// <value>The title.</value>
|
|
public abstract string Title { get; }
|
|
|
|
/// <summary>
|
|
/// Gets the icon of the view. It is displayed in the view switching UI.
|
|
/// </summary>
|
|
public abstract string Icon { get; }
|
|
|
|
/// <summary>
|
|
/// Gets the text of the view. It is displayed in the view switching UI.
|
|
/// </summary>
|
|
/// <value>The text.</value>
|
|
public abstract string Text { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the scheduler instance.
|
|
/// </summary>
|
|
/// <value>The scheduler.</value>
|
|
[CascadingParameter]
|
|
public IScheduler? Scheduler { get; set; }
|
|
|
|
|
|
/// <summary>
|
|
/// Disposes this instance.
|
|
/// </summary>
|
|
public void Dispose()
|
|
{
|
|
Scheduler?.RemoveView(this);
|
|
GC.SuppressFinalize(this);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Called by the Blazor runtime when parameters are set.
|
|
/// </summary>
|
|
/// <param name="parameters">The parameters.</param>
|
|
public override async Task SetParametersAsync(ParameterView parameters)
|
|
{
|
|
var textChanged = parameters.DidParameterChange(nameof(Text), Text);
|
|
|
|
await base.SetParametersAsync(parameters);
|
|
|
|
if (textChanged && Scheduler != null)
|
|
{
|
|
await Scheduler.Reload();
|
|
}
|
|
|
|
if (Scheduler != null)
|
|
{
|
|
await Scheduler.AddView(this);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Returns a new date when the user clicks the next button of RadzenScheduler.
|
|
/// </summary>
|
|
/// <returns>The next date. For example a day view will return the next day, a week view will return the next week.</returns>
|
|
public abstract DateTime Next();
|
|
|
|
/// <summary>
|
|
/// Returns a new date when the user clicks the previous button of RadzenScheduler.
|
|
/// </summary>
|
|
/// <returns>The previous date. For example a day view will return the previous day, a week view will return the previous week.</returns>
|
|
public abstract DateTime Prev();
|
|
|
|
/// <summary>
|
|
/// Renders this instance.
|
|
/// </summary>
|
|
public abstract RenderFragment Render();
|
|
|
|
/// <summary>
|
|
/// Gets the start date.
|
|
/// </summary>
|
|
/// <value>The start date.</value>
|
|
public abstract DateTime StartDate { get; }
|
|
/// <summary>
|
|
/// Gets the end date.
|
|
/// </summary>
|
|
/// <value>The end date.</value>
|
|
public abstract DateTime EndDate { get; }
|
|
|
|
/// <summary>
|
|
/// Handles appointent move event.
|
|
/// </summary>
|
|
/// <param name="data"></param>
|
|
/// <returns></returns>
|
|
public async Task OnAppointmentMove(SchedulerAppointmentMoveEventArgs data)
|
|
{
|
|
if (Scheduler != null)
|
|
{
|
|
await Scheduler.AppointmentMove.InvokeAsync(data);
|
|
}
|
|
}
|
|
}
|
|
} |