@adyen/adyen-web
Version:
[](https://www.npmjs.com/package/@adyen/adyen-web)
3 lines (2 loc) • 1.78 kB
JavaScript
import{getTranslation as t}from"./utils.js";import{getLocalisedAmount as e}from"../utils/amount-util.js";import i from"../core/Errors/AdyenCheckoutError.js";function o(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function r(t){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{},r=Object.keys(i);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(i).filter(function(t){return Object.getOwnPropertyDescriptor(i,t).enumerable}))),r.forEach(function(e){o(t,e,i[e])})}return t}class n{get(e,i){const o=t(this.translations,e,i);return null!==o?o:e}amount(t,i,o){return e(t,this.locale,i,o)}date(t,e={}){if(void 0===t)return"";const i=r({year:"numeric",month:"2-digit",day:"2-digit"},e);return new Date(t).toLocaleDateString(this.locale,i)}dateTime(t){return void 0===t?"":this.timeAndDateFormatter.format(new Date(t))}constructor(t){o(this,"locale",void 0),o(this,"languageCode",void 0),o(this,"translations",void 0),o(this,"customTranslations",void 0),o(this,"timeFormatOptions",{hour:"numeric",minute:"numeric"}),o(this,"timeAndDateFormatOptions",r({year:"numeric",month:"2-digit",day:"2-digit"},this.timeFormatOptions)),o(this,"timeAndDateFormatter",void 0);const{locale:e,translations:n,customTranslations:a}=t;if(!e)throw new i("IMPLEMENTATION_ERROR",'Language: "locale" property is not defined');this.locale=e,this.languageCode=this.locale.split("-")[0],this.customTranslations=a||{},this.timeAndDateFormatter=Intl.DateTimeFormat(this.locale,this.timeAndDateFormatOptions),this.translations=r({},n,!!this.customTranslations[this.locale]&&this.customTranslations[this.locale])}}export{n as Language,n as default};
//# sourceMappingURL=Language.js.map