Skip to content

Commit da441c3

Browse files
authored
doc(Component): comments support both Chinese and English (#7532)
* docs: provided English translations * docs: manual edit and improvement to the documentation * docs: wrapped example in code block
1 parent 0b15132 commit da441c3

File tree

6 files changed

+101
-72
lines changed

6 files changed

+101
-72
lines changed

src/BootstrapBlazor/Components/ContextMenu/ContextMenu.razor.cs

Lines changed: 35 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Licensed to the .NET Foundation under one or more agreements.
1+
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the Apache 2.0 License
33
// See the LICENSE file in the project root for more information.
44
// Maintainer: Argo Zhang([email protected]) Website: https://www.blazor.zone
@@ -8,24 +8,28 @@
88
namespace BootstrapBlazor.Components;
99

1010
/// <summary>
11-
/// ContextMenu 组件
11+
/// <para lang="zh">ContextMenu 组件</para>
12+
/// <para lang="en">A component that represents a context menu.</para>
1213
/// </summary>
1314
public partial class ContextMenu
1415
{
1516
/// <summary>
16-
/// 获得/设置 是否显示阴影 默认 true
17+
/// <para lang="zh">获得/设置 是否显示阴影 默认 <see langword="true" /></para>
18+
/// <para lang="en">Flags whether to show a shadow around the context menu. Default is <see langword="true" />.</para>
1719
/// </summary>
1820
[Parameter]
1921
public bool ShowShadow { get; set; } = true;
2022

2123
/// <summary>
22-
/// 获得/设置 弹出前回调方法 默认 null
24+
/// <para lang="zh">获得/设置 弹出前回调方法 默认 null</para>
25+
/// <para lang="en">Defines the callback that is executed before showing the context menu. Default is <see langword="null" />.</para>
2326
/// </summary>
2427
[Parameter]
2528
public Func<object?, Task>? OnBeforeShowCallback { get; set; }
2629

2730
/// <summary>
28-
/// 获得/设置 子组件
31+
/// <para lang="zh">获得/设置 子组件</para>
32+
/// <para lang="en">The <see cref="RenderFragment"/> that represents the child content.</para>
2933
/// </summary>
3034
[Parameter]
3135
public RenderFragment? ChildContent { get; set; }
@@ -57,21 +61,15 @@ public partial class ContextMenu
5761

5862
private object? _contextItem;
5963

60-
/// <summary>
6164
/// <inheritdoc/>
62-
/// </summary>
6365
protected override void OnInitialized()
6466
{
6567
base.OnInitialized();
6668

6769
ContextMenuZone.RegisterContextMenu(this);
6870
}
6971

70-
/// <summary>
7172
/// <inheritdoc/>
72-
/// </summary>
73-
/// <param name="firstRender"></param>
74-
/// <returns></returns>
7573
protected override async Task OnAfterRenderAsync(bool firstRender)
7674
{
7775
await base.OnAfterRenderAsync(firstRender);
@@ -84,11 +82,21 @@ protected override async Task OnAfterRenderAsync(bool firstRender)
8482
}
8583

8684
/// <summary>
87-
/// 弹出 ContextMenu
85+
/// <para lang="zh">弹出 ContextMenu</para>
86+
/// <para lang="en">Shows the <see cref="ContextMenu"/>.</para>
8887
/// </summary>
89-
/// <param name="args"></param>
90-
/// <param name="contextItem"></param>
91-
/// <returns></returns>
88+
/// <param name="args">
89+
/// <para lang="zh">鼠标事件参数</para>
90+
/// <para lang="en">The <see cref="MouseEventArgs"/> that invoked this event.</para>
91+
/// </param>
92+
/// <param name="contextItem">
93+
/// <para lang="zh">上下文项</para>
94+
/// <para lang="en">Context that is associated with the clicked <see cref="ContextMenuItem"/>.</para>
95+
/// </param>
96+
/// <returns>
97+
/// <para lang="zh">异步任务</para>
98+
/// <para lang="en">An asynchronous instance of a <see cref="Task"/>.</para>
99+
/// </returns>
92100
internal async Task Show(MouseEventArgs args, object? contextItem)
93101
{
94102
_contextItem = contextItem;
@@ -109,14 +117,22 @@ private async Task OnClickItem(ContextMenuItem item)
109117
}
110118

111119
/// <summary>
112-
/// 增加 ContextMenuItem 方法
120+
/// <para lang="zh">增加 ContextMenuItem 方法</para>
121+
/// <para lang="en">Adds an <paramref name="item"/> to the menu.</para>
113122
/// </summary>
114-
/// <param name="item"></param>
123+
/// <param name="item">
124+
/// <para lang="zh">要添加的项</para>
125+
/// <para lang="en">The <see cref="IContextMenuItem"/> to add</para>
126+
/// </param>
115127
internal void AddItem(IContextMenuItem item) => _contextMenuItems.Add(item);
116128

117129
/// <summary>
118-
/// 移除 ContextMenuItem 方法
130+
/// <para lang="zh">移除 ContextMenuItem 方法</para>
131+
/// <para lang="en">Removes an <paramref name="item"/> from the menu.</para>
119132
/// </summary>
120-
/// <param name="item"></param>
133+
/// <param name="item">
134+
/// <para lang="zh">要移除的项</para>
135+
/// <para lang="en">The <see cref="IContextMenuItem"/> to remove</para>
136+
/// </param>
121137
internal void RemoveItem(IContextMenuItem item) => _contextMenuItems.Remove(item);
122138
}

src/BootstrapBlazor/Components/ContextMenu/ContextMenuDivider.cs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Licensed to the .NET Foundation under one or more agreements.
1+
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the Apache 2.0 License
33
// See the LICENSE file in the project root for more information.
44
// Maintainer: Argo Zhang([email protected]) Website: https://www.blazor.zone
@@ -8,36 +8,36 @@
88
namespace BootstrapBlazor.Components;
99

1010
/// <summary>
11-
/// ContextMenuDivider 组件
11+
/// <para lang="zh">ContextMenuDivider 组件</para>
12+
/// <para lang="en">A component that defines a menu item as a divider in a context menu.</para>
1213
/// </summary>
1314
public class ContextMenuDivider : Divider, IContextMenuItem, IDisposable
1415
{
1516
[CascadingParameter]
1617
[NotNull]
1718
private ContextMenu? ContextMenu { get; set; }
1819

19-
/// <summary>
2020
/// <inheritdoc/>
21-
/// </summary>
2221
protected override void OnInitialized()
2322
{
2423
base.OnInitialized();
2524

2625
ContextMenu.AddItem(this);
2726
}
2827

29-
/// <summary>
3028
/// <inheritdoc/>
31-
/// </summary>
32-
/// <param name="builder"></param>
3329
protected override void BuildRenderTree(RenderTreeBuilder builder) { }
3430

3531
private bool disposedValue;
3632

3733
/// <summary>
38-
/// 释放资源方法
34+
/// <para lang="zh">释放资源方法</para>
35+
/// <para lang="en">Method to release resources.</para>
3936
/// </summary>
40-
/// <param name="disposing"></param>
37+
/// <param name="disposing">
38+
/// <para lang="zh">是否释放托管资源</para>
39+
/// <para lang="en">Flags whether to release managed resources</para>
40+
/// </param>
4141
protected virtual void Dispose(bool disposing)
4242
{
4343
if (!disposedValue)
@@ -50,9 +50,7 @@ protected virtual void Dispose(bool disposing)
5050
}
5151
}
5252

53-
/// <summary>
5453
/// <inheritdoc/>
55-
/// </summary>
5654
public void Dispose()
5755
{
5856
Dispose(disposing: true);

src/BootstrapBlazor/Components/ContextMenu/ContextMenuItem.cs

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,52 @@
1-
// Licensed to the .NET Foundation under one or more agreements.
1+
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the Apache 2.0 License
33
// See the LICENSE file in the project root for more information.
44
// Maintainer: Argo Zhang([email protected]) Website: https://www.blazor.zone
55

66
namespace BootstrapBlazor.Components;
77

88
/// <summary>
9-
/// ContextMenuItem 类
9+
/// <para lang="zh">ContextMenuItem 类</para>
10+
/// <para lang="en">A type that represents a menu item in a <see cref="ContextMenu"/>.</para>
1011
/// </summary>
1112
public class ContextMenuItem : ComponentBase, IContextMenuItem, IDisposable
1213
{
1314
/// <summary>
14-
/// 获得/设置 显示文本
15+
/// <para lang="zh">获得/设置 显示文本</para>
16+
/// <para lang="en">The text to display.</para>
1517
/// </summary>
1618
[Parameter]
1719
public string? Text { get; set; }
1820

1921
/// <summary>
20-
/// 获得/设置 图标
22+
/// <para lang="zh">获得/设置 图标</para>
23+
/// <para lang="en">The CSS class name that represents an icon (if any)</para>
2124
/// </summary>
25+
/// <example>
26+
/// <code>
27+
/// Icon="fa-solid fa-bookmark"
28+
/// </code>
29+
/// </example>
2230
[Parameter]
2331
public string? Icon { get; set; }
2432

2533
/// <summary>
26-
/// 获得/设置 是否被禁用 默认 false 优先级低于 <see cref="OnDisabledCallback"/>
34+
/// <para lang="zh">获得/设置 是否被禁用 默认 false 优先级低于 <see cref="OnDisabledCallback"/></para>
35+
/// <para lang="en">Flags whether the item is disabled. Default is <see langword="false"/>. It has a lower priority than <see cref="OnDisabledCallback"/>.</para>
2736
/// </summary>
2837
[Parameter]
2938
public bool Disabled { get; set; }
3039

3140
/// <summary>
32-
/// 获得/设置 是否被禁用回调方法 默认 null 优先级高于 <see cref="Disabled"/>
41+
/// <para lang="zh">获得/设置 是否被禁用回调方法 默认 null 优先级高于 <see cref="Disabled"/></para>
42+
/// <para lang="en">Defines the callback to determine if the item is disabled. Default is <see langword="null" />. It has a higher priority than <see cref="Disabled"/>.</para>
3343
/// </summary>
3444
[Parameter]
3545
public Func<ContextMenuItem, object?, bool>? OnDisabledCallback { get; set; }
3646

3747
/// <summary>
38-
/// 获得/设置 点击回调方法 默认 null
48+
/// <para lang="zh">获得/设置 点击回调方法 默认 null</para>
49+
/// <para lang="en">Defines the click callback. Default is <see langword="null" />.</para>
3950
/// </summary>
4051
[Parameter]
4152
public Func<ContextMenuItem, object?, Task>? OnClick { get; set; }
@@ -44,9 +55,7 @@ public class ContextMenuItem : ComponentBase, IContextMenuItem, IDisposable
4455
[NotNull]
4556
private ContextMenu? ContextMenu { get; set; }
4657

47-
/// <summary>
4858
/// <inheritdoc/>
49-
/// </summary>
5059
protected override void OnInitialized()
5160
{
5261
base.OnInitialized();
@@ -57,9 +66,10 @@ protected override void OnInitialized()
5766
private bool disposedValue;
5867

5968
/// <summary>
60-
/// 释放资源方法
69+
/// <para lang="zh">释放资源方法</para>
70+
/// <para lang="en">Method to release resources.</para>
6171
/// </summary>
62-
/// <param name="disposing"></param>
72+
/// <param name="disposing"><para lang="zh">是否释放托管资源</para><para lang="en">Whether to release managed resources</para></param>
6373
protected virtual void Dispose(bool disposing)
6474
{
6575
if (!disposedValue)
@@ -72,9 +82,7 @@ protected virtual void Dispose(bool disposing)
7282
}
7383
}
7484

75-
/// <summary>
7685
/// <inheritdoc/>
77-
/// </summary>
7886
public void Dispose()
7987
{
8088
Dispose(disposing: true);

src/BootstrapBlazor/Components/ContextMenu/ContextMenuTrigger.cs

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,25 @@
99
namespace BootstrapBlazor.Components;
1010

1111
/// <summary>
12-
/// ContextMenuTrigger 组件
12+
/// <para lang="zh">ContextMenuTrigger 组件</para>
13+
/// <para lang="en">A component that defines a trigger that shows a <see cref="ContextMenu"/>.</para>
1314
/// </summary>
1415
public class ContextMenuTrigger : BootstrapComponentBase
1516
{
16-
/// <summary>
17-
/// 获得/设置 子组件
18-
/// </summary>
17+
/// <inheritdoc cref="ContextMenu.ChildContent" />
1918
[Parameter]
2019
public RenderFragment? ChildContent { get; set; }
2120

2221
/// <summary>
23-
/// 获得/设置 包裹组件 TagName 默认为 div
22+
/// <para lang="zh">获得/设置 包裹组件 TagName 默认为 div</para>
23+
/// <para lang="en">The HTML tag name to use for the trigger. Default is &lt;div&gt;.</para>
2424
/// </summary>
2525
[Parameter]
2626
public string WrapperTag { get; set; } = "div";
2727

2828
/// <summary>
29-
/// 获得/设置 上下文数据
29+
/// <para lang="zh">获得/设置 上下文数据</para>
30+
/// <para lang="en">Gets or sets the context data.</para>
3031
/// </summary>
3132
[Parameter]
3233
public object? ContextItem { get; set; }
@@ -36,8 +37,8 @@ public class ContextMenuTrigger : BootstrapComponentBase
3637
private ContextMenuZone? ContextMenuZone { get; set; }
3738

3839
/// <summary>
39-
/// The timeout duration for touch events to trigger the context menu (in milliseconds).
40-
/// Default is <see cref="ContextMenuOptions.OnTouchDelay"/> milliseconds. Must be greater than 0.
40+
/// <para lang="zh">触摸事件触发菜单的超时时间(毫秒)。默认值为 <see cref="ContextMenuOptions.OnTouchDelay"/> 毫秒。必须大于 0。</para>
41+
/// <para lang="en">The timeout duration for touch events to trigger the context menu (in milliseconds). Default is <see cref="ContextMenuOptions.OnTouchDelay"/> milliseconds. Must be greater than 0.</para>
4142
/// </summary>
4243
[Parameter]
4344
public int? OnTouchDelay { get; set; }
@@ -49,20 +50,15 @@ public class ContextMenuTrigger : BootstrapComponentBase
4950
.AddClassFromAttributes(AdditionalAttributes)
5051
.Build();
5152

52-
/// <summary>
5353
/// <inheritdoc/>
54-
/// </summary>
5554
protected override void OnParametersSet()
5655
{
5756
base.OnParametersSet();
5857

5958
OnTouchDelay ??= Options.CurrentValue.ContextMenuOptions.OnTouchDelay;
6059
}
6160

62-
/// <summary>
6361
/// <inheritdoc/>
64-
/// </summary>
65-
/// <param name="builder"></param>
6662
protected override void BuildRenderTree(RenderTreeBuilder builder)
6763
{
6864
builder.OpenElement(0, WrapperTag);
@@ -77,18 +73,21 @@ protected override void BuildRenderTree(RenderTreeBuilder builder)
7773
}
7874

7975
/// <summary>
80-
/// 点击 ContextMenu 菜单项时触发
76+
/// <para lang="zh">点击 ContextMenu 菜单项时触发</para>
77+
/// <para lang="en">Triggered when a context menu item is clicked.</para>
8178
/// </summary>
8279
[DynamicDependency(DynamicallyAccessedMemberTypes.PublicMethods, typeof(MouseEventArgs))]
8380
public Task OnContextMenu(MouseEventArgs args) => ContextMenuZone.OnContextMenu(args, ContextItem);
8481

8582
/// <summary>
86-
/// 是否触摸
83+
/// <para lang="zh">是否触摸</para>
84+
/// <para lang="en">Indicates whether a touch event is started.</para>
8785
/// </summary>
8886
public bool IsTouchStarted { get; private set; }
8987

9088
/// <summary>
91-
/// 触摸定时器工作指示
89+
/// <para lang="zh">触摸定时器工作指示</para>
90+
/// <para lang="en">Indicates whether the touch timer is working.</para>
9291
/// </summary>
9392
private bool IsBusy { get; set; }
9493

0 commit comments

Comments
 (0)