UNPKG

@esri/calcite-components

Version:

Web Components for Esri's Calcite Design System.

31 lines (30 loc) 1.1 kB
/*! All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://github.com/Esri/calcite-design-system/blob/dev/LICENSE.md for details. v3.2.1 */ import { a as dateFromISO } from "./date.js"; import { b as getSupportedLocale } from "./locale.js"; import { g as getAssetPath } from "./runtime.js"; const translationCache = {}; const requestCache = {}; async function getLocaleData(lang) { const locale = getSupportedLocale(lang); if (translationCache[locale]) { return translationCache[locale]; } if (!requestCache[locale]) { requestCache[locale] = fetch(getAssetPath(`./assets/date-picker/nls/${locale}.json`)).then((resp) => resp.json()).catch(() => { console.error(`Translations for "${locale}" not found or invalid, falling back to english`); return getLocaleData("en"); }); } const data = await requestCache[locale]; translationCache[locale] = data; return data; } function getValueAsDateRange(value) { return value.map((v, index) => dateFromISO(v, index === 1)); } export { getLocaleData as a, getValueAsDateRange as g };