function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? Object(arguments[i]) : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

export function getComponentLocale(props, context, componentName, getDefaultLocale) {
  var locale = {};

  if (context && context.antLocale && context.antLocale[componentName]) {
    locale = context.antLocale[componentName];
  } else {
    var defaultLocale = getDefaultLocale(); // TODO: make default lang of antd be English
    // https://github.com/ant-design/ant-design/issues/6334

    locale = defaultLocale["default"] || defaultLocale;
  }

  var result = _objectSpread({}, locale);

  if (props.locale) {
    result = _objectSpread({}, result, props.locale);

    if (props.locale.lang) {
      result.lang = _objectSpread({}, locale.lang, props.locale.lang);
    }
  }

  return result;
}
export function getLocaleCode() {
  var lang = 'en_US';
  var langBook = {
    en: 'en_US',
    zh: 'zh_CN'
  };
  var _navigator = navigator,
      language = _navigator.language;
  var temp = language.split('-');

  if (temp[1]) {
    temp[1] = temp[1].toUpperCase();
    lang = temp.join('_');
  } else {
    lang = langBook[temp[0]];
  }

  return lang;
}