diff --git a/src/app.js b/src/app.js index 05ca316..caa0b3f 100644 --- a/src/app.js +++ b/src/app.js @@ -29,6 +29,30 @@ export default class { * @param {object} contentData */ constructor(params, contentId, contentData = {}) { + params = Util.extend({ + l10n: { + recordAnswer: 'Record', + pause: 'Pause', + continue: 'Continue', + download: 'Download', + done: 'Done', + retry: 'Retry', + microphoneNotSupported: 'Microphone not supported. Make sure you are using a browser that allows microphone recording.', + microphoneInaccessible: 'Microphone is not accessible. Make sure that the browser microphone is enabled.', + insecureNotAllowed: 'Access to microphone is not allowed in your browser since this page is not served using HTTPS. Please contact the author, and ask him to make this available using HTTPS', + statusReadyToRecord: 'Press a button below to record your answer.', + statusRecording: 'Recording...', + statusPaused: 'Recording paused. Press a button to continue recording.', + statusFinishedRecording: 'You have successfully recorded your answer! Listen to the recording below.', + downloadRecording: 'Download this recording or retry.', + retryDialogHeaderText: 'Retry recording?', + retryDialogBodyText: 'By pressing "Retry" you will lose your current recording.', + retryDialogConfirmText: 'Retry', + retryDialogCancelText: 'Cancel', + statusCantCreateTheAudioFile: 'Can\'t create the audio file.' + } + }, params); + const rootElement = document.createElement('div'); rootElement.classList.add('h5p-audio-recorder'); diff --git a/src/components/Util.js b/src/components/Util.js new file mode 100644 index 0000000..9104434 --- /dev/null +++ b/src/components/Util.js @@ -0,0 +1,25 @@ +/** Class for utility functions */ +class Util { + /** + * Extend an array just like JQuery's extend. + * @param {object} arguments Objects to be merged. + * @return {object} Merged objects. + */ + static extend() { + for (let i = 1; i < arguments.length; i++) { + for (let key in arguments[i]) { + if (arguments[i].hasOwnProperty(key)) { + if (typeof arguments[0][key] === 'object' && typeof arguments[i][key] === 'object') { + this.extend(arguments[0][key], arguments[i][key]); + } + else { + arguments[0][key] = arguments[i][key]; + } + } + } + } + return arguments[0]; + } +} + +export default Util;