"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.isJSExpression = exports.generateI18n = void 0;
var _intlMessageformat = _interopRequireDefault(require("intl-messageformat"));
var isJSExpression = exports.isJSExpression = function isJSExpression(obj) {
  if (obj === void 0) {
    obj = '';
  }
  if (obj && typeof obj === 'object' && obj.type === 'JSExpression') {
    return true;
  }
  return false;
};

/**
 * 用于构造国际化字符串处理函数
 * @param {*} locale 国际化标识，例如 zh-CN、en-US
 * @param {*} messages 国际化语言包
 */
var generateI18n = exports.generateI18n = function generateI18n(locale, messages) {
  if (locale === void 0) {
    locale = 'zh-CN';
  }
  if (messages === void 0) {
    messages = {};
  }
  return function (key, values) {
    if (values === void 0) {
      values = {};
    }
    if (!messages || !messages[key]) return '';
    var formater = new _intlMessageformat["default"](messages[key], locale);
    return formater.format(values);
  };
};