mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 18:14:17 +00:00
Merge pull request #3626 from DSpace/backport-3625-to-dspace-7_x
[Port dspace-7_x] Fix Klaro translations by forcing Klaro to use a zy language code that DSpace will translate
This commit is contained in:
@@ -101,7 +101,7 @@ describe('BrowserKlaroService', () => {
|
|||||||
|
|
||||||
mockConfig = {
|
mockConfig = {
|
||||||
translations: {
|
translations: {
|
||||||
zz: {
|
zy: {
|
||||||
purposes: {},
|
purposes: {},
|
||||||
test: {
|
test: {
|
||||||
testeritis: testKey
|
testeritis: testKey
|
||||||
@@ -159,8 +159,8 @@ describe('BrowserKlaroService', () => {
|
|||||||
|
|
||||||
it('addAppMessages', () => {
|
it('addAppMessages', () => {
|
||||||
service.addAppMessages();
|
service.addAppMessages();
|
||||||
expect(mockConfig.translations.zz[appName]).toBeDefined();
|
expect(mockConfig.translations.zy[appName]).toBeDefined();
|
||||||
expect(mockConfig.translations.zz.purposes[purpose]).toBeDefined();
|
expect(mockConfig.translations.zy.purposes[purpose]).toBeDefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('translateConfiguration', () => {
|
it('translateConfiguration', () => {
|
||||||
|
@@ -91,7 +91,7 @@ export class BrowserKlaroService extends KlaroService {
|
|||||||
initialize() {
|
initialize() {
|
||||||
if (!environment.info.enablePrivacyStatement) {
|
if (!environment.info.enablePrivacyStatement) {
|
||||||
delete this.klaroConfig.privacyPolicy;
|
delete this.klaroConfig.privacyPolicy;
|
||||||
this.klaroConfig.translations.zz.consentNotice.description = 'cookies.consent.content-notice.description.no-privacy';
|
this.klaroConfig.translations.zy.consentNotice.description = 'cookies.consent.content-notice.description.no-privacy';
|
||||||
}
|
}
|
||||||
|
|
||||||
const hideGoogleAnalytics$ = this.configService.findByPropertyName(this.GOOGLE_ANALYTICS_KEY).pipe(
|
const hideGoogleAnalytics$ = this.configService.findByPropertyName(this.GOOGLE_ANALYTICS_KEY).pipe(
|
||||||
@@ -238,12 +238,12 @@ export class BrowserKlaroService extends KlaroService {
|
|||||||
*/
|
*/
|
||||||
addAppMessages() {
|
addAppMessages() {
|
||||||
this.klaroConfig.services.forEach((app) => {
|
this.klaroConfig.services.forEach((app) => {
|
||||||
this.klaroConfig.translations.zz[app.name] = {
|
this.klaroConfig.translations.zy[app.name] = {
|
||||||
title: this.getTitleTranslation(app.name),
|
title: this.getTitleTranslation(app.name),
|
||||||
description: this.getDescriptionTranslation(app.name)
|
description: this.getDescriptionTranslation(app.name)
|
||||||
};
|
};
|
||||||
app.purposes.forEach((purpose) => {
|
app.purposes.forEach((purpose) => {
|
||||||
this.klaroConfig.translations.zz.purposes[purpose] = this.getPurposeTranslation(purpose);
|
this.klaroConfig.translations.zy.purposes[purpose] = this.getPurposeTranslation(purpose);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -257,7 +257,7 @@ export class BrowserKlaroService extends KlaroService {
|
|||||||
*/
|
*/
|
||||||
this.translateService.setDefaultLang(environment.defaultLanguage);
|
this.translateService.setDefaultLang(environment.defaultLanguage);
|
||||||
|
|
||||||
this.translate(this.klaroConfig.translations.zz);
|
this.translate(this.klaroConfig.translations.zy);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -17,7 +17,7 @@ export const GOOGLE_ANALYTICS_KLARO_KEY = 'google-analytics';
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Klaro configuration
|
* Klaro configuration
|
||||||
* For more information see https://kiprotect.com/docs/klaro/annotated-config
|
* For more information see https://klaro.org/docs/integration/annotated-configuration
|
||||||
*/
|
*/
|
||||||
export const klaroConfiguration: any = {
|
export const klaroConfiguration: any = {
|
||||||
storageName: ANONYMOUS_STORAGE_NAME_KLARO,
|
storageName: ANONYMOUS_STORAGE_NAME_KLARO,
|
||||||
@@ -47,21 +47,30 @@ export const klaroConfiguration: any = {
|
|||||||
|
|
||||||
htmlTexts: true,
|
htmlTexts: true,
|
||||||
|
|
||||||
|
/*
|
||||||
|
Force Klaro to use our custom "zy" lang configs defined below.
|
||||||
|
*/
|
||||||
|
lang: 'zy',
|
||||||
|
|
||||||
/*
|
/*
|
||||||
You can overwrite existing translations and add translations for your app
|
You can overwrite existing translations and add translations for your app
|
||||||
descriptions and purposes. See `src/translations/` for a full list of
|
descriptions and purposes. See `src/translations/` for a full list of
|
||||||
translations that can be overwritten:
|
translations that can be overwritten:
|
||||||
https://github.com/KIProtect/klaro/tree/master/src/translations
|
https://github.com/klaro-org/klaro-js/tree/master/src/translations
|
||||||
*/
|
*/
|
||||||
translations: {
|
translations: {
|
||||||
/*
|
/*
|
||||||
The `zz` key contains default translations that will be used as fallback values.
|
For DSpace we use this custom 'zy' key to map to our own i18n translations for klaro, see
|
||||||
This can e.g. be useful for defining a fallback privacy policy URL.
|
|
||||||
FOR DSPACE: We use 'zz' to map to our own i18n translations for klaro, see
|
|
||||||
translateConfiguration() in browser-klaro.service.ts. All the below i18n keys are specified
|
translateConfiguration() in browser-klaro.service.ts. All the below i18n keys are specified
|
||||||
in your /src/assets/i18n/*.json5 translation pack.
|
in your /src/assets/i18n/*.json5 translation pack.
|
||||||
|
This 'zy' key has no special meaning to Klaro & is not a valid language code. It just
|
||||||
|
allows DSpace to override Klaro's own translations in favor of DSpace's i18n keys.
|
||||||
|
NOTE: we do not use 'zz' as that has special meaning to Klaro and is ONLY used as a "fallback"
|
||||||
|
if no other translations can be found within Klaro. Currently, a bug in Klaro means that
|
||||||
|
'zz' is never used as there's no way to exclude translations:
|
||||||
|
https://github.com/klaro-org/klaro-js/issues/515
|
||||||
*/
|
*/
|
||||||
zz: {
|
zy: {
|
||||||
acceptAll: 'cookies.consent.accept-all',
|
acceptAll: 'cookies.consent.accept-all',
|
||||||
acceptSelected: 'cookies.consent.accept-selected',
|
acceptSelected: 'cookies.consent.accept-selected',
|
||||||
close: 'cookies.consent.close',
|
close: 'cookies.consent.close',
|
||||||
|
Reference in New Issue
Block a user