From 94481f37191cb350c366acc4a5724a9fe569061f Mon Sep 17 00:00:00 2001 From: James Yeung Date: Mon, 13 Feb 2023 23:09:22 +0800 Subject: [PATCH] fix(module: popconfirm): missing built-in localization (#3095) --- components/popconfirm/Popconfirm.razor.cs | 13 ++++++-- components/popconfirm/PopconfirmLocale.cs | 4 +-- .../Components/Popconfirm/demo/Basic.razor | 8 ++--- .../Components/Popconfirm/demo/Locale.razor | 4 +++ .../Popconfirm/demo/PlacementType.razor | 31 +++++++++---------- .../Components/Popconfirm/demo/locale.md | 4 +-- 6 files changed, 35 insertions(+), 29 deletions(-) diff --git a/components/popconfirm/Popconfirm.razor.cs b/components/popconfirm/Popconfirm.razor.cs index a2e5d733..9bd71916 100644 --- a/components/popconfirm/Popconfirm.razor.cs +++ b/components/popconfirm/Popconfirm.razor.cs @@ -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)) diff --git a/components/popconfirm/PopconfirmLocale.cs b/components/popconfirm/PopconfirmLocale.cs index f59976d4..4a8b6529 100644 --- a/components/popconfirm/PopconfirmLocale.cs +++ b/components/popconfirm/PopconfirmLocale.cs @@ -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"; } } diff --git a/site/AntDesign.Docs/Demos/Components/Popconfirm/demo/Basic.razor b/site/AntDesign.Docs/Demos/Components/Popconfirm/demo/Basic.razor index 4425579b..4aad144f 100644 --- a/site/AntDesign.Docs/Demos/Components/Popconfirm/demo/Basic.razor +++ b/site/AntDesign.Docs/Demos/Components/Popconfirm/demo/Basic.razor @@ -2,17 +2,13 @@ + OnCancel="Cancel"> Delete
+ OnCancel="Cancel"> Delete (unbound) diff --git a/site/AntDesign.Docs/Demos/Components/Popconfirm/demo/Locale.razor b/site/AntDesign.Docs/Demos/Components/Popconfirm/demo/Locale.razor index 9cd9e7eb..37176d6e 100644 --- a/site/AntDesign.Docs/Demos/Components/Popconfirm/demo/Locale.razor +++ b/site/AntDesign.Docs/Demos/Components/Popconfirm/demo/Locale.razor @@ -1,3 +1,7 @@ Delete + + + + Delete \ No newline at end of file diff --git a/site/AntDesign.Docs/Demos/Components/Popconfirm/demo/PlacementType.razor b/site/AntDesign.Docs/Demos/Components/Popconfirm/demo/PlacementType.razor index bfc5c1f6..1b3471e1 100644 --- a/site/AntDesign.Docs/Demos/Components/Popconfirm/demo/PlacementType.razor +++ b/site/AntDesign.Docs/Demos/Components/Popconfirm/demo/PlacementType.razor @@ -1,59 +1,56 @@ -@inject IMessageService _message -
- + - + - +
- + - + - +
- + - + - +
- + - + - +
+@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() { diff --git a/site/AntDesign.Docs/Demos/Components/Popconfirm/demo/locale.md b/site/AntDesign.Docs/Demos/Components/Popconfirm/demo/locale.md index 8c7ea114..53ca4b3b 100644 --- a/site/AntDesign.Docs/Demos/Components/Popconfirm/demo/locale.md +++ b/site/AntDesign.Docs/Demos/Components/Popconfirm/demo/locale.md @@ -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.