"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;

var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));

var _i18next = _interopRequireDefault(require("i18next"));

var _en = _interopRequireDefault(require("./en"));

var _es = _interopRequireDefault(require("./es"));

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }

_i18next["default"].init({
  fallbackLng: "en",
  lng: "en",
  debug: true,
  resources: {
    en: _en["default"],
    es: _es["default"]
  }
});

var _default = {
  translator: _objectSpread(_objectSpread({}, _i18next["default"]), {}, {
    t: function t(key, options) {
      var lng = options.lng;

      switch (lng) {
        // these keys don't work with plurals, don't know why, so I added a workaround to convert them to the correct lng
        case "en_US":
        case "en-US":
          options.lng = "en";
          break;

        case "es_ES":
        case "es-ES":
        case "es_MX":
        case "es-MX":
          options.lng = "es";
          break;

        default:
          break;
      }

      return _i18next["default"].t(key, _objectSpread({
        lng: lng
      }, options));
    }
  }),
  languageOptions: [{
    value: "en_US",
    label: "English (US)"
  }, {
    value: "es_ES",
    label: "Spanish"
  }]
};
exports["default"] = _default;
//# sourceMappingURL=index.js.map