Skip to content

Commit

Permalink
提取文本到资源文件。
Browse files Browse the repository at this point in the history
  • Loading branch information
Codespilot committed Mar 6, 2024
1 parent 1052aa0 commit 3160f86
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Source/Starfish.Webapp/Pages/Home.razor
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

@inject IDashboardApi DashboardApi

<PageTitle>Home</PageTitle>
<PageTitle>@(Resources.IDS_HOME_PAGE_TITLE)</PageTitle>

<FluentGrid>
<FluentGridItem lg="4" md="4" sm="6">
Expand Down
2 changes: 1 addition & 1 deletion Source/Starfish.Webapp/Pages/User/Edit.razor
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
{
if (!string.Equals(Password, Confirm))
{
throw new Exception("Password not match.");
throw new ValidationException(Resources.IDS_ERROR_PASSWORD_NOT_MATCH);
}

var request = new UserCreateDto
Expand Down
27 changes: 15 additions & 12 deletions Source/Starfish.Webapp/Pages/User/Login.razor
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

@inject NavigationManager Navigation
@inject AuthenticationStateProvider Authentication
@inject IConfiguration Configuration
@inject IJSRuntime Script
@inject IToastService ToastService
@inject IIdentityApi Api
Expand All @@ -19,7 +20,7 @@
<img alt="logo" class="logo" src="logo.svg">
<span class="title" style="color:#fcab66; font-size: 24px;">Starfish</span>
</div>
<div class="desc">配置管理和服务发现</div>
<div class="desc">@(Resources.IDS_COMMON_SUBTITLE)</div>
</div>
<FluentCard>
<FluentStack Orientation="Orientation.Vertical" VerticalGap="12" HorizontalAlignment="HorizontalAlignment.Center">
Expand All @@ -28,10 +29,10 @@
<FluentTab Label="@(Resources.IDS_LOGIN_TAB_USERNAME)" Id="Tab-Password" Style="padding:16px 0">
<FluentStack Orientation="Orientation.Vertical">
<FluentTextField @bind-Value="UserName" Placeholder="@(Resources.IDS_LOGIN_PLACEHOLDER_USERNAME)" Style="width: 100%">
<FluentIcon Value="@(new Icons.Regular.Size24.Person())" Slot="start" Color="Color.Neutral"/>
<FluentIcon Value="@(new Icons.Regular.Size24.Person())" Slot="start" Color="Color.Neutral" />
</FluentTextField>
<FluentTextField @bind-Value="Password" Placeholder="@(Resources.IDS_LOGIN_PLACEHOLDER_PASSWORD)" Style="width: 100%" TextFieldType="TextFieldType.Password">
<FluentIcon Value="@(new Icons.Regular.Size24.ShieldKeyhole())" Slot="start" Color="Color.Neutral"/>
<FluentIcon Value="@(new Icons.Regular.Size24.ShieldKeyhole())" Slot="start" Color="Color.Neutral" />
</FluentTextField>
</FluentStack>
</FluentTab>
Expand All @@ -40,15 +41,17 @@
</FluentBodyContent>
<div style="width: 100%; display: flex;align-items: center;">
<FluentButton Style="width: 100px;" Loading="Loading" Appearance="Appearance.Accent" OnClick="@OnClick">@(Resources.IDS_LOGIN_BUTTON_TEXT_LOGIN)</FluentButton>
<FluentSpacer/>
<a href="">Forget password?</a>
<FluentSpacer />
<a href="">@(Resources.IDS_LOGIN_BUTTON_TEXT_FORGET_PASSWORD)</a>
</div>

<FluentButton Appearance="Appearance.Lightweight" OnClick="@OnRegisterClicked">Register new user?</FluentButton>
@if (Configuration.GetValue<bool>("FeatureManagement:UserRegistration"))
{
<FluentButton Appearance="Appearance.Lightweight" OnClick="@OnRegisterClicked">@(Resources.IDS_LOGIN_BUTTON_TEXT_REGISTER)</FluentButton>
}
</FluentStack>
</FluentCard>
</FluentStack>
<FluentToastProvider MaxToastCount="10"/>
<FluentToastProvider MaxToastCount="10" />
</div>

@code {
Expand Down Expand Up @@ -113,10 +116,10 @@
private async Task<AuthResponseDto> SubmitAsync(CancellationToken cancellationToken = default)
{
var dto = new AuthRequestDto
{
UserName = UserName,
Password = Password
};
{
UserName = UserName,
Password = Password
};
return await Api.GrantTokenAsync(dto, cancellationToken).EnsureSuccess(cancellationToken);
}

Expand Down
2 changes: 1 addition & 1 deletion Source/Starfish.Webapp/Pages/User/Register.razor
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<img alt="logo" class="logo" src="logo.svg">
<span class="title" style="color:#fcab66; font-size: 24px;">Starfish</span>
</div>
<div class="desc">配置管理和服务发现</div>
<div class="desc">@(Resources.IDS_COMMON_SUBTITLE)</div>
</div>
<FluentCard>
<FluentStack Orientation="Orientation.Vertical">
Expand Down
2 changes: 1 addition & 1 deletion Source/Starfish.Webapp/Pages/User/ResetPassword.razor
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@

if (!string.Equals(Password, Confirm))
{
throw new ValidationException("Password and confirm password are not the same.");
throw new ValidationException(Resources.IDS_ERROR_PASSWORD_NOT_MATCH);
}

var data = new ResetPasswordRequestDto()
Expand Down
15 changes: 15 additions & 0 deletions Source/Starfish.Webapp/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,9 @@
<data name="IDS_COMMON_SUBMIT" xml:space="preserve">
<value>Submit</value>
</data>
<data name="IDS_COMMON_SUBTITLE" xml:space="preserve">
<value>Configuration management &amp; service discovery</value>
</data>
<data name="IDS_COMMON_YES" xml:space="preserve">
<value>Yes</value>
</data>
Expand Down Expand Up @@ -342,6 +345,9 @@
<data name="IDS_CONFIG_SYNC_REDIS_DIALOG_TITLE" xml:space="preserve">
<value>Sync to Redis</value>
</data>
<data name="IDS_ERROR_PASSWORD_NOT_MATCH" xml:space="preserve">
<value>The password you entered are not the same.</value>
</data>
<data name="IDS_HOME_COLUMN_CONFIGURATION" xml:space="preserve">
<value>Configuration</value>
</data>
Expand All @@ -366,9 +372,18 @@
<data name="IDS_HOME_LABEL_TEAMS" xml:space="preserve">
<value>Teams</value>
</data>
<data name="IDS_HOME_PAGE_TITLE" xml:space="preserve">
<value>Home</value>
</data>
<data name="IDS_LOGIN_BUTTON_TEXT_FORGET_PASSWORD" xml:space="preserve">
<value>Forget password?</value>
</data>
<data name="IDS_LOGIN_BUTTON_TEXT_LOGIN" xml:space="preserve">
<value>Login</value>
</data>
<data name="IDS_LOGIN_BUTTON_TEXT_REGISTER" xml:space="preserve">
<value>Register new user</value>
</data>
<data name="IDS_LOGIN_PAGE_TITLE" xml:space="preserve">
<value>Login</value>
</data>
Expand Down
15 changes: 15 additions & 0 deletions Source/Starfish.Webapp/Properties/Resources.zh-Hans.resx
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,9 @@
<data name="IDS_COMMON_SUBMIT" xml:space="preserve">
<value>提交</value>
</data>
<data name="IDS_COMMON_SUBTITLE" xml:space="preserve">
<value>配置管理和服务发现</value>
</data>
<data name="IDS_COMMON_YES" xml:space="preserve">
<value>是</value>
</data>
Expand Down Expand Up @@ -342,6 +345,9 @@
<data name="IDS_CONFIG_SYNC_REDIS_DIALOG_TITLE" xml:space="preserve">
<value>同步到Redis</value>
</data>
<data name="IDS_ERROR_PASSWORD_NOT_MATCH" xml:space="preserve">
<value>您输入的密码不一致。</value>
</data>
<data name="IDS_HOME_COLUMN_CONFIGURATION" xml:space="preserve">
<value>配置</value>
</data>
Expand All @@ -366,9 +372,18 @@
<data name="IDS_HOME_LABEL_TEAMS" xml:space="preserve">
<value>团队</value>
</data>
<data name="IDS_HOME_PAGE_TITLE" xml:space="preserve">
<value>首页</value>
</data>
<data name="IDS_LOGIN_BUTTON_TEXT_FORGET_PASSWORD" xml:space="preserve">
<value>忘记密码?</value>
</data>
<data name="IDS_LOGIN_BUTTON_TEXT_LOGIN" xml:space="preserve">
<value>登录</value>
</data>
<data name="IDS_LOGIN_BUTTON_TEXT_REGISTER" xml:space="preserve">
<value>注册新用户</value>
</data>
<data name="IDS_LOGIN_PAGE_TITLE" xml:space="preserve">
<value>登录</value>
</data>
Expand Down
15 changes: 15 additions & 0 deletions Source/Starfish.Webapp/Properties/Resources.zh-Hant.resx
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,9 @@
<data name="IDS_COMMON_SUBMIT" xml:space="preserve">
<value>提交</value>
</data>
<data name="IDS_COMMON_SUBTITLE" xml:space="preserve">
<value>配置管理和服務發現</value>
</data>
<data name="IDS_COMMON_YES" xml:space="preserve">
<value>是</value>
</data>
Expand Down Expand Up @@ -342,6 +345,9 @@
<data name="IDS_CONFIG_SYNC_REDIS_DIALOG_TITLE" xml:space="preserve">
<value>同步到Redis</value>
</data>
<data name="IDS_ERROR_PASSWORD_NOT_MATCH" xml:space="preserve">
<value>您輸入的密碼不一致。</value>
</data>
<data name="IDS_HOME_COLUMN_CONFIGURATION" xml:space="preserve">
<value>配置</value>
</data>
Expand All @@ -366,9 +372,18 @@
<data name="IDS_HOME_LABEL_TEAMS" xml:space="preserve">
<value>團隊</value>
</data>
<data name="IDS_HOME_PAGE_TITLE" xml:space="preserve">
<value>首頁</value>
</data>
<data name="IDS_LOGIN_BUTTON_TEXT_FORGET_PASSWORD" xml:space="preserve">
<value>忘記密碼?</value>
</data>
<data name="IDS_LOGIN_BUTTON_TEXT_LOGIN" xml:space="preserve">
<value>登入</value>
</data>
<data name="IDS_LOGIN_BUTTON_TEXT_REGISTER" xml:space="preserve">
<value>註冊新用戶</value>
</data>
<data name="IDS_LOGIN_PAGE_TITLE" xml:space="preserve">
<value>登入</value>
</data>
Expand Down
3 changes: 3 additions & 0 deletions Source/Starfish.Webapp/wwwroot/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,8 @@
"Api": {
"BaseUrl": "http://localhost:5229",
"Timeout": 10000
},
"FeatureManagement": {
"UserRegistration": false
}
}

0 comments on commit 3160f86

Please sign in to comment.