diff --git a/src/components/BootstrapBlazor.CherryMarkdown/Components/CherryMarkdown/CherryMarkdown.razor.cs b/src/components/BootstrapBlazor.CherryMarkdown/Components/CherryMarkdown/CherryMarkdown.razor.cs index 1d1969c3..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; @@ -66,6 +67,25 @@ public partial class CherryMarkdown [Parameter] public bool IsViewer { get; set; } + /// + /// 获取/设置 组件语言 + /// + [Parameter] + public string? Language { get; set; } + + /// + /// + /// + protected override void OnParametersSet() + { + base.OnParametersSet(); + + if (string.IsNullOrEmpty(Language)) + { + Language = CultureInfo.CurrentUICulture.Name; + } + } + /// /// /// @@ -93,7 +113,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 = Language, Editor = EditorSettings ?? new(), Toolbars = ToolbarSettings ?? new() }, nameof(Upload)); ///