mirror of
https://gitee.com/ant-design-blazor/ant-design-blazor.git
synced 2024-12-02 03:57:38 +08:00
fix(module: popconfirm): missing built-in localization (#3095)
This commit is contained in:
parent
0289f1433b
commit
94481f3719
@ -16,14 +16,17 @@ namespace AntDesign
|
||||
public RenderFragment TitleTemplate { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public string CancelText { get; set; } = "Cancel";
|
||||
public string CancelText { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public string OkText { get; set; } = "OK";
|
||||
public string OkText { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public string OkType { get; set; } = "primary";
|
||||
|
||||
[Parameter]
|
||||
public PopconfirmLocale Locale { get; set; } = LocaleProvider.CurrentLocale.Popconfirm;
|
||||
|
||||
[Parameter]
|
||||
public ButtonProps OkButtonProps { get; set; }
|
||||
|
||||
@ -59,6 +62,12 @@ namespace AntDesign
|
||||
Trigger = new[] { AntDesign.Trigger.Click };
|
||||
}
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
OkText ??= Locale.OkText ?? "Ok";
|
||||
CancelText ??= Locale.CancelText ?? "Cancel";
|
||||
}
|
||||
|
||||
internal override async Task Show(int? overlayLeft = null, int? overlayTop = null)
|
||||
{
|
||||
if (Trigger.Contains(AntDesign.Trigger.Hover))
|
||||
|
@ -6,8 +6,8 @@ namespace AntDesign
|
||||
{
|
||||
public class PopconfirmLocale
|
||||
{
|
||||
public string CancelText { get; set; } = "OK";
|
||||
public string CancelText { get; set; } = "Cancel";
|
||||
|
||||
public string OkText { get; set; } = "Cancel";
|
||||
public string OkText { get; set; } = "OK";
|
||||
}
|
||||
}
|
||||
|
@ -2,17 +2,13 @@
|
||||
|
||||
<Popconfirm Title="Are you sure delete this task?"
|
||||
OnConfirm="Confirm"
|
||||
OnCancel="Cancel"
|
||||
OkText="Yes"
|
||||
CancelText="No">
|
||||
OnCancel="Cancel">
|
||||
<a>Delete</a>
|
||||
</Popconfirm>
|
||||
<br />
|
||||
<Popconfirm Title="Are you sure delete this task?"
|
||||
OnConfirm="Confirm"
|
||||
OnCancel="Cancel"
|
||||
OkText="Yes"
|
||||
CancelText="No">
|
||||
OnCancel="Cancel">
|
||||
<Unbound>
|
||||
<a @ref="@context.Current">Delete (unbound)</a>
|
||||
</Unbound>
|
||||
|
@ -1,3 +1,7 @@
|
||||
<Popconfirm Title="Are you sure?" OkText="Yes" CancelText="No">
|
||||
<a>Delete</a>
|
||||
</Popconfirm>
|
||||
|
||||
<Popconfirm Title="Are you sure?" Locale="@(new(){ OkText="Yes", CancelText="No" })">
|
||||
<a>Delete</a>
|
||||
</Popconfirm>
|
@ -1,59 +1,56 @@
|
||||
@inject IMessageService _message
|
||||
|
||||
<div class="demo">
|
||||
<div style="margin-left: @($"{ButtonWidth}px"); white-space: nowrap;">
|
||||
<Popconfirm Placement="@Placement.TopLeft" Title="@_title" OkText="@_okText" CancelText="@_cancelText" OnConfirm="Confirm">
|
||||
<Popconfirm Placement="@Placement.TopLeft" Title="@_title" OnConfirm="Confirm">
|
||||
<Button>TL</Button>
|
||||
</Popconfirm>
|
||||
<Popconfirm Placement="@Placement.Top" Title="@_title" OkText="@_okText" CancelText="@_cancelText" OnConfirm="Confirm">
|
||||
<Popconfirm Placement="@Placement.Top" Title="@_title" OnConfirm="Confirm">
|
||||
<Button>Top</Button>
|
||||
</Popconfirm>
|
||||
<Popconfirm Placement="@Placement.TopRight" Title="@_title" OkText="@_okText" CancelText="@_cancelText" OnConfirm="Confirm">
|
||||
<Popconfirm Placement="@Placement.TopRight" Title="@_title" OnConfirm="Confirm">
|
||||
<Button>TR</Button>
|
||||
</Popconfirm>
|
||||
</div>
|
||||
<div style="width: @($"{ButtonWidth}px"); float: left;">
|
||||
<Popconfirm Placement="@Placement.LeftTop" Title="@_title" OkText="@_okText" CancelText="@_cancelText" OnConfirm="Confirm">
|
||||
<Popconfirm Placement="@Placement.LeftTop" Title="@_title" OnConfirm="Confirm">
|
||||
<Button>LT</Button>
|
||||
</Popconfirm>
|
||||
<Popconfirm Placement="@Placement.Left" Title="@_title" OkText="@_okText" CancelText="@_cancelText" OnConfirm="Confirm">
|
||||
<Popconfirm Placement="@Placement.Left" Title="@_title" OnConfirm="Confirm">
|
||||
<Button>Left</Button>
|
||||
</Popconfirm>
|
||||
<Popconfirm Placement="@Placement.LeftBottom" Title="@_title" OkText="@_okText" CancelText="@_cancelText" OnConfirm="Confirm">
|
||||
<Popconfirm Placement="@Placement.LeftBottom" Title="@_title" OnConfirm="Confirm">
|
||||
<Button>LB</Button>
|
||||
</Popconfirm>
|
||||
</div>
|
||||
<div style="width: @($"{ButtonWidth}px"); margin-left: @($"{ButtonWidth * 4 + 24}px");">
|
||||
<Popconfirm Placement="@Placement.RightTop" Title="@_title" OkText="@_okText" CancelText="@_cancelText" OnConfirm="Confirm">
|
||||
<Popconfirm Placement="@Placement.RightTop" Title="@_title" OnConfirm="Confirm">
|
||||
<Button>RT</Button>
|
||||
</Popconfirm>
|
||||
<Popconfirm Placement="@Placement.Right" Title="@_title" OkText="@_okText" CancelText="@_cancelText" OnConfirm="Confirm">
|
||||
<Popconfirm Placement="@Placement.Right" Title="@_title" OnConfirm="Confirm">
|
||||
<Button>Right</Button>
|
||||
</Popconfirm>
|
||||
<Popconfirm Placement="@Placement.RightBottom" Title="@_title" OkText="@_okText" CancelText="@_cancelText" OnConfirm="Confirm">
|
||||
<Popconfirm Placement="@Placement.RightBottom" Title="@_title" OnConfirm="Confirm">
|
||||
<Button>RB</Button>
|
||||
</Popconfirm>
|
||||
</div>
|
||||
<div style="margin-left: @($"{ButtonWidth}px"); clear: both; white-space: nowrap;">
|
||||
<Popconfirm Placement="@Placement.BottomLeft" Title="@_title" OkText="@_okText" CancelText="@_cancelText" OnConfirm="Confirm">
|
||||
<Popconfirm Placement="@Placement.BottomLeft" Title="@_title" OnConfirm="Confirm">
|
||||
<Button>BL</Button>
|
||||
</Popconfirm>
|
||||
<Popconfirm Placement="@Placement.Bottom" Title="@_title" OkText="@_okText" CancelText="@_cancelText" OnConfirm="Confirm">
|
||||
<Popconfirm Placement="@Placement.Bottom" Title="@_title" OnConfirm="Confirm">
|
||||
<Button>Bottom</Button>
|
||||
</Popconfirm>
|
||||
<Popconfirm Placement="@Placement.BottomRight" Title="@_title" OkText="@_okText" CancelText="@_cancelText" OnConfirm="Confirm">
|
||||
<Popconfirm Placement="@Placement.BottomRight" Title="@_title" OnConfirm="Confirm">
|
||||
<Button>BR</Button>
|
||||
</Popconfirm>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@inject IMessageService _message
|
||||
|
||||
@code
|
||||
{
|
||||
|
||||
const int ButtonWidth = 70;
|
||||
|
||||
private string _cancelText = "No";
|
||||
private string _okText = "Yes";
|
||||
private string _title = "Are you sure to delete this task?";
|
||||
private void Confirm()
|
||||
{
|
||||
|
@ -7,9 +7,9 @@ title:
|
||||
|
||||
## zh-CN
|
||||
|
||||
使用 `okText` 和 `cancelText` 自定义按钮文字。
|
||||
使用 `OkText` 和 `CancelText` 或者 `Locale` 自定义按钮文字。
|
||||
|
||||
## en-US
|
||||
|
||||
Set `okText` and `cancelText` props to customize the button's labels.
|
||||
Set `okText` and `cancelText` or `Locale` props to customize the button's labels.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user