Skip to content

Commit

Permalink
HFP-3008 Add content language to iframe document
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasmars committed Aug 28, 2020
1 parent 16c71b4 commit 1a644dd
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion js/h5p.js
Original file line number Diff line number Diff line change
Expand Up @@ -378,8 +378,11 @@ H5P.init = function (target) {
// Insert H5Ps that should be in iframes.
H5P.jQuery('iframe.h5p-iframe:not(.h5p-initialized)', target).each(function () {
var contentId = H5P.jQuery(this).addClass('h5p-initialized').data('content-id');
const contentData = H5PIntegration.contents['cid-' + contentId];
const language = contentData && contentData.metadata && contentData.metadata.defaultLanguage
? contentData.metadata.defaultLanguage : 'en';
this.contentDocument.open();
this.contentDocument.write('<!doctype html><html class="h5p-iframe"><head>' + H5P.getHeadTags(contentId) + '</head><body><div class="h5p-content" data-content-id="' + contentId + '"/></body></html>');
this.contentDocument.write('<!doctype html><html class="h5p-iframe" lang="' + language + '"><head>' + H5P.getHeadTags(contentId) + '</head><body><div class="h5p-content" data-content-id="' + contentId + '"/></body></html>');
this.contentDocument.close();
});
};
Expand Down

0 comments on commit 1a644dd

Please sign in to comment.