Skip to content

Commit 73adf50

Browse files
authored
doc(OtpService): add localization for sample code (#8083)
* doc: 精简代码 * doc: 增加注入服务文档 * doc(OtpService): add localization for sample code
1 parent 525e75b commit 73adf50

4 files changed

Lines changed: 27 additions & 8 deletions

File tree

src/BootstrapBlazor.Server/Components/Samples/Html2Pdfs.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
<PackageTips Name="BootstrapBlazor.Html2Pdf" />
2828

29-
<p class="code-label">@((MarkupString)Localizer["Html2PdfStep1"].Value)</p>
29+
<p class="code-label">@Localizer["Html2PdfStep1"]</p>
3030
<Pre>services.AddBootstrapBlazorHtml2PdfService();</Pre>
3131

3232
<p class="code-label">@Localizer["CommonIssuesTitle"]</p>

src/BootstrapBlazor.Server/Components/Samples/OtpServices.razor

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929

3030
<PackageTips Name="BootstrapBlazor.Authenticator"></PackageTips>
3131

32+
<p class="code-label">@Localizer["InjectServiceLabel"]</p>
33+
<Pre>services.AddBootstrapBlazorTotpService();</Pre>
34+
3235
<DemoBlock Title="@Localizer["BaseUsageTitle"]" Introduction="@Localizer["BaseUsageIntro"]" Name="Normal">
3336
<QRCode Content="@_content" Width="190" class="mb-3"></QRCode>
3437
<OtpInput Value="@_code" IsReadonly="true" class="text-center mb-3"></OtpInput>
@@ -38,21 +41,21 @@
3841
</div>
3942
</DemoBlock>
4043

41-
<p class="code-label mt-3">1. 服务注入</p>
44+
<p class="code-label mt-3">@Localizer["Step1Title"]</p>
4245

4346
<Pre>services.AddBootstrapBlazorTotpService();</Pre>
4447

4548
<Pre>[Inject]
4649
[NotNull]
4750
private ITotpService? TotpService { get; set; }</Pre>
4851

49-
<p class="code-label">2. 生成二维码</p>
50-
<p>调用 <code>TotpService</code> 实例方法 <code>GenerateOtpUri</code> 得到二维码内容,配合二维码组件 <code>QRCode</code> 显示二维码</p>
52+
<p class="code-label">@Localizer["Step2Title"]</p>
53+
<p>@((MarkupString)Localizer["Step2Description"].Value)</p>
5154

52-
<p class="code-label">3. 使用 <code>Microsoft Authenticator</code> <code>Google Authenticator</code> 等支持 <b>TOTP</b> 协议的软件,扫描二维码</p>
55+
<p class="code-label">@((MarkupString)Localizer["Step3Title"].Value)</p>
5356

54-
<p class="code-label">4. 验证逻辑</p>
57+
<p class="code-label">@Localizer["Step4Title"]</p>
5558

56-
<p>网页内使用 <code>OtpInput</code> 让用户填写手机 <code>App</code> 终端的密码,后台通过调用 <code>TotpService</code> 实例方法 <code>Compute</code> 得到当前时间窗口内的密码,与客户录入的比对,如果一致则密码正确</p>
59+
<p>@((MarkupString)Localizer["Step4Description"].Value)</p>
5760

58-
<div>通过使用本服务可以很方便的构建 <code>2FA</code> 应用</div>
61+
<div>@((MarkupString)Localizer["Summary"].Value)</div>

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3571,7 +3571,15 @@
35713571
"BootstrapBlazor.Server.Components.Samples.OtpServices": {
35723572
"BaseUsageIntro": "By calling the <code>Compute</code> method of the <code>ITotpService</code> service instance, you can get the password in the current time window. By calling the <code>Instance.GetRemainingSeconds</code> method, you can display the remaining validity time of the current password. In this example, the progress bar is used for dynamic display.",
35733573
"BaseUsageTitle": "Basic usage",
3574+
"InjectServiceLabel": "Register service",
3575+
"Step1Title": "1. Inject the service",
3576+
"Step2Description": "Call the <code>GenerateOtpUri</code> instance method on <code>TotpService</code> to get the QR code payload, then render it with the <code>QRCode</code> component",
3577+
"Step2Title": "2. Generate the QR code",
3578+
"Step3Title": "3. Use software that supports the <b>TOTP</b> protocol, such as <code>Microsoft Authenticator</code> or <code>Google Authenticator</code>, to scan the QR code",
3579+
"Step4Description": "Use <code>OtpInput</code> on the page so the user can enter the code from the mobile <code>App</code>. On the server side, call the <code>Compute</code> instance method on <code>TotpService</code> to get the code for the current time window and compare it with the client input. If they match, the code is valid",
3580+
"Step4Title": "4. Verification logic",
35743581
"SubTitle": "An implementation TOTP RFC 6238 and HOTP RFC 4226 Authenticator service.",
3582+
"Summary": "This service makes it straightforward to build <code>2FA</code> applications",
35753583
"Title": "ITotpService"
35763584
},
35773585
"BootstrapBlazor.Server.Components.Samples.Paginations": {

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3571,7 +3571,15 @@
35713571
"BootstrapBlazor.Server.Components.Samples.OtpServices": {
35723572
"BaseUsageIntro": "通过调用 <code>ITotpService</code> 服务实例方法 <code>Compute</code> 得到当前时间窗口内密码, 通过调用 <code>Instance.GetRemainingSeconds</code> 方法可以显示当前密码剩余有效时间,本例中通过进度条进行动态显示",
35733573
"BaseUsageTitle": "基本用法",
3574+
"InjectServiceLabel": "注入服务",
3575+
"Step1Title": "1. 服务注入",
3576+
"Step2Description": "调用 <code>TotpService</code> 实例方法 <code>GenerateOtpUri</code> 得到二维码内容,配合二维码组件 <code>QRCode</code> 显示二维码",
3577+
"Step2Title": "2. 生成二维码",
3578+
"Step3Title": "3. 使用 <code>Microsoft Authenticator</code>、<code>Google Authenticator</code> 等支持 <b>TOTP</b> 协议的软件扫描二维码",
3579+
"Step4Description": "网页内使用 <code>OtpInput</code> 让用户填写手机 <code>App</code> 端的密码,后台通过调用 <code>TotpService</code> 实例方法 <code>Compute</code> 得到当前时间窗口内的密码,与客户端录入的比对,如果一致则密码正确",
3580+
"Step4Title": "4. 验证逻辑",
35743581
"SubTitle": "实现 TOTP RFC 6238 和 HOTP RFC 4226 认证器服务",
3582+
"Summary": "通过使用本服务可以很方便地构建 <code>2FA</code> 应用",
35753583
"Title": "ITotpService 时间密码验证服务"
35763584
},
35773585
"BootstrapBlazor.Server.Components.Samples.Paginations": {

0 commit comments

Comments
 (0)