INNER CODE UNIT · TypeScript
createScopedLocalize
baizunxian/zerorunner · frontend/src/components/monaco/nls/index.ts:220
function createScopedLocalize(scope) {
return function (idx, defaultValue) {
const restArgs = Array.prototype.slice.call(arguments, 2);
return _format(scope[idx], restArgs);
};
}
// export function localize(data, message, ...args) {
// return _format(message, args);
// }
// ------------------------invoke----------------------------------------
export function localize(path, data, defaultMessage, ...args) {
var key = typeof data === 'object' ? data.key : data;
var data = ${CURRENT_LOCALE_DATA} || {};
var message = (data[path] || {})[key];
if (!message) {
message = defaultMessage;
}
return _format(message, args);