Skip to content

Commit 61cb823

Browse files
authored
doc(Tutorials): update Tutorials sample code (#8023)
* doc: 合并多语言 * doc: 追悼模式增加多语言支持 * doc: 资源文件排序
1 parent 5c0ea5f commit 61cb823

5 files changed

Lines changed: 50 additions & 45 deletions

File tree

src/BootstrapBlazor.Server/Components/Layout/TutorialsNavMenu.razor.cs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// See the LICENSE file in the project root for more information.
44
// Maintainer: Argo Zhang(argo@live.ca) Website: https://www.blazor.zone
55

6-
using BootstrapBlazor.Server.Components.Pages;
76
using Microsoft.AspNetCore.Components.Web;
87
using System.Text;
98

@@ -20,11 +19,7 @@ public partial class TutorialsNavMenu
2019

2120
[Inject]
2221
[NotNull]
23-
private IStringLocalizer<Tutorials>? TutorialsLocalizer { get; set; }
24-
25-
[Inject]
26-
[NotNull]
27-
private IStringLocalizer<Tutorials>? Localizer { get; set; }
22+
private IStringLocalizer<TutorialsNavMenu>? Localizer { get; set; }
2823

2924
[Inject]
3025
[NotNull]
@@ -52,12 +47,12 @@ protected override async Task OnInitializedAsync()
5247
new()
5348
{
5449
Template = CreateDownloadButtonComponent("dashboard", _dashboardFileList),
55-
Text = TutorialsLocalizer["DashboardSummary"],
50+
Text = Localizer["DashboardSummary"],
5651
Url = "tutorials/dashboard"
5752
},
5853
new()
5954
{
60-
Text = TutorialsLocalizer["LoginSummary"],
55+
Text = Localizer["LoginSummary"],
6156
Url = "tutorials/login",
6257
Items =
6358
[
@@ -96,24 +91,24 @@ protected override async Task OnInitializedAsync()
9691
new()
9792
{
9893
Template = CreateDownloadButtonComponent("waterfall", _waterfallFileList),
99-
Text = TutorialsLocalizer["WaterfallSummary"],
94+
Text = Localizer["WaterfallSummary"],
10095
Url = "tutorials/waterfall"
10196
},
10297
new()
10398
{
10499
Template = CreateDownloadButtonComponent("translate", _translateFileList),
105-
Text = TutorialsLocalizer["TranslateSummary"],
100+
Text = Localizer["TranslateSummary"],
106101
Url = "tutorials/translate"
107102
},
108103
new()
109104
{
110105
Template = CreateDownloadButtonComponent("drawing", _drawingAppFileList),
111-
Text = TutorialsLocalizer["DrawingSummary"],
106+
Text = Localizer["DrawingSummary"],
112107
Url = "tutorials/drawing"
113108
},
114109
new()
115110
{
116-
Text = TutorialsLocalizer["AdminSummary"],
111+
Text = Localizer["AdminSummary"],
117112
Url = "tutorials/admin",
118113
},
119114
new()
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
@layout TutorialsLayout
1+
@layout TutorialsLayout
22
@page "/tutorials"
3-
@inject IStringLocalizer<Tutorials> Localizer
3+
@inject IStringLocalizer<TutorialsNavMenu> Localizer
44

55
<ComponentCategory Text="@Localizer["CategoryTitle"]">
66
<ComponentCard Text="@Localizer["DashboardSummary"]" Image="tutorials/dashboard.png" Url="tutorials/dashboard"></ComponentCard>
@@ -10,4 +10,3 @@
1010
<ComponentCard Text="@Localizer["DrawingSummary"]" Image="tutorials/drawing.png" Url="tutorials/drawing"></ComponentCard>
1111
<ComponentCard Text="@Localizer["AdminSummary"]" Image="tutorials/pro.jpg" Url="tutorials/admin"></ComponentCard>
1212
</ComponentCategory>
13-
Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
@page "/tutorials/memorial"
1+
@page "/tutorials/memorial"
2+
@inject IStringLocalizer<Memorial> Localizer
23

3-
<Button Text="切换哀悼模式" OnClick="OnToggle" class="mb-3"></Button>
4+
<Button Text="@Localizer["ToggleButtonText"]" OnClick="OnToggle" class="mb-3"></Button>
45

5-
<p class="code-label">1. 加载 <code>Utlity</code> 工具</p>
6+
<p class="code-label">@((MarkupString)Localizer["Step1Title"].Value)</p>
67
<Pre>var module = await JSRuntime.LoadUtility();</Pre>
78

8-
<p class="code-label">2. 设置哀悼模式</p>
9+
<p class="code-label">@Localizer["Step2Title"]</p>
910
<Pre>await module.InvokeVoidAsync("SetMemorial", true);</Pre>
1011

11-
<p class="code-label">3. 全站默认设置追悼模式方法</p>
12-
<p>更新 <code>App.razor</code> 文档内容如下</p>
12+
<p class="code-label">@Localizer["Step3Title"]</p>
13+
<p>@((MarkupString)Localizer["Step3Description"].Value)</p>
1314
<Pre>&lt;html lang="en" data-bs-theme='dark' data-bb-theme="memorial"&gt;</Pre>

src/BootstrapBlazor.Server/Locales/en-US.json

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -469,9 +469,16 @@
469469
"ZipArchive": "IZipArchiveService"
470470
},
471471
"BootstrapBlazor.Server.Components.Layout.TutorialsNavMenu": {
472+
"AdminSummary": "Admin",
473+
"CategoryTitle": "Bootstrap Blazor Practical Cases",
474+
"DashboardSummary": "Dashboard",
475+
"DrawingSummary": "Drawing",
476+
"LoginSummary": "Login&Register",
472477
"MemorialMode": "Memorial",
473478
"MFA": "MFA",
474-
"OnlineSheet": "UniverSheet"
479+
"OnlineSheet": "UniverSheet",
480+
"TranslateSummary": "Translate",
481+
"WaterfallSummary": "Waterfall"
475482
},
476483
"BootstrapBlazor.Server.Components.Pages.Breakpoints": {
477484
"Amount": "pixel",
@@ -716,15 +723,6 @@
716723
"P8": "theme, please use the original",
717724
"P9": "The added style file is as follows"
718725
},
719-
"BootstrapBlazor.Server.Components.Pages.Tutorials": {
720-
"AdminSummary": "Admin",
721-
"CategoryTitle": "Bootstrap Blazor Practical Cases",
722-
"DashboardSummary": "Dashboard",
723-
"DrawingSummary": "Drawing",
724-
"LoginSummary": "Login&Register",
725-
"TranslateSummary": "Translate",
726-
"WaterfallSummary": "Waterfall"
727-
},
728726
"BootstrapBlazor.Server.Components.Samples.Affixs": {
729727
"AffixIntro": "Fix the element to a specific visible area",
730728
"AffixNormalIntro": "Affix is fixed at the top of the page by default",
@@ -4607,10 +4605,10 @@
46074605
},
46084606
"BootstrapBlazor.Server.Components.Samples.Table.TablesColumnDrag": {
46094607
"AllowDragOrderDesc": "<p>Pressing the mouse over a column heading and dragging it to another column heading position can adjust the column to be in front of the target column, but the built-in columns in the <code>Table</code> component, such as detail row, row number, selection, and operation columns, cannot be adjusted</p><p>This example enables local storage by setting the <code>ClientTableName</code> parameter. After dragging and adjusting the order, the page can be refreshed, and the column order remains in the previous state</p><p>After version <code>10.6.1</code>, use <code>OnTableColumnClientStatusChanged</code> to uniformly handle column dragging, column resizing, and auto-fit column width callbacks, replacing the original <code>OnDragColumnEndAsync</code>, <code>OnResizeColumnAsync</code>, and <code>OnAutoFitContentAsync</code> callbacks.</p><p><b>Notes:</b></p><p>Table state persistence has two modes. If the <code>ClientTableName</code> property is set, browser local storage is used to persist information. If it is not set, server-side storage persistence is implemented through callbacks. The persistence structure is <code>TableColumnClientStatus</code>, which consists of the column state collection and the table width parameter.</p><p>The table width parameter defaults to 0. When all columns have width values, the table width parameter is the actual width rendered on the client. A value of 0 means the table width is adaptive.</p><p>When using browser local storage for persistence, no additional settings are required. The table automatically loads the client state.</p><p>When using server-side storage for persistence, handle table state loading and saving logic in callbacks. In actual use, the state can be stored in a database or other storage as needed. Use the <code>OnTableColumnClientStatusChanged</code> callback to handle server-side state changes, and use the <code>OnLoadTableColumnClientStatus</code> callback to restore the table persistence state.</p>",
4610-
"ClearTableColumnClientStatusDesc": "By calling the <code>ClearTableColumnClientStatus</code> method of the table component instance, the current persistent settings are cleared, restoring the table to its default settings.",
4611-
"ResetButtonText": "Reset",
46124608
"AllowDragOrderIntro": "By specifying <code>AllowDragColumn</code>, set the table columns to allow dragging column headings to adjust the table column order",
46134609
"AllowDragOrderTitle": "Allow dragging column headings to adjust table column order",
4610+
"ClearTableColumnClientStatusDesc": "By calling the <code>ClearTableColumnClientStatus</code> method of the table component instance, the current persistent settings are cleared, restoring the table to its default settings.",
4611+
"ResetButtonText": "Reset",
46144612
"TablesColumnDescription": "Used to display multiple pieces of data with similar structures, data can be sorted, filtered, compared or other custom operations.",
46154613
"TablesColumnTitle": "Table Column"
46164614
},
@@ -5706,6 +5704,13 @@
57065704
"UrlDesc": "Use your iPhone's camera or the QR code scanning function to scan the QR code below, then open the <code>Safari</code> browser and open the current address",
57075705
"WiFiDesc": "Use your iPhone's camera or the QR code scanner to scan the QR code below to automatically join the <code>WiFi</code> network."
57085706
},
5707+
"BootstrapBlazor.Server.Components.Samples.Tutorials.Memorial": {
5708+
"Step1Title": "1. Load the <code>Utility</code> module",
5709+
"Step2Title": "2. Enable memorial mode",
5710+
"Step3Description": "Update the <code>App.razor</code> document as follows",
5711+
"Step3Title": "3. Enable memorial mode site-wide by default",
5712+
"ToggleButtonText": "Toggle Memorial Mode"
5713+
},
57095714
"BootstrapBlazor.Server.Components.Samples.Tutorials.OnlineSheet.OnlineSheet": {
57105715
"ToastOnReadyContent": "After 4 seconds the table is updated by other writers to change the content",
57115716
"ToastOnReadyTitle": "Collaboration Notification"

src/BootstrapBlazor.Server/Locales/zh-CN.json

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -469,9 +469,16 @@
469469
"ZipArchive": "压缩归档服务 IZipArchiveService"
470470
},
471471
"BootstrapBlazor.Server.Components.Layout.TutorialsNavMenu": {
472+
"AdminSummary": "中台 Admin",
473+
"CategoryTitle": "BootstrapBlazor 实战案例",
474+
"DashboardSummary": "仪表盘 Dashboard",
475+
"DrawingSummary": "画图 Drawing",
476+
"LoginSummary": "登陆注册 Login&Register",
472477
"MemorialMode": "追悼模式",
473478
"MFA": "多因子认证 MFA",
474-
"OnlineSheet": "在线表格 UniverSheet"
479+
"OnlineSheet": "在线表格 UniverSheet",
480+
"TranslateSummary": "翻译工具 Translate",
481+
"WaterfallSummary": "瀑布流图片 Waterfall"
475482
},
476483
"BootstrapBlazor.Server.Components.Pages.Breakpoints": {
477484
"Amount": "像素",
@@ -716,15 +723,6 @@
716723
"P8": "主题,则请在原有",
717724
"P9": "内增加样式文件如下"
718725
},
719-
"BootstrapBlazor.Server.Components.Pages.Tutorials": {
720-
"AdminSummary": "中台 Admin",
721-
"CategoryTitle": "BootstrapBlazor 实战案例",
722-
"DashboardSummary": "仪表盘 Dashboard",
723-
"DrawingSummary": "画图 Drawing",
724-
"LoginSummary": "登陆注册 Login&Register",
725-
"TranslateSummary": "翻译工具 Translate",
726-
"WaterfallSummary": "瀑布流图片 Waterfall"
727-
},
728726
"BootstrapBlazor.Server.Components.Samples.Affixs": {
729727
"AffixIntro": "将页面元素钉在可视范围",
730728
"AffixNormalIntro": "固钉默认固定在页面顶部",
@@ -4607,10 +4605,10 @@
46074605
},
46084606
"BootstrapBlazor.Server.Components.Samples.Table.TablesColumnDrag": {
46094607
"AllowDragOrderDesc": "<p>在列标题上按下鼠标拖动到其他列标题位置可将该列调整至目标列之前,但 <code>Table</code> 组件内置的列如明细行列、行号列、选择列、操作列等不可被调整</p><p>本示例通过设置 <code>ClientTableName</code> 参数开启了本地化存储,拖动调整顺序后,可刷新页面,列顺序是保持上次状态的</p><p><code>10.6.1</code> 版本后使用 <code>OnTableColumnClientStatusChanged</code> 统一处理列拖拽、列宽调整与自适应列宽回调,移除原 <code>OnDragColumnEndAsync</code> <code>OnResizeColumnAsync</code> 和 <code>OnAutoFitContentAsync</code> 回调。</p><p><b>注意事项:</b></p><p>表格状态持久化功能分两种情况,设置 <code>ClientTableName</code> 属性即使用浏览器本地存储持久化信息,如果未设置则通过回调使用服务器端存储持久化信息。持久化信息结构体为 <code>TableColumnClientStatus</code> 由列状态集合以及表格宽度参数组成。</p><p>表格宽度参数默认为 0 当所有列宽度均有值时,表格宽度参数值为表格在客户端渲染的实际宽度;为 0 表示表格宽度自适应</p><p>使用浏览器本地存储持久化信息时,无需任何设置,表格会自动加载客户端状态</p><p>使用服务器端存储持久化信息时,需在回调中处理表格状态加载与保存逻辑,实际使用中可根据需要使用数据库或其他方式进行存储;通过 <code>OnTableColumnClientStatusChanged</code> 回调处理服务器端状态,通过 <code>OnLoadTableColumnClientStatus</code> 回调方法对表格进行持久化状态恢复操作</p>",
4610-
"ClearTableColumnClientStatusDesc": "通过调用表格组件实例方法 <code>ClearTableColumnClientStatus</code> 清除当前持久化设置恢复表格为默认设置",
4611-
"ResetButtonText": "重置",
46124608
"AllowDragOrderIntro": "通过指定 <code>AllowDragColumn</code> 设置表格列允许拖动列标题调整表格列顺序",
46134609
"AllowDragOrderTitle": "允许拖动列标题调整表格列顺序",
4610+
"ClearTableColumnClientStatusDesc": "通过调用表格组件实例方法 <code>ClearTableColumnClientStatus</code> 清除当前持久化设置恢复表格为默认设置",
4611+
"ResetButtonText": "重置",
46144612
"TablesColumnDescription": "用于展示多条结构类似的数据,可对数据进行排序、筛选、对比或其他自定义操作。",
46154613
"TablesColumnTitle": "Table 表格"
46164614
},
@@ -5706,6 +5704,13 @@
57065704
"UrlDesc": "使用 <code>iPhone</code> 手机相机或者扫描二维码功能扫描下方二维码后,打开 <code>Safari</code> 浏览器并且打开当前地址",
57075705
"WiFiDesc": "使用 <code>iPhone</code> 手机相机或者扫描二维码功能扫描下方二维码后,自动加入 <code>WiFi</code> 网络"
57085706
},
5707+
"BootstrapBlazor.Server.Components.Samples.Tutorials.Memorial": {
5708+
"Step1Title": "1. 加载 <code>Utility</code> 工具",
5709+
"Step2Title": "2. 设置哀悼模式",
5710+
"Step3Description": "更新 <code>App.razor</code> 文档内容如下",
5711+
"Step3Title": "3. 全站默认设置追悼模式方法",
5712+
"ToggleButtonText": "切换哀悼模式"
5713+
},
57095714
"BootstrapBlazor.Server.Components.Samples.Tutorials.OnlineSheet.OnlineSheet": {
57105715
"ToastOnReadyContent": "4 秒后表格更新其他写作人员更改内容",
57115716
"ToastOnReadyTitle": "在线表格协作通知"

0 commit comments

Comments
 (0)