!783 feat(#I2A35U): add localization feature for Tab

* feat: Tab 组件增加本地化功能
This commit is contained in:
Argo 2020-12-20 17:21:00 +08:00
parent a8735b4a77
commit 909a56b2d0
4 changed files with 46 additions and 6 deletions

View File

@ -54,10 +54,10 @@
<div class="dropdown nav-link-bar dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<div class="nav-link-close"><i class="fa fa-chevron-down"></i></div>
</div>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="关闭标签下拉菜单">
<div class="dropdown-item" @onclick="CloseCurrentTab"><span>关闭当前标签</span></div>
<div class="dropdown-item" @onclick="CloseOtherTab"><span>关闭其他标签</span></div>
<div class="dropdown-item" @onclick="CloseAllTab"><span>关闭所有标签</span></div>
<div class="dropdown-menu dropdown-menu-right">
<div class="dropdown-item" @onclick="CloseCurrentTab"><span>@CloseCurrentTabText</span></div>
<div class="dropdown-item" @onclick="CloseOtherTabs"><span>@CloseOtherTabsText</span></div>
<div class="dropdown-item" @onclick="CloseAllTabs"><span>@CloseAllTabsText</span></div>
</div>
}
else

View File

@ -9,6 +9,7 @@
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Routing;
using Microsoft.Extensions.Localization;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
@ -152,6 +153,31 @@ namespace BootstrapBlazor.Components
[Parameter]
public Func<TabItem, Task>? OnClickTab { get; set; }
/// <summary>
/// 获得/设置 关闭当前 TabItem 菜单文本
/// </summary>
[Parameter]
[NotNull]
public string? CloseCurrentTabText { get; set; }
/// <summary>
/// 获得/设置 关闭所有 TabItem 菜单文本
/// </summary>
[Parameter]
[NotNull]
public string? CloseAllTabsText { get; set; }
/// <summary>
/// 获得/设置 关闭其他 TabItem 菜单文本
/// </summary>
[Parameter]
[NotNull]
public string? CloseOtherTabsText { get; set; }
[Inject]
[NotNull]
private IStringLocalizer<Tab>? Localizer { get; set; }
[Inject]
[NotNull]
private NavigationManager? Navigator { get; set; }
@ -169,6 +195,10 @@ namespace BootstrapBlazor.Components
if (ShowExtendButtons) IsBorderCard = true;
CloseOtherTabsText ??= Localizer[nameof(CloseOtherTabsText)];
CloseAllTabsText ??= Localizer[nameof(CloseAllTabsText)];
CloseCurrentTabText ??= Localizer[nameof(CloseCurrentTabText)];
await InitRouteTable();
}
@ -320,7 +350,7 @@ namespace BootstrapBlazor.Components
/// <summary>
/// 关闭所有标签页方法
/// </summary>
private void CloseAllTab()
private void CloseAllTabs()
{
_items.RemoveAll(t => t.Closable);
}
@ -337,7 +367,7 @@ namespace BootstrapBlazor.Components
/// <summary>
/// 关闭其他标签页方法
/// </summary>
private void CloseOtherTab()
private void CloseOtherTabs()
{
_items.RemoveAll(t => t.Closable && !t.IsActive);
}

View File

@ -150,6 +150,11 @@
"OnInnerText": "On",
"OffInnerText": "Off"
},
"BootstrapBlazor.Components.Tab": {
"CloseCurrentTabText": "Close",
"CloseOtherTabsText": "Close Other",
"CloseAllTabsText": "Close All"
},
"BootstrapBlazor.Components.Table": {
"AddButtonText": "Add",
"EditButtonText": "Edit",

View File

@ -150,6 +150,11 @@
"OnInnerText": "开",
"OffInnerText": "关"
},
"BootstrapBlazor.Components.Tab": {
"CloseCurrentTabText": "关闭当前标签",
"CloseOtherTabsText": "关闭其他标签",
"CloseAllTabsText": "关闭所有标签"
},
"BootstrapBlazor.Components.Table": {
"AddButtonText": "新建",
"EditButtonText": "编辑",