mirror of
https://github.com/richard-loafle/fuse-angular.git
synced 2025-01-10 04:25:08 +00:00
Temporary solution to the ngx-translate issue while we are working on a better solution
This commit is contained in:
parent
126ba35d3d
commit
880529ad62
|
@ -28,10 +28,15 @@ export class AppComponent
|
||||||
// Set the default language
|
// Set the default language
|
||||||
this.translate.setDefaultLang('en');
|
this.translate.setDefaultLang('en');
|
||||||
|
|
||||||
// Set the navigation translations
|
// Give Angular some time to finish loading navigation before
|
||||||
this.fuseTranslationLoader.loadTranslations(navigationEnglish, navigationTurkish);
|
// loading navigation translations
|
||||||
|
setTimeout(() => {
|
||||||
|
|
||||||
// Use a language
|
// Set the navigation translations
|
||||||
this.translate.use('en');
|
this.fuseTranslationLoader.loadTranslations(navigationEnglish, navigationTurkish);
|
||||||
|
|
||||||
|
// Use a language
|
||||||
|
this.translate.use('en');
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnDestroy, OnInit } from '@angular/core';
|
||||||
import { NavigationEnd, NavigationStart, Router } from '@angular/router';
|
import { NavigationEnd, NavigationStart, Router } from '@angular/router';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
|
import { Subscription } from 'rxjs';
|
||||||
|
|
||||||
import { FuseConfigService } from '@fuse/services/config.service';
|
import { FuseConfigService } from '@fuse/services/config.service';
|
||||||
import { FuseSidebarService } from '@fuse/components/sidebar/sidebar.service';
|
import { FuseSidebarService } from '@fuse/components/sidebar/sidebar.service';
|
||||||
|
@ -14,7 +15,7 @@ import { navigation } from 'app/navigation/navigation';
|
||||||
styleUrls : ['./toolbar.component.scss']
|
styleUrls : ['./toolbar.component.scss']
|
||||||
})
|
})
|
||||||
|
|
||||||
export class FuseToolbarComponent implements OnInit
|
export class FuseToolbarComponent implements OnInit, OnDestroy
|
||||||
{
|
{
|
||||||
userStatusOptions: any[];
|
userStatusOptions: any[];
|
||||||
languages: any;
|
languages: any;
|
||||||
|
@ -23,6 +24,7 @@ export class FuseToolbarComponent implements OnInit
|
||||||
horizontalNav: boolean;
|
horizontalNav: boolean;
|
||||||
noNav: boolean;
|
noNav: boolean;
|
||||||
navigation: any;
|
navigation: any;
|
||||||
|
languageChangeSubscription: Subscription;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private router: Router,
|
private router: Router,
|
||||||
|
@ -94,7 +96,22 @@ export class FuseToolbarComponent implements OnInit
|
||||||
|
|
||||||
ngOnInit()
|
ngOnInit()
|
||||||
{
|
{
|
||||||
this.selectedLanguage = _.find(this.languages, {'id': this.translate.currentLang});
|
// Set the default language by hand to prevent
|
||||||
|
// errors while the translation service being
|
||||||
|
// initialized
|
||||||
|
this.selectedLanguage = this.languages[0];
|
||||||
|
|
||||||
|
// Subscribe to the language changes
|
||||||
|
this.languageChangeSubscription =
|
||||||
|
this.translate.onLangChange.subscribe((event) => {
|
||||||
|
this.selectedLanguage = _.find(this.languages, {'id': event.lang});
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnDestroy()
|
||||||
|
{
|
||||||
|
this.languageChangeSubscription.unsubscribe();
|
||||||
}
|
}
|
||||||
|
|
||||||
toggleSidebarOpened(key)
|
toggleSidebarOpened(key)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user