mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-24 23:12:24 -05:00
53b5ba93f5
These tests convert some extension metadata into scratch-blocks JSON and XML, then verify that the JSON and XML are as expected.
18 lines
800 B
JavaScript
18 lines
800 B
JavaScript
const formatMessage = require('format-message');
|
|
|
|
/**
|
|
* Check if `maybeMessage` looks like a message object, and if so pass it to `formatMessage`.
|
|
* Otherwise, return `maybeMessage` as-is.
|
|
* @param {*} maybeMessage - something that might be a message descriptor object.
|
|
* @param {object} [args] - the arguments to pass to `formatMessage` if it gets called.
|
|
* @param {string} [locale] - the locale to pass to `formatMessage` if it gets called.
|
|
* @return {string|*} - the formatted message OR the original `maybeMessage` input.
|
|
*/
|
|
const maybeFormatMessage = function (maybeMessage, args, locale) {
|
|
if (maybeMessage && maybeMessage.id && maybeMessage.default) {
|
|
return formatMessage(maybeMessage, args, locale);
|
|
}
|
|
return maybeMessage;
|
|
};
|
|
|
|
module.exports = maybeFormatMessage;
|