@adyen/adyen-web
Version:
[](https://www.npmjs.com/package/@adyen/adyen-web)
3 lines (2 loc) • 1.03 kB
JavaScript
import{httpGet as r}from"../core/Services/http.js";import t from"../packages/server/translations/en-US.json.js";import{matchLocale as e}from"./utils.js";import{DEFAULT_LOCALE as o,CDN_SUPPORTED_LOCALES as s}from"./constants.js";function n(r,t,e){return t in r?Object.defineProperty(r,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):r[t]=e,r}class a{async fetchTranslationsFromCdn(e){const o=this.matchLocaleWithCdnSupportedLocales(e);if("en-US"===o)return t;try{return await r({loadingContext:this.cdnUrl,errorLevel:"fatal",errorMessage:`Translations: Failed to fetch translations for locale "${o}"`,path:`sdk/${this.sdkVersion}/translations/${o}.json`})}catch(r){return console.warn(`LanguageService - fetchTranslationsFromCdn(): Failed to fetch locale "${o}."`,r),t}}matchLocaleWithCdnSupportedLocales(r){return e(r,s)||o}constructor({cdnUrl:r,sdkVersion:t}){n(this,"cdnUrl",void 0),n(this,"sdkVersion",void 0),this.cdnUrl=r,this.sdkVersion=t}}export{a as LanguageService};
//# sourceMappingURL=LanguageService.js.map