Merge branch 'MDL-68227-master' of git://github.com/sarjona/moodle

This commit is contained in:
Víctor Déniz Falcón 2020-05-13 17:13:11 +01:00
commit 6b37b6a1ba
8 changed files with 401 additions and 18 deletions

View File

@ -378,15 +378,10 @@ class editor {
$PAGE->requires->js(autoloader::get_h5p_editor_library_url('scripts/h5peditor-editor.js' . $cachebuster), true);
$PAGE->requires->js(autoloader::get_h5p_editor_library_url('scripts/h5peditor-init.js' . $cachebuster), true);
// Add translations.
// Load editor translations.
$language = framework::get_language();
$languagescript = "language/{$language}.js";
if (!file_exists("{$CFG->dirroot}" . autoloader::get_h5p_editor_library_base($languagescript))) {
$languagescript = 'language/en.js';
}
$PAGE->requires->js(autoloader::get_h5p_editor_library_url($languagescript . $cachebuster),
true);
$editorstrings = $this->get_editor_translations($language);
$PAGE->requires->data_for_js('H5PEditor.language.core', $editorstrings, false);
// Add JavaScript settings.
$root = $CFG->wwwroot;
@ -423,6 +418,47 @@ class editor {
$PAGE->requires->data_for_js('H5PIntegration', $settings, true);
}
/**
* Get editor translations for the defined language.
* Check if the editor strings have been translated in Moodle.
* If the strings exist, they will override the existing ones in the JS file.
*
* @param string $language The language for the translations to be returned.
* @return array The editor string translations.
*/
private function get_editor_translations(string $language): array {
global $CFG;
// Add translations.
$languagescript = "language/{$language}.js";
if (!file_exists("{$CFG->dirroot}" . autoloader::get_h5p_editor_library_base($languagescript))) {
$languagescript = 'language/en.js';
}
// Check if the editor strings have been translated in Moodle.
// If the strings exist, they will override the existing ones in the JS file.
// Get existing strings from current JS language file.
$langcontent = file_get_contents("{$CFG->dirroot}" . autoloader::get_h5p_editor_library_base($languagescript));
// Get only the content between { } (for instance, ; at the end of the file has to be removed).
$langcontent = substr($langcontent, 0, strpos($langcontent, '}', -0) + 1);
$langcontent = substr($langcontent, strpos($langcontent, '{'));
// Parse the JS language content and get a PHP array.
$editorstrings = helper::parse_js_array($langcontent);
foreach ($editorstrings as $key => $value) {
$stringkey = 'editor:'.strtolower(trim($key));
$value = autoloader::get_h5p_string($stringkey, $language);
if (!empty($value)) {
$editorstrings[$key] = $value;
}
}
return $editorstrings;
}
/**
* Preprocess the data sent through the form to the H5P JS Editor Library.
*

View File

@ -82,7 +82,6 @@ class helper {
return false;
}
/**
* Get the error messages stored in our H5P framework.
*
@ -410,4 +409,24 @@ class helper {
// Remove whitespaces and replace '.' to '_'.
return str_replace('.', '_', str_replace(' ', '', $library));
}
/**
* Parse a JS array to a PHP array.
*
* @param string $jscontent The JS array to parse to PHP array.
* @return array The JS array converted to PHP array.
*/
public static function parse_js_array(string $jscontent): array {
$jsarray = preg_split('/,\n\s+/', substr($jscontent, 0, -1));
$jsarray = preg_replace('~{?\\n~', '', $jsarray);
$strings = [];
foreach ($jsarray as $key => $value) {
$splitted = explode(":", $value, 2);
$value = preg_replace("/^['|\"](.*)['|\"]$/", "$1", trim($splitted[1], ' ,'));
$strings[ trim($splitted[0]) ] = str_replace("\'", "'", $value);
}
return $strings;
}
}

View File

@ -149,6 +149,17 @@ class autoloader {
return component_class_callback(self::get_handler_classname(), 'get_h5p_editor_library_base', [$filepath]);
}
/**
* Returns a localized string, if it exists in the h5plib plugin and the value it's different from the English version.
*
* @param string $identifier The key identifier for the localized string
* @param string $language Language to get the localized string.
* @return string|null The localized string or null if it doesn't exist in this H5P library plugin.
*/
public static function get_h5p_string(string $identifier, string $language): ?string {
return component_class_callback(self::get_handler_classname(), 'get_h5p_string', [$identifier, $language]);
}
/**
* Register the H5P autoloader.
*/

View File

@ -123,6 +123,31 @@ abstract class handler {
return new \moodle_url(static::get_h5p_editor_library_base($filepath), $params);
}
/**
* Returns a localized string, if it exists in the h5plib plugin and the value it's different from the English version.
*
* @param string $identifier The key identifier for the localized string
* @param string $language Language to get the localized string.
* @return string|null The localized string or null if it doesn't exist in this H5P library plugin.
*/
public static function get_h5p_string(string $identifier, string $language): ?string {
$value = null;
$h5pversion = static::get_h5p_version();
$component = 'h5plib_v' . $h5pversion;
if (get_string_manager()->string_exists($identifier, $component)) {
$defaultmoodlelang = 'en';
// In Moodle, all the English strings always will exist because they have to be declared in order to let users
// to translate them. That's why, this method will only replace existing key if the value is different from
// the English version and the current language is not English.
$string = new \lang_string($identifier, $component);
if ($language === $defaultmoodlelang || $string->out($language) !== $string->out($defaultmoodlelang)) {
$value = $string->out($language);
}
}
return $value;
}
/**
* Return the list of classes with their location within the joubel directory.
*

View File

@ -8,6 +8,13 @@ Import procedure:
- Copy all the files from the folder repository in this directory.
- In the method ns.LibrarySelector.prototype.appendTo (scripts/h5peditor-library-selector.js),
comment the line "this.$selector.appendTo($element);" to avoid the display of the Hub Selector.
- Review strings in joubel/editor/language/en.js and compare them with
existing ones in lang/en/h5plib_vXXX.php: add the new ones and remove the
unexisting ones. Remember to use the AMOS script commands, such CPY, to copy
all the existing strings from the previous version. As you'll see, all the
strings in en.js have been converted following these rules:
* Prefix "editor:" has been added.
* Keys have been lowercased.
Removed:
* composer.json

View File

@ -24,6 +24,221 @@
defined('MOODLE_INTERNAL') || die();
$string['editor:atoz'] = 'A to Z';
$string['editor:add'] = 'Add';
$string['editor:addauthor'] = 'Save author';
$string['editor:addentity'] = 'Add :entity';
$string['editor:addfile'] = 'Add file';
$string['editor:addnewchange'] = 'Add new change';
$string['editor:addtitle'] = 'Add title';
$string['editor:addvideodescription'] = 'H5P supports all external video sources formatted as mp4, webm or ogv, like Vimeo Pro, and has support for YouTube links.';
$string['editor:avtablistlabel'] = 'Insert using';
$string['editor:belowmin'] = 'The :property value is below the minimum of :min.';
$string['editor:cancel'] = 'Cancel';
$string['editor:cancellabel'] = 'Cancel';
$string['editor:changefile'] = 'Change file';
$string['editor:changelanguage'] = 'Change language to :language?';
$string['editor:changelibrary'] = 'Change content type?';
$string['editor:changelogdescription'] = 'Some licenses require that changes made to the original work, or derivatives are logged and displayed. You may log your changes here for licensing reasons or just to allow yourself and others to keep track of the changes made to this content.';
$string['editor:close'] = 'Close';
$string['editor:commonfields'] = 'Text overrides and translations';
$string['editor:commonfieldsdescription'] = 'Here you can edit settings or translate texts used in this content.';
$string['editor:confirmchangelibrary'] = 'By doing this you will lose all work done with the current content type. Are you sure you wish to change content type?';
$string['editor:confirmdeletechangelog'] = 'Are you sure you would like to delete this change log entry?';
$string['editor:confirmimageremoval'] = 'This will remove your image. Are you sure you wish to proceed?';
$string['editor:confirmpastebuttontext'] = 'Replace content';
$string['editor:confirmpastecontent'] = 'By doing this you will replace the current content with the content from your clipboard. The current content will be lost. Are you sure you wish to continue?';
$string['editor:confirmremoval'] = 'Are you sure you wish to remove this :type?';
$string['editor:confirmremoveauthor'] = 'Are you sure you would like to remove this author?';
$string['editor:contenttypebackbuttonlabel'] = 'Back';
$string['editor:contenttypecacheoutdated'] = 'Content type list outdated';
$string['editor:contenttypecacheoutdateddesc'] = 'Your site is having difficulties connecting to H5P.org to check for content type updates. You may not be able to update or install new content types.';
$string['editor:contenttypedemobuttonlabel'] = 'Content Demo';
$string['editor:contenttypedetailbuttonlabel'] = 'Details';
$string['editor:contenttypegetbuttonlabel'] = 'Get';
$string['editor:contenttypeiconalttext'] = 'Icon';
$string['editor:contenttypeinstallbuttonlabel'] = 'Install';
$string['editor:contenttypeinstallerror'] = ':contentType could not be installed. Contact your administrator.';
$string['editor:contenttypeinstallsuccess'] = ':contentType successfully installed!';
$string['editor:contenttypeinstallingbuttonlabel'] = 'Installing';
$string['editor:contenttypelicensepaneltitle'] = 'License';
$string['editor:contenttypenotinstalled'] = 'Content type not installed';
$string['editor:contenttypenotinstalleddesc'] = 'You do not have permission to install content types.';
$string['editor:contenttypeowner'] = 'By :owner';
$string['editor:contenttyperestricted'] = 'Restricted content type';
$string['editor:contenttyperestricteddesc'] = 'The use of this content type has been restricted by an administrator.';
$string['editor:contenttypesearchfieldplaceholder'] = 'Search for Content Types';
$string['editor:contenttypesectionall'] = 'All Content Types';
$string['editor:contenttypeunsupportedapiversioncontent'] = 'Contact your system administrator to provide you with the necessary updates';
$string['editor:contenttypeunsupportedapiversiontitle'] = 'This content type requires a newer core version';
$string['editor:contenttypeupdateavailable'] = 'Update available';
$string['editor:contenttypeupdatebuttonlabel'] = 'Update';
$string['editor:contenttypeupdatesuccess'] = ':contentType successfully updated!';
$string['editor:contenttypeupdatingbuttonlabel'] = 'Updating';
$string['editor:contenttypeusebuttonlabel'] = 'Use';
$string['editor:contributetranslations'] = 'If you want to complete the translation for :language you can learn about <a href=":url" target="_new">contributing translations to H5P</a>';
$string['editor:copiedbutton'] = 'Copied';
$string['editor:copiedtoclipboard'] = 'Content is copied to the clipboard';
$string['editor:copybutton'] = 'Copy';
$string['editor:copytoclipboard'] = 'Copy H5P content to the clipboard';
$string['editor:createcontenttablabel'] = 'Create Content';
$string['editor:currentmenuselected'] = 'current selection';
$string['editor:editcopyright'] = 'Edit copyright';
$string['editor:editimage'] = 'Edit image';
$string['editor:editmode'] = 'Editing mode';
$string['editor:enteraudiotitle'] = 'Paste link or other audio source URL';
$string['editor:enteraudiourl'] = 'Enter audio source URL';
$string['editor:enterfullscreenbuttonlabel'] = 'Enter fullscreen';
$string['editor:entervideotitle'] = 'Paste YouTube link or other video source URL';
$string['editor:entervideourl'] = 'Enter video source URL or YouTube link';
$string['editor:errorcalculatingmaxscore'] = 'Could not calculate the max score for this content. The max score is assumed to be 0. Contact your administrator if this isnt correct.';
$string['editor:errorcommunicatinghubcontent'] = 'An error occured. Please try again.';
$string['editor:errorcommunicatinghubtitle'] = 'Not able to communicate with hub.';
$string['editor:errorheader'] = 'An error occured';
$string['editor:errornotsupported'] = 'Parameters contain %used which is not supported.';
$string['editor:errorparamsbroken'] = 'Parameters are broken.';
$string['editor:errortoohighversion'] = 'Parameters contain %used while only %supported or earlier are supported.';
$string['editor:example'] = 'Example';
$string['editor:exceedsmax'] = 'The :property value exceeds the maximum of :max.';
$string['editor:exitfullscreenbuttonlabel'] = 'Exit fullscreen';
$string['editor:expandcollapse'] = 'Expand/Collapse';
$string['editor:filetolarge'] = 'The file you are trying to upload might be too large.';
$string['editor:fillinthefieldsbelow'] = 'Fill in the fields below';
$string['editor:gethelp'] = 'Get help';
$string['editor:h5pfileuploadservererrorcontent'] = 'An unexpected error occured. Check your server error log for\' + \' more details.';
$string['editor:h5pfileuploadservererrortitle'] = 'The H5P file could not be uploaded';
$string['editor:h5pfilevalidationfailedcontent'] = 'Make sure the uploaded H5P contains valid H5P content. H5P\' + \' files containing only libraries should be uploaded through the H5P Libraries page.';
$string['editor:h5pfilevalidationfailedtitle'] = 'Could not validate H5P file.';
$string['editor:h5pfilewrongextensioncontent'] = 'Only files with the .h5p extension are allowed.';
$string['editor:h5pfilewrongextensiontitle'] = 'The selected file could not be uploaded';
$string['editor:height'] = 'height';
$string['editor:hide'] = 'Hide';
$string['editor:hideimportantinstructions'] = 'Hide important instructions';
$string['editor:hubpanellabel'] = 'Select content type';
$string['editor:illegaldecimalnumber'] = ':property can only contain numbers with max :decimals decimals.';
$string['editor:imagelightboxprogress'] = ':num of :total';
$string['editor:imagelightboxtitle'] = 'Images';
$string['editor:importantinstructions'] = 'Important instructions';
$string['editor:insert'] = 'Insert';
$string['editor:invalidformat'] = 'Field value contains an invalid format or characters that are forbidden.';
$string['editor:language'] = 'Language';
$string['editor:librarymissing'] = 'Missing required library %lib.';
$string['editor:licensecandistribute'] = 'Can distribute';
$string['editor:licensecanholdliable'] = 'Can hold liable';
$string['editor:licensecanmodify'] = 'Can modify';
$string['editor:licensecansublicense'] = 'Can sublicense';
$string['editor:licensecanusecommercially'] = 'Can use commercially';
$string['editor:licensecannotholdliable'] = 'Cannot hold liable';
$string['editor:licensedescription'] = 'Some of the features of this license are indicated below. Click the info icon above to read the original license text.';
$string['editor:licensefetchdetailsfailed'] = 'Failed fetching license details';
$string['editor:licensemodalsubtitle'] = 'Select a license to view information about proper usage';
$string['editor:licensemodaltitle'] = 'License Details';
$string['editor:licensemustincludecopyright'] = 'Must include copyright';
$string['editor:licensemustincludelicense'] = 'Must include license';
$string['editor:licenseunspecified'] = 'Unspecified';
$string['editor:listbelowmin'] = 'The list needs at least :min items for the content to function properly.';
$string['editor:listexceedsmax'] = 'The list exceeds the maximum of :max items.';
$string['editor:listlabel'] = 'List';
$string['editor:loading'] = 'Loading, please wait...';
$string['editor:loadingimageeditor'] = 'Loading image editor, please wait...';
$string['editor:logthischange'] = 'Log this change';
$string['editor:loggedchanges'] = 'Logged changes';
$string['editor:maxscoresemanticsmissing'] = 'Could not find the expected semantics in the content.';
$string['editor:metadata'] = 'Metadata';
$string['editor:metadatasharingandlicensinginfo'] = 'Metadata (sharing and licensing info)';
$string['editor:missingproperty'] = 'Field :index is missing its :property property.';
$string['editor:missingtranslation'] = '[Missing translation :key]';
$string['editor:newchangehasbeenlogged'] = 'New change has been logged';
$string['editor:newestfirst'] = 'Newest First';
$string['editor:nextimage'] = 'Next image';
$string['editor:nochangeshavebeenlogged'] = 'No changes have been logged';
$string['editor:nocontenttypesavailable'] = 'No content types are available';
$string['editor:nocontenttypesavailabledesc'] = 'Your site is having difficulties connecting to H5P.org and listing the available content types.';
$string['editor:nofollow'] = 'Cannot follow field ":path".';
$string['editor:nolanguagessupported'] = 'No languages supported';
$string['editor:noresultsfound'] = 'No results found';
$string['editor:noresultsfounddesc'] = 'There is no content type that matches your search criteria.';
$string['editor:nosemantics'] = 'Error, could not load the content type form.';
$string['editor:notalltextschanged'] = 'Not all texts were changed, there is only partial coverage for :language.';
$string['editor:notimagefield'] = '":path" is not an image.';
$string['editor:notimageordimensionsfield'] = '":path" is not an image or dimensions field.';
$string['editor:numresults'] = ':num results';
$string['editor:numberfield'] = 'number field';
$string['editor:ok'] = 'OK';
$string['editor:onlynumbers'] = 'The :property value can only contain numbers.';
$string['editor:or'] = 'or';
$string['editor:orderitemdown'] = 'Order item down';
$string['editor:orderitemup'] = 'Order item up';
$string['editor:outofstep'] = 'The :property value can only be changed in steps of :step.';
$string['editor:pasteandreplacebutton'] = 'Paste & Replace';
$string['editor:pasteandreplacefromclipboard'] = 'Replace existing content with H5P Content from the clipboard';
$string['editor:pastebutton'] = 'Paste';
$string['editor:pastecontent'] = 'Replace Content';
$string['editor:pastecontentnotsupported'] = 'The content in the H5P clipboard is not supported in this context';
$string['editor:pastecontentrestricted'] = 'The content in the clipboard has been restricted on this site';
$string['editor:pasteerror'] = 'Cannot paste from clipboard';
$string['editor:pastefromclipboard'] = 'Paste H5P content from the clipboard';
$string['editor:pastenocontent'] = 'No H5P content on the clipboard';
$string['editor:pastetoonew'] = 'The content in the H5P clipboard is of a higher version (:clip) than what is supported in this context (:local), if possible try to have this content upgraded first, and then try pasting the content here again.';
$string['editor:pastetooold'] = 'The content in the H5P clipboard is of a lower version (:clip) than what is supported in this context (:local), if possible try to have the content you want to paste upgraded, copy it again and try pasting it here.';
$string['editor:popularfirst'] = 'Popular First';
$string['editor:previousimage'] = 'Previous image';
$string['editor:proceedbuttonlabel'] = 'Proceed to save';
$string['editor:readless'] = 'Read less';
$string['editor:readmore'] = 'Read more';
$string['editor:recentlyusedfirst'] = 'Recently Used First';
$string['editor:reloadbuttonlabel'] = 'Reload';
$string['editor:removefile'] = 'Remove file';
$string['editor:removeimage'] = 'Remove image';
$string['editor:removeitem'] = 'Remove item';
$string['editor:requiredproperty'] = 'The :property is required and must have a value.';
$string['editor:resettooriginallabel'] = 'Reset to original';
$string['editor:savelabel'] = 'Save';
$string['editor:savemetadata'] = 'Save metadata';
$string['editor:screenshots'] = 'Screenshots';
$string['editor:scriptmissing'] = 'Could not load upgrades script for %lib.';
$string['editor:searchresults'] = 'Search Results';
$string['editor:selectfiletoupload'] = 'Select file to upload';
$string['editor:selectlibrary'] = 'Select the library you wish to use for your content.';
$string['editor:semanticserror'] = 'Semantics error: :error';
$string['editor:show'] = 'Show';
$string['editor:showimportantinstructions'] = 'Show instructions';
$string['editor:tabtitlebasicfileupload'] = 'File Upload';
$string['editor:tabtitleinputlinkurl'] = 'Link/URL';
$string['editor:textfield'] = 'text field';
$string['editor:thecontenttype'] = 'the content type';
$string['editor:thiswillpotentially'] = 'This will potentially reset all the text and translations. You can\'t undo this. The content itself will not be changed. Do you want to proceed?';
$string['editor:title'] = 'Title';
$string['editor:toolong'] = 'Field value is too long, should contain :max letters or less.';
$string['editor:tryagain'] = 'Try again';
$string['editor:tutorial'] = 'Tutorial';
$string['editor:unabletointerpreterror'] = 'Unable to interpret response.';
$string['editor:unabletointerpretsolution'] = 'Please check your error log.';
$string['editor:unknownfieldpath'] = 'Unable to find ":path".';
$string['editor:unknownfileuploaderror'] = 'Unknown file upload error';
$string['editor:unknownlibrary'] = 'Unfortunately, the selected content type \'%lib\' isn\'t installed on this system.';
$string['editor:untitled'] = 'Untitled :libraryTitle';
$string['editor:uploadaudiotitle'] = 'Upload audio file';
$string['editor:uploaderror'] = 'File Upload Error';
$string['editor:uploadfilebuttonchangelabel'] = 'Change file';
$string['editor:uploadfilebuttonlabel'] = 'Upload a file';
$string['editor:uploadinstructionscontent'] = 'You may start with examples from <a href="https://h5p.org/content-types-and-applications" target="blank">H5P.org</a>.';
$string['editor:uploadinstructionstitle'] = 'Upload an H5P file.';
$string['editor:uploadplaceholder'] = 'No file chosen';
$string['editor:uploadsuccess'] = ':title was successfully uploaded!';
$string['editor:uploadtablabel'] = 'Upload';
$string['editor:uploadvideotitle'] = 'Upload video file';
$string['editor:uploading'] = 'Uploading, please wait...';
$string['editor:uploadingthrobber'] = 'Now uploading...';
$string['editor:usedforsearchingreportsandcopyrightinformation'] = 'Used for searching, reports and copyright information';
$string['editor:videoquality'] = 'Video quality label';
$string['editor:videoqualitydefaultlabel'] = 'Quality :index';
$string['editor:videoqualitydescription'] = 'This label helps the user identify the current quality of the video. E.g. 1080p, 720p, HD or Mobile';
$string['editor:warningchangebrowsingtoseeresults'] = 'Click <em>All</em> to get the list of all the content types you can install.';
$string['editor:warningnocontenttypesinstalled'] = 'You don\'t have any content types installed.';
$string['editor:warningupdateavailablebody'] = 'Update to the latest version for an improved experience.';
$string['editor:warningupdateavailabletitle'] = 'A new version of :contentType is available.';
$string['editor:width'] = 'width';
$string['pluginname'] = 'H5P framework v1.24';
$string['pluginname_help'] = 'H5P framework version 1.24.';
$string['privacy:metadata'] = 'The H5P framework v1.24 does not store any personal data.';

View File

@ -214,15 +214,6 @@ class editor_testcase extends advanced_testcase {
$item = $h5pcorepath . $item . $cachebuster;
});
// Add translation script.
$language = framework::get_language();
$languagescript = "language/{$language}.js";
if (!file_exists($CFG->dirroot . autoloader::get_h5p_editor_library_base($languagescript))) {
$languagescript = 'language/en.js';
}
$expectedjs[] = autoloader::get_h5p_editor_library_url($languagescript . $cachebuster)->out();
$expectedjs[] = (new \moodle_url('/h5p/js/h5p_overrides.js' . $cachebuster))->out();
$expectedjs[] = autoloader::get_h5p_editor_library_url('scripts/h5peditor-editor.js' . $cachebuster)->out();
$expectedjs[] = autoloader::get_h5p_editor_library_url('scripts/h5peditor-init.js' . $cachebuster)->out();

View File

@ -0,0 +1,79 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Testing the H5P library handler.
*
* @package core_h5p
* @category test
* @copyright 2020 Sara Arjona <sara@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core_h5p\local\library;
use advanced_testcase;
/**
* Test class covering the H5P library handler.
*
* @package core_h5p
* @copyright 2020 Sara Arjona <sara@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class handler_testcase extends advanced_testcase {
/**
* Test the behaviour of get_h5p_string().
*
* @dataProvider get_h5p_string_provider
* @param string $identifier The key identifier for the localized string.
* @param string $expectedresult Expected result.
* @param string $lang Language to get the localized string.
*/
public function test_get_h5p_string(string $identifier, ?string $expectedresult, ?string $lang = 'en'): void {
$result = autoloader::get_h5p_string($identifier, $lang);
$this->assertEquals($expectedresult, $result);
}
/**
* Data provider for test_get_h5p_string().
*
* @return array
*/
public function get_h5p_string_provider(): array {
return [
'Existing string in h5plib plugin' => [
'editor:add',
'Add',
],
'Unexisting translation for an existing string in h5plib plugin (es)' => [
'editor:add',
null,
'es',
],
'Unexisting string in h5plib plugin' => [
'unexistingstring',
null,
],
'Unexisting translation for an unexisting string in h5plib plugin (es)' => [
'unexistingstring',
null,
'es',
],
];
}
}