var _excluded = ["children"];
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
import { createI18njs } from '@procore/core-i18n-js';
import * as R from 'ramda';
import React from 'react';
import deDE from '../_locales/de-DE.json';
import enAU from '../_locales/en-AU.json';
import enCA from '../_locales/en-CA.json';
import enGB from '../_locales/en-GB.json';
import enUS from '../_locales/en-US.json';
import en from '../_locales/en.json';
import esES from '../_locales/es-ES.json';
import es from '../_locales/es.json';
import frCA from '../_locales/fr-CA.json';
import frFR from '../_locales/fr-FR.json';
import isIS from '../_locales/is-IS.json';
import isIT from '../_locales/it-IT.json';
import jaJP from '../_locales/ja-JP.json';
import ko from '../_locales/ko.json';
import ptBR from '../_locales/pt-BR.json';
import thTH from '../_locales/th-TH.json';
import zhSG from '../_locales/zh-SG.json';
/* Set up i18n-js */
export var coreTranslations = {
  'de-DE': deDE,
  en: en,
  'en-AU': enAU,
  'en-CA': enCA,
  'en-GB': enGB,
  'en-US': enUS,
  es: es,
  'es-ES': esES,
  'fr-CA': frCA,
  'fr-FR': frFR,
  'is-IS': isIS,
  'it-IT': isIT,
  'ja-JP': jaJP,
  ko: ko,
  'pt-BR': ptBR,
  'th-TH': thTH,
  'zh-SG': zhSG
};
function getValidLocale(_ref) {
  var locale = _ref.locale,
    translations = _ref.translations;
  return locale;
}
export function useI18n(_ref2) {
  var _locale = _ref2.locale,
    _ref2$translations = _ref2.translations,
    _translations = _ref2$translations === void 0 ? {} : _ref2$translations;
  var translations = R.mergeDeepLeft(_translations, coreTranslations);
  var locale = getValidLocale({
    locale: _locale,
    translations: translations
  });
  return createI18njs({
    locale: locale,
    translations: translations
  });
}
export var I18nContext = /*#__PURE__*/React.createContext(createI18njs({
  locale: 'en',
  translations: coreTranslations // inject our translations
}));

export function I18nProvider(_ref3) {
  var children = _ref3.children,
    props = _objectWithoutProperties(_ref3, _excluded);
  return /*#__PURE__*/React.createElement(I18nContext.Provider, {
    value: useI18n(props)
  }, children);
}
export function useI18nContext() {
  var ctx = React.useContext(I18nContext);
  if (!ctx) {
    // TODO investigate a way to do warnings that won't annoy people
    // we probably need to introduce a build system to have nice dev warnings
    // console.warn()
  }
  return ctx;
}
//# sourceMappingURL=I18n.js.map