dspace-angular
dspace-angular copied to clipboard
Fix Klaro translations by forcing Klaro to use a `zy` language code that DSpace will translate
References
- Related to #2027
- Broken since upgrade to Klaro 0.7.19. See https://github.com/klaro-org/klaro-js/issues/515
Description
After upgrading to Klaro 0.7.19 (or later), our custom message translations are no longer loading into Klaro. This can be seen on both https://sandbox.dspace.org and https://demo.dspace.org because the Klaro Cookie pop-up shows the default Klaro text like this:
The main issue is that the Klaro 'zz' "default translations" no longer seem to work. The reason is because Klaro only uses the zz translations if no other languages can be found, and (as of 0.7.19) the klaro-no-translations package is wrongly including all the translations (see https://github.com/klaro-org/klaro-js/issues/515). So, there's no longer a way to tell Klaro to not include translations and therefore to only use the zz language code.
This PR fixes the issue by changing our Klaro configuration to force Klaro to always use a (different, fake) language code of zy. In our Klaro configuration, we then use our i18n keys for the zy language, and translate it to the user's language as we did before.
Instructions for Reviewers
- Verify the Klaro cookie popup works as before. It's easiest to verify by opening the homepage in an Incognito window.
This bug does NOT impact 7.6.2 or 8.0 (as they both used Klaro 0.7.18). However, it does impact main, dspace-8_x and dspace-7_x as they all now use Klaro 0.7.21 (and this Klaro bug began with 0.7.19).