mirror of
https://gitee.com/ant-design-blazor/ant-design-blazor.git
synced 2024-12-04 21:17:36 +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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!item.IsSelected)
|
|
||||||
{
|
|
||||||
item.Select();
|
|
||||||
|
|
||||||
foreach (MenuItem menuitem in MenuItems.Where(x => x != item))
|
foreach (MenuItem menuitem in MenuItems.Where(x => x != item))
|
||||||
{
|
{
|
||||||
menuitem.Deselect();
|
menuitem.Deselect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!item.IsSelected)
|
||||||
|
{
|
||||||
|
item.Select();
|
||||||
}
|
}
|
||||||
|
|
||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
|
@ -26,8 +26,6 @@ namespace AntDesign.Docs.Routing
|
|||||||
|
|
||||||
[Parameter] public string DefaultUrl { get; set; }
|
[Parameter] public string DefaultUrl { get; set; }
|
||||||
|
|
||||||
private static CultureInfo[] AllCultureInfos => CultureInfo.GetCultures(CultureTypes.AllCultures);
|
|
||||||
|
|
||||||
public void Attach(RenderHandle renderHandle)
|
public void Attach(RenderHandle renderHandle)
|
||||||
{
|
{
|
||||||
_renderHandle = renderHandle;
|
_renderHandle = renderHandle;
|
||||||
@ -93,19 +91,23 @@ namespace AntDesign.Docs.Routing
|
|||||||
|
|
||||||
var currentCulture = LanguageService.CurrentCulture;
|
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);
|
NavigationManager.NavigateTo($"{currentCulture.Name}/{relativeUri}", true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (AllCultureInfos.Any(x => x.Name == segment))
|
if (segment.IsIn("zh-CN", "en-US"))
|
||||||
{
|
{
|
||||||
LanguageService.SetLanguage(CultureInfo.GetCultureInfo(segment));
|
LanguageService.SetLanguage(CultureInfo.GetCultureInfo(segment));
|
||||||
}
|
}
|
||||||
|
else if (currentCulture.Name.IsIn("zh-CN", "en-US"))
|
||||||
|
{
|
||||||
|
NavigationManager.NavigateTo($"{currentCulture.Name}/{relativeUri}", true);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
NavigationManager.NavigateTo($"en-US/{relativeUri}", true);
|
NavigationManager.NavigateTo($"en-US/{relativeUri}", true);
|
||||||
|
Loading…
Reference in New Issue
Block a user