Ver código fonte

[web-app]i18n for login

tomsun28 3 anos atrás
pai
commit
2de1aa4069

+ 2 - 2
web-app/src/app/routes/passport/lock/lock.component.html

@@ -7,11 +7,11 @@
       <nz-form-item>
         <nz-form-control [nzErrorTip]="'validation.password.required' | i18n">
           <nz-input-group nzSuffixIcon="lock">
-            <input type="text" nz-input formControlName="password" placeholder="输入任意解锁" />
+            <input type="text" nz-input formControlName="password" [placeholder]="'app.lock.placeholder' | i18n" />
           </nz-input-group>
         </nz-form-control>
       </nz-form-item>
-      <nz-row nzType="flex" nzAlign="middle">
+      <nz-row nzAlign="middle">
         <nz-col [nzOffset]="12" [nzSpan]="12" style="text-align: right">
           <button nz-button [disabled]="!f.valid" nzType="primary">{{ 'app.lock' | i18n }}</button>
         </nz-col>

+ 4 - 4
web-app/src/app/routes/passport/login/login.component.html

@@ -3,16 +3,16 @@
     <nz-tab [nzTitle]="'app.login.tab-login-credentials' | i18n">
       <nz-alert *ngIf="error" [nzType]="'error'" [nzMessage]="error" [nzShowIcon]="true" class="mb-lg"></nz-alert>
       <nz-form-item>
-        <nz-form-control nzErrorTip="请输入用户名">
+        <nz-form-control [nzErrorTip]="'app.login.message-need-identifier' | i18n">
           <nz-input-group nzSize="large" nzPrefixIcon="user">
-            <input nz-input formControlName="userName" placeholder="请输入用户名" />
+            <input nz-input formControlName="userName" [placeholder]="'app.login.message-need-identifier' | i18n" />
           </nz-input-group>
         </nz-form-control>
       </nz-form-item>
       <nz-form-item>
-        <nz-form-control nzErrorTip="请输入密码">
+        <nz-form-control [nzErrorTip]="'app.login.message-need-credential' | i18n">
           <nz-input-group nzSize="large" nzPrefixIcon="lock">
-            <input nz-input type="password" formControlName="password" placeholder="请输入密码" />
+            <input nz-input type="password" formControlName="password" [placeholder]="'app.login.message-need-credential' | i18n" />
           </nz-input-group>
         </nz-form-control>
       </nz-form-item>

+ 5 - 4
web-app/src/app/routes/passport/login/login.component.ts

@@ -1,10 +1,10 @@
 import { ChangeDetectionStrategy, ChangeDetectorRef, Component, Inject, OnDestroy, Optional } from '@angular/core';
 import { AbstractControl, FormBuilder, FormGroup, Validators } from '@angular/forms';
 import { Router } from '@angular/router';
-import { StartupService } from '@core';
+import { I18NService, StartupService } from '@core';
 import { ReuseTabService } from '@delon/abc/reuse-tab';
-import { DA_SERVICE_TOKEN, ITokenService, SocialOpenType, SocialService } from '@delon/auth';
-import { SettingsService, _HttpClient } from '@delon/theme';
+import { DA_SERVICE_TOKEN, ITokenService, SocialService } from '@delon/auth';
+import { SettingsService, _HttpClient, ALAIN_I18N_TOKEN } from '@delon/theme';
 import { User } from '@delon/theme/src/services/settings/types';
 import { NzTabChangeEvent } from 'ng-zorro-antd/tabs';
 import { finalize } from 'rxjs/operators';
@@ -29,6 +29,7 @@ export class UserLoginComponent implements OnDestroy {
     @Inject(ReuseTabService)
     private reuseTabService: ReuseTabService,
     @Inject(DA_SERVICE_TOKEN) private tokenService: ITokenService,
+    @Inject(ALAIN_I18N_TOKEN) private i18nSvc: I18NService,
     private startupSrv: StartupService,
     private http: _HttpClient,
     private cdr: ChangeDetectorRef,
@@ -125,7 +126,7 @@ export class UserLoginComponent implements OnDestroy {
         let user: User = {
           name: this.userName.value,
           avatar: './assets/img/avatar.svg',
-          email: '管理员'
+          email: this.i18nSvc.fanyi('app.role.admin')
         };
         this.settingsService.setUser(user);
         // 重新获取 StartupService 内容,我们始终认为应用信息一般都会受当前用户授权范围而影响

+ 4 - 18
web-app/src/assets/i18n/en-US.json

@@ -172,35 +172,21 @@
   "common.button.cancel": "Cancel",
   "common.button.help": "Help",
   "common.button.detect": "Detect",
-  "app.login.message-need-identifier": "Please enter your email or mobile number",
-  "app.login.message-need-credential": "Please enter password",
-  "app.password.forgot": "Forgot password",
-  "app.password.reset": "Reset password",
-  "app.register-result.login": "Login",
   "validation.email.invalid": "Invalid email!",
   "validation.phone.invalid": "Invalid phone number!",
   "validation.verification-code.invalid": "Invalid verification code, should be 6 digits!",
   "validation.required": "Please fill in the required fields! ",
+  "app.role.admin": "Administrator",
   "app.lock": "Lock",
+  "app.lock.placeholder": "Enter Any To Unlock",
   "app.passport.desc": "TanCloud-Friendly High Performance Monitoring Cloud Service",
   "app.passport.welcome": "Welcome To Use TanCloud-Monitoring Cloud Service-tancloud.cn",
+  "app.login.message-need-identifier": "Please enter your username",
+  "app.login.message-need-credential": "Please enter password",
   "app.login.message-invalid-credentials": "Invalid username or password",
-  "app.login.message-invalid-verification-code": "Invalid verification code",
   "app.login.tab-login-credentials": "Credentials",
-  "app.login.tab-login-mobile": "Mobile number",
   "app.login.remember-me": "Remember me",
-  "app.login.forgot-password": "Forgot your password?",
-  "app.login.sign-in-with": "Sign in with",
-  "app.login.signup": "Sign up",
   "app.login.login": "Login",
-  "app.register.register": "Register",
-  "app.register.get-verification-code": "Get code",
-  "app.register.sign-in": "Already have an account?",
-  "app.register-result.msg": "Account:registered at {{email}}",
-  "app.register-result.activation-email":
-    "The activation email has been sent to your email address and is valid for 24 hours. Please log in to the email in time and click on the link in the email to activate the account.",
-  "app.register-result.back-home": "Back to home",
-  "app.register-result.view-mailbox": "View mailbox",
   "validation.email.required": "Please enter your email!",
   "validation.email.wrong-format": "The email address is in the wrong format!",
   "validation.password.required": "Please enter your password!",

+ 3 - 17
web-app/src/assets/i18n/zh-CN.json

@@ -172,31 +172,17 @@
   "common.button.detect": "测试",
   "common.button.cancel": "取消",
   "common.button.help": "帮助",
+  "app.role.admin": "管理员",
   "app.lock": "锁屏",
+  "app.lock.placeholder": "输入任意解锁",
   "app.passport.desc": "TanCloud-易用友好的高性能监控云服务",
   "app.passport.welcome": "欢迎使用TanCloud探云-监控云服务-tancloud.cn",
-  "app.login.message-need-identifier": "请输入邮箱或手机号",
+  "app.login.message-need-identifier": "请输入用户名",
   "app.login.message-need-credential": "请输入密码",
   "app.login.message-invalid-credentials": "账户或密码错误",
-  "app.login.message-invalid-verification-code": "验证码错误",
   "app.login.tab-login-credentials": "账户密码登录",
-  "app.login.tab-login-mobile": "手机号登录",
   "app.login.remember-me": "自动登录",
-  "app.login.forgot-password": "忘记密码",
-  "app.login.sign-in-with": "其他登录方式",
-  "app.login.signup": "注册账户",
   "app.login.login": "登录",
-  "app.password.forgot": "忘记密码",
-  "app.password.reset": "重置密码",
-  "app.register.register": "注册",
-  "app.register.get-verification-code": "获取验证码",
-  "app.register.sign-in": "使用已有账户登录",
-  "app.register-result.msg": "你的账户:{{email}} 注册成功",
-  "app.register-result.activation-email":
-    "额外赠送监控额度邮件已发送到你的邮箱中。请及时登录邮箱,点击邮件中的链接领取。",
-  "app.register-result.login": "开始登录",
-  "app.register-result.back-home": "返回首页",
-  "app.register-result.view-mailbox": "查看邮箱",
   "validation.email.required": "请输入邮箱地址!",
   "validation.email.wrong-format": "邮箱地址格式错误!",
   "validation.email.invalid": "无效的邮箱地址!",