skedify-calendar
Version:
Skedify Calendar React component
31 lines (23 loc) • 1.01 kB
JavaScript
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
import { createContext } from 'react';
import { nl, fr, de } from 'date-fns/locale';
var AVAILABLE_LOCALES = {
de: de,
fr: fr,
nl: nl
};
var DEFAULT_LOCALE = undefined; // The default for date-fns will be english anyway
export function loadLocale(locale) {
// Assuming that when an object is passed
// It is a valid date-fns object
if ((typeof locale === 'undefined' ? 'undefined' : _typeof(locale)) === 'object' && locale !== null) {
return locale;
}
if (Object.keys(AVAILABLE_LOCALES).indexOf(locale) === -1) {
return DEFAULT_LOCALE;
}
// If a string is passed
// Only one of the supported locales is used
return AVAILABLE_LOCALES[locale];
}
export var LocaleContext = createContext(loadLocale('en'));