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() { 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().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) { toggleNavbar(event) {

View File

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

View File

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

View File

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