From 721f2b97561f04796dc8d0d9ef02441e5f0dee67 Mon Sep 17 00:00:00 2001 From: MadLongTom <36219016+MadLongTom@users.noreply.github.com> Date: Mon, 14 Jul 2025 09:36:53 +0800 Subject: [PATCH 1/2] feat(CherryMarkdown): add locale parameter --- .../Components/CherryMarkdown/CherryMarkdown.razor.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/components/BootstrapBlazor.CherryMarkdown/Components/CherryMarkdown/CherryMarkdown.razor.cs b/src/components/BootstrapBlazor.CherryMarkdown/Components/CherryMarkdown/CherryMarkdown.razor.cs index 1d1969c3..ef9e4e75 100644 --- a/src/components/BootstrapBlazor.CherryMarkdown/Components/CherryMarkdown/CherryMarkdown.razor.cs +++ b/src/components/BootstrapBlazor.CherryMarkdown/Components/CherryMarkdown/CherryMarkdown.razor.cs @@ -66,6 +66,12 @@ public partial class CherryMarkdown [Parameter] public bool IsViewer { get; set; } + /// + /// 获取/设置 组件语言 + /// + [Parameter] + public string Locale { get; set; } = "zh-CN"; + /// /// /// @@ -93,7 +99,7 @@ protected override async Task OnAfterRenderAsync(bool firstRender) /// /// protected override Task InvokeInitAsync() => InvokeVoidAsync("init", Id, Interop, - new { Value, IsSupportMath, IsViewer, Editor = EditorSettings ?? new(), Toolbars = ToolbarSettings ?? new() }, + new { Value, IsSupportMath, IsViewer, Locale, Editor = EditorSettings ?? new(), Toolbars = ToolbarSettings ?? new() }, nameof(Upload)); /// From 8208a96252f9d61ad76833c0f83fcc42712ff220 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Mon, 14 Jul 2025 09:59:11 +0800 Subject: [PATCH 2/2] =?UTF-8?q?refactor:=20=E5=A2=9E=E5=8A=A0=E8=AF=AD?= =?UTF-8?q?=E8=A8=80=E8=87=AA=E9=80=82=E5=BA=94=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CherryMarkdown/CherryMarkdown.razor.cs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/components/BootstrapBlazor.CherryMarkdown/Components/CherryMarkdown/CherryMarkdown.razor.cs b/src/components/BootstrapBlazor.CherryMarkdown/Components/CherryMarkdown/CherryMarkdown.razor.cs index ef9e4e75..d39acbe3 100644 --- a/src/components/BootstrapBlazor.CherryMarkdown/Components/CherryMarkdown/CherryMarkdown.razor.cs +++ b/src/components/BootstrapBlazor.CherryMarkdown/Components/CherryMarkdown/CherryMarkdown.razor.cs @@ -3,6 +3,7 @@ // Website: https://www.blazor.zone or https://argozhang.github.io/ using Microsoft.AspNetCore.Components; +using System.Globalization; namespace BootstrapBlazor.Components; @@ -70,7 +71,20 @@ public partial class CherryMarkdown /// 获取/设置 组件语言 /// [Parameter] - public string Locale { get; set; } = "zh-CN"; + public string? Language { get; set; } + + /// + /// + /// + protected override void OnParametersSet() + { + base.OnParametersSet(); + + if (string.IsNullOrEmpty(Language)) + { + Language = CultureInfo.CurrentUICulture.Name; + } + } /// /// @@ -99,7 +113,7 @@ protected override async Task OnAfterRenderAsync(bool firstRender) /// /// protected override Task InvokeInitAsync() => InvokeVoidAsync("init", Id, Interop, - new { Value, IsSupportMath, IsViewer, Locale, Editor = EditorSettings ?? new(), Toolbars = ToolbarSettings ?? new() }, + new { Value, IsSupportMath, IsViewer, Locale = Language, Editor = EditorSettings ?? new(), Toolbars = ToolbarSettings ?? new() }, nameof(Upload)); ///