Skip to content

Commit

Permalink
fix: fix i18n logic not save issue
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Apr 15, 2020
1 parent 6e626d4 commit 376d63f
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,14 @@ import { StorageMap } from '@ngx-pwa/local-storage';
})
export class AppComponent implements OnInit {
title = 'ledge';
tran: TranslateService;

constructor(
private route: Router,
translate: TranslateService,
public translate: TranslateService,
private storage: StorageMap
) {
translate.setDefaultLang('zh-cn');
translate.use('zh-cn');

this.tran = translate;
}

// component-todo: refactor
Expand All @@ -34,14 +31,14 @@ export class AppComponent implements OnInit {
}

setLanguage(lang: string) {
this.tran.use(lang);
this.storage.set('language', lang);
this.translate.use(lang);
this.storage.set('language', lang).subscribe();
}

ngOnInit(): void {
this.storage.get('language').subscribe((value: string) => {
if (!!value) {
this.tran.use(value);
this.translate.use(value);
}
});
}
Expand Down

0 comments on commit 376d63f

Please sign in to comment.