Cultures should come from supported cultures
This commit is contained in:
parent
932c5590af
commit
c5ae8c979b
|
@ -2,6 +2,7 @@
|
||||||
@inherits ModuleBase
|
@inherits ModuleBase
|
||||||
@using System.Globalization
|
@using System.Globalization
|
||||||
@inject NavigationManager NavigationManager
|
@inject NavigationManager NavigationManager
|
||||||
|
@inject ILocalizationService LocalizationService
|
||||||
@inject ILanguageService LanguageService
|
@inject ILanguageService LanguageService
|
||||||
@inject IStringLocalizer<Add> Localizer
|
@inject IStringLocalizer<Add> Localizer
|
||||||
|
|
||||||
|
@ -11,12 +12,15 @@
|
||||||
<Label For="name" HelpText="Name Of The Langauage" ResourceKey="Name">Name:</Label>
|
<Label For="name" HelpText="Name Of The Langauage" ResourceKey="Name">Name:</Label>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
|
@if (_supportedCultures?.Count() > 1)
|
||||||
|
{
|
||||||
<select id="_code" class="form-control" @bind="@_code">
|
<select id="_code" class="form-control" @bind="@_code">
|
||||||
@foreach (var culture in GetCultures())
|
@foreach (var culture in _supportedCultures)
|
||||||
{
|
{
|
||||||
<option value="@culture.Name">@culture.DisplayName</option>
|
<option value="@culture.Name">@culture.DisplayName</option>
|
||||||
}
|
}
|
||||||
</select>
|
</select>
|
||||||
|
}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -31,7 +35,7 @@
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<button type="button" class="btn btn-success" @onclick="SaveLanguage">@Localizer["Save"]</button>
|
<button type="button" class="btn btn-success @(_supportedCultures?.Count() > 1 ? String.Empty : "disabled")" @onclick="SaveLanguage">@Localizer["Save"]</button>
|
||||||
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@Localizer["Cancel"]</NavLink>
|
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@Localizer["Cancel"]</NavLink>
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
|
@ -40,9 +44,12 @@
|
||||||
|
|
||||||
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
|
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
|
||||||
|
|
||||||
private static IEnumerable<Culture> GetCultures()
|
private IEnumerable<Culture> _supportedCultures;
|
||||||
=> CultureInfo.GetCultures(CultureTypes.AllCultures)
|
|
||||||
.Select(c => new Culture { Name = c.Name, DisplayName = c.DisplayName });
|
protected override async Task OnParametersSetAsync()
|
||||||
|
{
|
||||||
|
_supportedCultures = await LocalizationService.GetCulturesAsync();
|
||||||
|
}
|
||||||
|
|
||||||
private async Task SaveLanguage()
|
private async Task SaveLanguage()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user