diff options
author | guochuyicmri <guochuyi@chinamobile.com> | 2019-05-08 10:55:37 +0800 |
---|---|---|
committer | guochuyicmri <guochuyi@chinamobile.com> | 2019-05-08 10:55:46 +0800 |
commit | d55e3b044987f29f03de2816e2cd8015c54c9db3 (patch) | |
tree | 5fe2b92222483983d58b2edf892e2b60d5cbde3f /usecaseui-portal/src/app/app.component.ts | |
parent | bf240f4fad6e8bf032bd1f190b238682a9fb721a (diff) |
UUI interface Multi-language development
Change-Id: I687222a6342e57bb81651ac210a8862f1980b051
Issue-ID: USECASEUI-211
Signed-off-by: guochuyicmri <guochuyi@chinamobile.com>
Diffstat (limited to 'usecaseui-portal/src/app/app.component.ts')
-rw-r--r-- | usecaseui-portal/src/app/app.component.ts | 40 |
1 files changed, 32 insertions, 8 deletions
diff --git a/usecaseui-portal/src/app/app.component.ts b/usecaseui-portal/src/app/app.component.ts index 0bdf72b2..1a7c48d8 100644 --- a/usecaseui-portal/src/app/app.component.ts +++ b/usecaseui-portal/src/app/app.component.ts @@ -13,8 +13,10 @@ See the License for the specific language governing permissions and limitations under the License. */ -import { Component } from '@angular/core'; -import { TranslateService } from '@ngx-translate/core'; +import {Component} from '@angular/core'; +import {TranslateService} from '@ngx-translate/core'; +import {MyhttpService} from "./myhttp.service"; +import {HomesService} from "./homes.service"; @Component({ @@ -23,15 +25,37 @@ import { TranslateService } from '@ngx-translate/core'; styleUrls: ['./app.component.less'] }) export class AppComponent { - constructor(private translate:TranslateService){ - translate.addLangs(['en', 'zh']); - translate.setDefaultLang('en'); - // translate.use('en'); - } + + constructor(private translate: TranslateService,private myhttp: HomesService) { + this.currentLanguageGet(); + translate.addLangs(['en', 'zh']); + // translate.use('en'); + } Language:String[] = ["zh","en"]; - selectLanguage = "en"; + //209.05.08 Get the currentLanguage + currentloginId = null; + currentLanguage = "en"; + currentLanguageGet() { + this.currentloginId = sessionStorage.getItem("loginId") || null; + if (this.currentloginId != null) { + this.myhttp.getCurrentLanguage(this.currentloginId) + .subscribe( + (data) => { + this.currentLanguage = data.languageName.toLowerCase(); + this.translate.use(this.currentLanguage); + }, + (err) => { + console.log(err); + } + ) + }else { + this.translate.setDefaultLang('en'); + } + } + + selectLanguage = "en"; changeLanguage(item){ this.selectLanguage = item; |