Skip to content

Commit

Permalink
feat: load lang menu on change page lang
Browse files Browse the repository at this point in the history
  • Loading branch information
mohammad-haji committed Aug 14, 2018
1 parent 01e1b17 commit a267e5e
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export class LayoutDirectionSwitcherComponent implements OnDestroy, OnInit {
constructor(private directionService: NbLayoutDirectionService, public translate: TranslateService) {
translate.addLangs(['fa', 'en']);
translate.setDefaultLang('fa');
translate.currentLang = 'fa';

const browserLang = translate.getBrowserLang();
// translate.use(browserLang.match(/en|fa/) ? browserLang : 'fa');
Expand All @@ -42,12 +43,14 @@ export class LayoutDirectionSwitcherComponent implements OnDestroy, OnInit {
}

ngOnInit() {
this.toggleDirection('rtl', 'fa');
// this.toggleDirection('rtl', 'fa');
}

toggleDirection(newDirection, lang) {
let _lang = lang === 'rtl' ? 'en' : 'fa';
this.translate.use(_lang);
this.translate.currentLang = _lang;
this.directionService.setDirection(newDirection);
this.translate.use((lang === 'rtl' ? 'en' : 'fa'))
}

ngOnDestroy() {
Expand Down

0 comments on commit a267e5e

Please sign in to comment.