mirror of
https://gitee.com/ant-design-blazor/ant-design-blazor.git
synced 2024-12-03 12:37:40 +08:00
docs: follow up the .net 5 docs and fix the culture issue (#615)
This commit is contained in:
parent
e95ee75f80
commit
20c1197793
@ -124,14 +124,14 @@ namespace AntDesign
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (MenuItem menuitem in MenuItems.Where(x => x != item))
|
||||
{
|
||||
menuitem.Deselect();
|
||||
}
|
||||
|
||||
if (!item.IsSelected)
|
||||
{
|
||||
item.Select();
|
||||
|
||||
foreach (MenuItem menuitem in MenuItems.Where(x => x != item))
|
||||
{
|
||||
menuitem.Deselect();
|
||||
}
|
||||
}
|
||||
|
||||
StateHasChanged();
|
||||
|
@ -26,8 +26,6 @@ namespace AntDesign.Docs.Routing
|
||||
|
||||
[Parameter] public string DefaultUrl { get; set; }
|
||||
|
||||
private static CultureInfo[] AllCultureInfos => CultureInfo.GetCultures(CultureTypes.AllCultures);
|
||||
|
||||
public void Attach(RenderHandle renderHandle)
|
||||
{
|
||||
_renderHandle = renderHandle;
|
||||
@ -93,19 +91,23 @@ namespace AntDesign.Docs.Routing
|
||||
|
||||
var currentCulture = LanguageService.CurrentCulture;
|
||||
|
||||
var segment = relativeUri.IndexOf('/') > 0 ? relativeUri.Substring(0, relativeUri.IndexOf('/')) : null;
|
||||
var segment = relativeUri.IndexOf('/') > 0 ? relativeUri.Substring(0, relativeUri.IndexOf('/')) : relativeUri;
|
||||
|
||||
if (segment == null)
|
||||
if (string.IsNullOrWhiteSpace(segment))
|
||||
{
|
||||
NavigationManager.NavigateTo($"{currentCulture.Name}/{relativeUri}", true);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (AllCultureInfos.Any(x => x.Name == segment))
|
||||
if (segment.IsIn("zh-CN", "en-US"))
|
||||
{
|
||||
LanguageService.SetLanguage(CultureInfo.GetCultureInfo(segment));
|
||||
}
|
||||
else if (currentCulture.Name.IsIn("zh-CN", "en-US"))
|
||||
{
|
||||
NavigationManager.NavigateTo($"{currentCulture.Name}/{relativeUri}", true);
|
||||
}
|
||||
else
|
||||
{
|
||||
NavigationManager.NavigateTo($"en-US/{relativeUri}", true);
|
||||
|
Loading…
Reference in New Issue
Block a user