docs: follow up the .net 5 docs and fix the culture issue (#615)

This commit is contained in:
James Yeung 2020-09-17 16:42:23 +08:00 committed by GitHub
parent e95ee75f80
commit 20c1197793
2 changed files with 12 additions and 10 deletions

View File

@ -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();

View File

@ -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);