fixed default language support

This commit is contained in:
Diamantis Tziotzios 2022-10-11 18:52:08 +03:00
parent 2b692fa579
commit b018dd42db
5 changed files with 16 additions and 5 deletions

View File

@ -224,9 +224,9 @@ export class AppComponent implements OnInit, AfterViewInit {
// }
initializeServices() {
this.translate.setDefaultLang('en');
this.translate.setDefaultLang(this.configurationService.defaultLanguage || 'en');
this.authentication.current() && this.authentication.current().culture ? this.cultureService.cultureSelected(this.authentication.current().culture) : this.cultureService.cultureSelected(this.configurationService.defaultCulture);
this.authentication.current() && this.authentication.current().language ? this.language.changeLanguage(this.authentication.current().language) : this.language.changeLanguage('en');
this.authentication.current() && this.authentication.current().language ? this.language.changeLanguage(this.authentication.current().language) : (this.configurationService.defaultLanguage || 'en');
}
toggleNavbar(event) {

View File

@ -36,6 +36,11 @@ export class ConfigurationService extends BaseComponent {
return this._defaultCulture;
}
private _defaultLanguage: string;
get defaultLanguage(): string {
return this._defaultLanguage;
}
private _loginProviders: LoginProviders;
get loginProviders(): LoginProviders {
return this._loginProviders;
@ -126,6 +131,7 @@ export class ConfigurationService extends BaseComponent {
this._app = config.App;
this._helpService = HelpService.parseValue(config.HelpService);
this._defaultCulture = config.defaultCulture;
this._defaultLanguage = config.defaultLanguage;
this._loginProviders = LoginProviders.parseValue(config.loginProviders);
this._logging = Logging.parseValue(config.logging);
this._lockInterval = config.lockInterval;

View File

@ -11,7 +11,7 @@ const availableLanguages: any[] = require('../../../../assets/resources/language
@Injectable()
export class LanguageService {
private currentLanguage: string = 'en';
private currentLanguage: string;
private languageUrl : string;
constructor(
@ -21,6 +21,7 @@ export class LanguageService {
private configurationService: ConfigurationService
) {
this.languageUrl = `${configurationService.server}language`;
this.currentLanguage = this.configurationService.defaultLanguage || 'en';
}
public changeLanguage(lang: string) {

View File

@ -20,6 +20,7 @@ import { Principal } from '@app/core/model/auth/principal';
import { MatomoService } from '@app/core/services/matomo/matomo-service';
import { HttpClient } from '@angular/common/http';
import { SideNavService } from '@app/core/services/sidenav/side-nav.sevice';
import { ConfigurationService } from '@app/core/services/configuration/configuration.service';
const availableLanguages: any[] = require('../../../assets/resources/language.json');
@ -38,7 +39,7 @@ export class NavbarComponent extends BaseComponent implements OnInit {
languages = availableLanguages;
language = this.languages[0];
currentRoute: string;
selectedLanguage = 'en';
selectedLanguage: string;
private user: UserListingModel;
@Output() sidebarToggled: EventEmitter<any> = new EventEmitter();
@ViewChild(MatMenuTrigger) trigger: MatMenuTrigger;
@ -53,11 +54,13 @@ export class NavbarComponent extends BaseComponent implements OnInit {
public userService: UserService,
private httpClient: HttpClient,
private matomoService: MatomoService,
private sidenavService: SideNavService
private sidenavService: SideNavService,
private configurationService: ConfigurationService
) {
super();
this.location = location;
this.sidebarVisible = false;
this.selectedLanguage = this.configurationService.defaultLanguage || 'en';
}
ngOnInit() {

View File

@ -7,6 +7,7 @@
"Url": "localhost:5000/"
},
"defaultCulture": "en-US",
"defaultLanguage": "en",
"loginProviders": {
"enabled": [1, 2, 3, 4, 5, 6, 7, 8],
"facebookConfiguration": { "clientId": "" },