configurable list of languages
This commit is contained in:
parent
554eb96824
commit
72daadee7e
|
@ -30,7 +30,6 @@
|
||||||
"scripts": [
|
"scripts": [
|
||||||
"node_modules/cookieconsent/build/cookieconsent.min.js",
|
"node_modules/cookieconsent/build/cookieconsent.min.js",
|
||||||
"node_modules/tinymce/tinymce.min.js"
|
"node_modules/tinymce/tinymce.min.js"
|
||||||
|
|
||||||
],
|
],
|
||||||
"vendorChunk": true,
|
"vendorChunk": true,
|
||||||
"extractLicenses": false,
|
"extractLicenses": false,
|
||||||
|
|
|
@ -41,6 +41,11 @@ export class ConfigurationService extends BaseComponent {
|
||||||
return this._defaultLanguage;
|
return this._defaultLanguage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _availableLanguages: any[] = [];
|
||||||
|
get availableLanguages(): any[] {
|
||||||
|
return this._availableLanguages;
|
||||||
|
}
|
||||||
|
|
||||||
private _loginProviders: LoginProviders;
|
private _loginProviders: LoginProviders;
|
||||||
get loginProviders(): LoginProviders {
|
get loginProviders(): LoginProviders {
|
||||||
return this._loginProviders;
|
return this._loginProviders;
|
||||||
|
@ -127,6 +132,7 @@ export class ConfigurationService extends BaseComponent {
|
||||||
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._defaultLanguage = config.defaultLanguage;
|
||||||
|
this._availableLanguages = config.availableLanguages;
|
||||||
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;
|
||||||
|
|
|
@ -7,8 +7,6 @@ import { BaseHttpService } from '../http/base-http.service';
|
||||||
import { Language } from '@app/models/language/Language';
|
import { Language } from '@app/models/language/Language';
|
||||||
import { ConfigurationService } from '../configuration/configuration.service';
|
import { ConfigurationService } from '../configuration/configuration.service';
|
||||||
|
|
||||||
const availableLanguages: any[] = require('../../../../assets/resources/language.json');
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class LanguageService {
|
export class LanguageService {
|
||||||
private currentLanguage: string;
|
private currentLanguage: string;
|
||||||
|
@ -43,7 +41,7 @@ export class LanguageService {
|
||||||
|
|
||||||
public getCurrentLanguageName() {
|
public getCurrentLanguageName() {
|
||||||
let result: string = '';
|
let result: string = '';
|
||||||
availableLanguages.forEach(language => {
|
this.configurationService.availableLanguages.forEach(language => {
|
||||||
if (language.value === this.currentLanguage) {
|
if (language.value === this.currentLanguage) {
|
||||||
result = this.translate.instant(language.label);
|
result = this.translate.instant(language.label);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,7 @@ import { LanguageService } from '@app/core/services/language/language.service';
|
||||||
import { UserService } from '@app/core/services/user/user.service';
|
import { UserService } from '@app/core/services/user/user.service';
|
||||||
import { takeUntil } from 'rxjs/operators';
|
import { takeUntil } from 'rxjs/operators';
|
||||||
import { BaseComponent } from '@common/base/base.component';
|
import { BaseComponent } from '@common/base/base.component';
|
||||||
|
import { ConfigurationService } from '@app/core/services/configuration/configuration.service';
|
||||||
const availableLanguages: any[] = require('../../../../assets/resources/language.json');
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-language',
|
selector: 'app-language',
|
||||||
|
@ -16,14 +15,18 @@ const availableLanguages: any[] = require('../../../../assets/resources/language
|
||||||
export class LanguageComponent extends BaseComponent implements OnInit {
|
export class LanguageComponent extends BaseComponent implements OnInit {
|
||||||
|
|
||||||
@Output() languageChange: EventEmitter<any> = new EventEmitter();
|
@Output() languageChange: EventEmitter<any> = new EventEmitter();
|
||||||
languages = availableLanguages;
|
languages = [];
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private router: Router,
|
private router: Router,
|
||||||
private authentication: AuthService,
|
private authentication: AuthService,
|
||||||
private languageService: LanguageService,
|
private languageService: LanguageService,
|
||||||
private userService: UserService
|
private userService: UserService,
|
||||||
) { super(); }
|
private configurationService:ConfigurationService
|
||||||
|
) {
|
||||||
|
super();
|
||||||
|
this.languages = this.configurationService.availableLanguages;
|
||||||
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.languageChange.emit(this.getCurrentLanguage().value)
|
this.languageChange.emit(this.getCurrentLanguage().value)
|
||||||
|
|
|
@ -1,29 +1,24 @@
|
||||||
import { Location } from '@angular/common';
|
import { Location } from '@angular/common';
|
||||||
|
import { HttpClient } from '@angular/common/http';
|
||||||
import { Component, ElementRef, EventEmitter, OnInit, Output, ViewChild } from '@angular/core';
|
import { Component, ElementRef, EventEmitter, OnInit, Output, ViewChild } from '@angular/core';
|
||||||
import { MatDialog } from '@angular/material/dialog';
|
import { MatDialog } from '@angular/material/dialog';
|
||||||
import { MatMenuTrigger } from '@angular/material/menu';
|
import { MatMenuTrigger } from '@angular/material/menu';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
import { AppRole } from '@app/core/common/enum/app-role';
|
import { AppRole } from '@app/core/common/enum/app-role';
|
||||||
|
import { UserListingModel } from '@app/core/model/user/user-listing';
|
||||||
import { AuthService } from '@app/core/services/auth/auth.service';
|
import { AuthService } from '@app/core/services/auth/auth.service';
|
||||||
|
import { ConfigurationService } from '@app/core/services/configuration/configuration.service';
|
||||||
|
import { LanguageService } from '@app/core/services/language/language.service';
|
||||||
|
import { MatomoService } from '@app/core/services/matomo/matomo-service';
|
||||||
import { ProgressIndicationService } from '@app/core/services/progress-indication/progress-indication-service';
|
import { ProgressIndicationService } from '@app/core/services/progress-indication/progress-indication-service';
|
||||||
|
import { SideNavService } from '@app/core/services/sidenav/side-nav.sevice';
|
||||||
|
import { UserService } from '@app/core/services/user/user.service';
|
||||||
import { BaseComponent } from '@common/base/base.component';
|
import { BaseComponent } from '@common/base/base.component';
|
||||||
import { takeUntil } from 'rxjs/operators';
|
import { takeUntil } from 'rxjs/operators';
|
||||||
|
import { StartNewDmpDialogComponent } from '../dmp/start-new-dmp-dialogue/start-new-dmp-dialog.component';
|
||||||
|
import { FaqDialogComponent } from '../faq/dialog/faq-dialog.component';
|
||||||
import { UserDialogComponent } from '../misc/navigation/user-dialog/user-dialog.component';
|
import { UserDialogComponent } from '../misc/navigation/user-dialog/user-dialog.component';
|
||||||
import { DATASETS_ROUTES, DMP_ROUTES, GENERAL_ROUTES } from '../sidebar/sidebar.component';
|
import { DATASETS_ROUTES, DMP_ROUTES, GENERAL_ROUTES } from '../sidebar/sidebar.component';
|
||||||
import { LanguageService } from '@app/core/services/language/language.service';
|
|
||||||
import { UserService } from '@app/core/services/user/user.service';
|
|
||||||
import { FaqDialogComponent } from '../faq/dialog/faq-dialog.component';
|
|
||||||
import { DmpInvitationDialogComponent } from '../dmp/invitation/dmp-invitation-dialog.component';
|
|
||||||
import { StartNewDmpDialogComponent } from '../dmp/start-new-dmp-dialogue/start-new-dmp-dialog.component';
|
|
||||||
import { UserListingModel } from '@app/core/model/user/user-listing';
|
|
||||||
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');
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-navbar',
|
selector: 'app-navbar',
|
||||||
templateUrl: './navbar.component.html',
|
templateUrl: './navbar.component.html',
|
||||||
|
@ -36,8 +31,7 @@ export class NavbarComponent extends BaseComponent implements OnInit {
|
||||||
mobile_menu_visible: any = 0;
|
mobile_menu_visible: any = 0;
|
||||||
private toggleButton: any;
|
private toggleButton: any;
|
||||||
private sidebarVisible: boolean;
|
private sidebarVisible: boolean;
|
||||||
languages = availableLanguages;
|
languages = [];
|
||||||
language = this.languages[0];
|
|
||||||
currentRoute: string;
|
currentRoute: string;
|
||||||
selectedLanguage: string;
|
selectedLanguage: string;
|
||||||
private user: UserListingModel;
|
private user: UserListingModel;
|
||||||
|
@ -60,6 +54,7 @@ export class NavbarComponent extends BaseComponent implements OnInit {
|
||||||
super();
|
super();
|
||||||
this.location = location;
|
this.location = location;
|
||||||
this.sidebarVisible = false;
|
this.sidebarVisible = false;
|
||||||
|
this.languages = this.configurationService.availableLanguages;
|
||||||
this.selectedLanguage = this.configurationService.defaultLanguage || 'en';
|
this.selectedLanguage = this.configurationService.defaultLanguage || 'en';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -266,7 +261,7 @@ export class NavbarComponent extends BaseComponent implements OnInit {
|
||||||
this.sidebarToggled.emit(event);
|
this.sidebarToggled.emit(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
toggleMyNav(event){
|
toggleMyNav(event) {
|
||||||
this.sidenavService.toggle();
|
this.sidenavService.toggle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,6 @@ import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms'
|
||||||
import { RoleOrganizationType } from '@app/core/common/enum/role-organization-type';
|
import { RoleOrganizationType } from '@app/core/common/enum/role-organization-type';
|
||||||
import { OrganizationModel } from '@app/core/model/organisation/organization';
|
import { OrganizationModel } from '@app/core/model/organisation/organization';
|
||||||
import { UserListingModel } from '@app/core/model/user/user-listing';
|
import { UserListingModel } from '@app/core/model/user/user-listing';
|
||||||
const availableLanguages: any[] = require('../../../assets/resources/language.json');
|
|
||||||
|
|
||||||
export class UserProfileEditorModel {
|
export class UserProfileEditorModel {
|
||||||
public id: String;
|
public id: String;
|
||||||
|
@ -25,7 +24,7 @@ export class UserProfileEditorModel {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
buildForm(): FormGroup {
|
buildForm(availableLanguages: any[]): FormGroup {
|
||||||
const formGroup = new FormBuilder().group({
|
const formGroup = new FormBuilder().group({
|
||||||
id: new FormControl(this.id),
|
id: new FormControl(this.id),
|
||||||
name: new FormControl(this.name),
|
name: new FormControl(this.name),
|
||||||
|
|
|
@ -31,9 +31,7 @@ import { FormValidationErrorsDialogComponent } from '@common/forms/form-validati
|
||||||
import { SnackBarNotificationLevel, UiNotificationService } from '@app/core/services/notification/ui-notification-service';
|
import { SnackBarNotificationLevel, UiNotificationService } from '@app/core/services/notification/ui-notification-service';
|
||||||
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 {PopupNotificationDialogComponent} from "@app/library/notification/popup/popup-notification.component";
|
import { PopupNotificationDialogComponent } from "@app/library/notification/popup/popup-notification.component";
|
||||||
|
|
||||||
const availableLanguages: any[] = require('../../../assets/resources/language.json');
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-user-profile',
|
selector: 'app-user-profile',
|
||||||
|
@ -49,7 +47,7 @@ export class UserProfileComponent extends BaseComponent implements OnInit, OnDes
|
||||||
cultures: Observable<CultureInfo[]>;
|
cultures: Observable<CultureInfo[]>;
|
||||||
timezones: Observable<any[]>;
|
timezones: Observable<any[]>;
|
||||||
editMode = false;
|
editMode = false;
|
||||||
languages = availableLanguages;
|
languages = [];
|
||||||
zenodoToken: string;
|
zenodoToken: string;
|
||||||
zenodoEmail: String;
|
zenodoEmail: String;
|
||||||
roleOrganizationEnum = RoleOrganizationType;
|
roleOrganizationEnum = RoleOrganizationType;
|
||||||
|
@ -86,7 +84,10 @@ export class UserProfileComponent extends BaseComponent implements OnInit, OnDes
|
||||||
private mergeEmailConfirmation: MergeEmailConfirmationService,
|
private mergeEmailConfirmation: MergeEmailConfirmationService,
|
||||||
private httpClient: HttpClient,
|
private httpClient: HttpClient,
|
||||||
private matomoService: MatomoService
|
private matomoService: MatomoService
|
||||||
) { super(); }
|
) {
|
||||||
|
super();
|
||||||
|
this.languages = this.configurationService.availableLanguages;
|
||||||
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.matomoService.trackPageView('User Profile');
|
this.matomoService.trackPageView('User Profile');
|
||||||
|
@ -101,7 +102,7 @@ export class UserProfileComponent extends BaseComponent implements OnInit, OnDes
|
||||||
this.zenodoEmail = result['zenodoEmail'];
|
this.zenodoEmail = result['zenodoEmail'];
|
||||||
|
|
||||||
this.userProfileEditorModel = new UserProfileEditorModel().fromModel(result);
|
this.userProfileEditorModel = new UserProfileEditorModel().fromModel(result);
|
||||||
this.formGroup = this.userProfileEditorModel.buildForm();
|
this.formGroup = this.userProfileEditorModel.buildForm(this.configurationService.availableLanguages);
|
||||||
// this.formGroup = new FormBuilder().group({
|
// this.formGroup = new FormBuilder().group({
|
||||||
// language: new FormControl(result['language'] ? availableLanguages.filter(x => x.value === result['language']['value']).pop() : '', [Validators.required]),
|
// language: new FormControl(result['language'] ? availableLanguages.filter(x => x.value === result['language']['value']).pop() : '', [Validators.required]),
|
||||||
// timezone: new FormControl(result['timezone'], [Validators.required]),
|
// timezone: new FormControl(result['timezone'], [Validators.required]),
|
||||||
|
|
|
@ -8,6 +8,48 @@
|
||||||
},
|
},
|
||||||
"defaultCulture": "en-US",
|
"defaultCulture": "en-US",
|
||||||
"defaultLanguage": "en",
|
"defaultLanguage": "en",
|
||||||
|
"availableLanguages": [
|
||||||
|
{
|
||||||
|
"label": "GENERAL.LANGUAGES.ENGLISH",
|
||||||
|
"value": "en"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "GENERAL.LANGUAGES.GREEK",
|
||||||
|
"value": "gr"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "GENERAL.LANGUAGES.SPANISH",
|
||||||
|
"value": "es"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "GENERAL.LANGUAGES.GERMAN",
|
||||||
|
"value": "de"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "GENERAL.LANGUAGES.TURKISH",
|
||||||
|
"value": "tr"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "GENERAL.LANGUAGES.SLOVAK",
|
||||||
|
"value": "sk"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "GENERAL.LANGUAGES.SERBIAN",
|
||||||
|
"value": "sr"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "GENERAL.LANGUAGES.PORTUGUESE",
|
||||||
|
"value": "pt"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "GENERAL.LANGUAGES.CROATIAN",
|
||||||
|
"value": "hr"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "GENERAL.LANGUAGES.POLISH",
|
||||||
|
"value": "pl"
|
||||||
|
}
|
||||||
|
],
|
||||||
"loginProviders": {
|
"loginProviders": {
|
||||||
"enabled": [1, 2, 3, 4, 5, 6, 7, 8],
|
"enabled": [1, 2, 3, 4, 5, 6, 7, 8],
|
||||||
"facebookConfiguration": { "clientId": "" },
|
"facebookConfiguration": { "clientId": "" },
|
||||||
|
|
|
@ -1,42 +0,0 @@
|
||||||
[
|
|
||||||
{
|
|
||||||
"label": "GENERAL.LANGUAGES.ENGLISH",
|
|
||||||
"value": "en"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"label": "GENERAL.LANGUAGES.GREEK",
|
|
||||||
"value": "gr"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"label": "GENERAL.LANGUAGES.SPANISH",
|
|
||||||
"value": "es"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"label": "GENERAL.LANGUAGES.GERMAN",
|
|
||||||
"value": "de"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"label": "GENERAL.LANGUAGES.TURKISH",
|
|
||||||
"value": "tr"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"label": "GENERAL.LANGUAGES.SLOVAK",
|
|
||||||
"value": "sk"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"label": "GENERAL.LANGUAGES.SERBIAN",
|
|
||||||
"value": "sr"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"label": "GENERAL.LANGUAGES.PORTUGUESE",
|
|
||||||
"value": "pt"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"label": "GENERAL.LANGUAGES.CROATIAN",
|
|
||||||
"value": "hr"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"label": "GENERAL.LANGUAGES.POLISH",
|
|
||||||
"value": "pl"
|
|
||||||
}
|
|
||||||
]
|
|
Loading…
Reference in New Issue