Files
Atomx/Atomx.Admin/Atomx.Admin.Client/Components/LocalizedText.razor
2025-12-02 13:10:10 +08:00

26 lines
514 B
Plaintext

@inject ILocalizationService LocalizationService
@Text
@code {
private string? _text;
[Parameter]
public string Key { get; set; } = string.Empty;
[Parameter]
public string? Culture { get; set; }
private string Text => _text ?? Key;
protected override async Task OnParametersSetAsync()
{
await LoadText();
}
private async Task LoadText()
{
_text = await LocalizationService.GetStringAsync(Key, Culture) ?? Key;
StateHasChanged();
}
}