Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | 146x 146x 4x 2x 2x 9x 146x 13x 13x 13x 13x | import { Translations } from '@bigcommerce/checkout-sdk'; import { FALLBACK_TRANSLATIONS } from './translations'; const AVAILABLE_TRANSLATIONS: Record<string, () => Promise<{ default: unknown }>> = { de: () => import( /* webpackChunkName: "translations-de" */ './translations/de.json' ), fr: () => import( /* webpackChunkName: "translations-fr" */ './translations/fr.json' ), it: () => import( /* webpackChunkName: "translations-it" */ './translations/it.json' ), nl: () => import( /* webpackChunkName: "translations-nl" */ './translations/nl.json' ), 'pt-BR': () => import( /* webpackChunkName: "translations-pt-br" */ './translations/pt-BR.json' ), pt: () => import( /* webpackChunkName: "translations-pt" */ './translations/pt.json' ), sv: () => import( /* webpackChunkName: "translations-sv" */ './translations/sv.json' ), en: () => Promise.resolve(({ default: FALLBACK_TRANSLATIONS })), }; export default async function getDefaultTranslations(requestedLocale: string): Promise<Translations> { const loadTranslations = AVAILABLE_TRANSLATIONS[requestedLocale] ?? AVAILABLE_TRANSLATIONS[requestedLocale.split('-')[0]]; return IloadTranslations ? asTranslations((await loadTranslations()).default) : {}; } function asTranslations(translations: unknown): Translations { return isTranslations(translations) ? translations : {}; } function isTranslations(translations: unknown): translations is Translations { return typeof translations === 'object'; } |