Adds language to cookie consent pop up. (Issue #203)
This commit is contained in:
parent
f652092726
commit
03143aacae
|
@ -24,10 +24,10 @@
|
||||||
"src/styles.scss",
|
"src/styles.scss",
|
||||||
"src/assets/scss/material-dashboard.scss",
|
"src/assets/scss/material-dashboard.scss",
|
||||||
"src/assets/css/demo.css",
|
"src/assets/css/demo.css",
|
||||||
"../dmp-frontend/node_modules/cookieconsent/build/cookieconsent.min.css"
|
"node_modules/cookieconsent/build/cookieconsent.min.css"
|
||||||
],
|
],
|
||||||
"scripts": [
|
"scripts": [
|
||||||
"../dmp-frontend/node_modules/cookieconsent/build/cookieconsent.min.js"
|
"node_modules/cookieconsent/build/cookieconsent.min.js"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"configurations": {
|
"configurations": {
|
||||||
|
|
|
@ -36,7 +36,6 @@ export class AppComponent implements OnInit {
|
||||||
private translate: TranslateService,
|
private translate: TranslateService,
|
||||||
private breadCrumbResolverService: BreadCrumbResolverService,
|
private breadCrumbResolverService: BreadCrumbResolverService,
|
||||||
private titleService: Title,
|
private titleService: Title,
|
||||||
private language: TranslateService,
|
|
||||||
private cultureService: CultureService,
|
private cultureService: CultureService,
|
||||||
private cookieService: CookieService,
|
private cookieService: CookieService,
|
||||||
private ccService: NgcCookieConsentService
|
private ccService: NgcCookieConsentService
|
||||||
|
@ -80,29 +79,41 @@ export class AppComponent implements OnInit {
|
||||||
})
|
})
|
||||||
).subscribe((ttl: string) => {
|
).subscribe((ttl: string) => {
|
||||||
if (ttl.length > 0) {
|
if (ttl.length > 0) {
|
||||||
this.language.get(ttl).subscribe((translated: string) => {
|
this.translate.get(ttl).subscribe((translated: string) => {
|
||||||
this.language.get('GENERAL.TITLES.PREFIX').subscribe((titlePrefix: string) => {
|
this.translate.get('GENERAL.TITLES.PREFIX').subscribe((titlePrefix: string) => {
|
||||||
this.titleService.setTitle(titlePrefix + translated);
|
this.titleService.setTitle(titlePrefix + translated);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.language.get('GENERAL.TITLES.GENERAL').subscribe((translated: string) => {
|
this.translate.get('GENERAL.TITLES.GENERAL').subscribe((translated: string) => {
|
||||||
this.titleService.setTitle(translated);
|
this.titleService.setTitle(translated);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.statusChangeSubscription = this.ccService.statusChange$
|
this.statusChangeSubscription = this.ccService.statusChange$.subscribe((event: NgcStatusChangeEvent) => {
|
||||||
.subscribe((event: NgcStatusChangeEvent) => {
|
if (event.status == "dismiss") {
|
||||||
if (event.status == "dismiss") {
|
this.cookieService.set("cookiesConsent", "true", 365);
|
||||||
this.cookieService.set("cookiesConsent", "true", 365);
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
this.translate
|
||||||
|
.get(['COOKIE.MESSAGE', 'COOKIE.DISMISS', 'COOKIE.DENY', 'COOKIE.LINK', 'COOKIE.POLICY'])
|
||||||
|
.subscribe(data => {
|
||||||
|
this.ccService.getConfig().content = this.ccService.getConfig().content || {};
|
||||||
|
// Override default messages with the translated ones
|
||||||
|
this.ccService.getConfig().content.message = data['COOKIE.MESSAGE'];
|
||||||
|
this.ccService.getConfig().content.dismiss = data['COOKIE.DISMISS'];
|
||||||
|
this.ccService.getConfig().content.deny = data['COOKIE.DENY'];
|
||||||
|
this.ccService.getConfig().content.link = data['COOKIE.LINK'];
|
||||||
|
this.ccService.getConfig().content.policy = data['COOKIE.POLICY'];
|
||||||
|
|
||||||
|
if (this.cookieService.get("cookiesConsent") == "true") {
|
||||||
|
this.ccService.getConfig().enabled = false;
|
||||||
}
|
}
|
||||||
});
|
this.ccService.destroy();
|
||||||
if (this.cookieService.get("cookiesConsent") == "true") {
|
this.ccService.init(this.ccService.getConfig());
|
||||||
this.ccService.getConfig().enabled = false;
|
})
|
||||||
this.ccService.destroy();
|
|
||||||
this.ccService.init(this.ccService.getConfig());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy() {
|
ngOnDestroy() {
|
||||||
|
|
|
@ -116,6 +116,13 @@
|
||||||
"DOC": "Document"
|
"DOC": "Document"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"COOKIE": {
|
||||||
|
"MESSAGE": "This website uses cookies to enhance the user experience.",
|
||||||
|
"DISMISS": "Got it!",
|
||||||
|
"DENY": "Refuse cookies",
|
||||||
|
"LINK": "Learn more",
|
||||||
|
"POLICY": "Cookie Policy"
|
||||||
|
},
|
||||||
"EMAIL-CONFIRMATION": {
|
"EMAIL-CONFIRMATION": {
|
||||||
"EXPIRED-EMAIL": "Mail invitation expired",
|
"EXPIRED-EMAIL": "Mail invitation expired",
|
||||||
"CARD-TITLE": "E-mail",
|
"CARD-TITLE": "E-mail",
|
||||||
|
|
Loading…
Reference in New Issue