angular-l10n
Advanced tools
Comparing version 3.4.0 to 3.4.1
!function(global,factory){"object"==typeof exports&&"undefined"!=typeof module?factory(exports,require("@angular/core"),require("rxjs/Subject"),require("rxjs/Observable"),require("rxjs/add/operator/toPromise"),require("rxjs/add/observable/merge"),require("@angular/http"),require("rxjs/add/operator/map"),require("@angular/common"),require("@angular/forms")):"function"==typeof define&&define.amd?define(["exports","@angular/core","rxjs/Subject","rxjs/Observable","rxjs/add/operator/toPromise","rxjs/add/observable/merge","@angular/http","rxjs/add/operator/map","@angular/common","@angular/forms"],factory):factory((global.ng=global.ng||{},global.ng.l10n=global.ng.l10n||{}),global.ng.core,global.Rx,global.Rx,global.Rx,global.Rx,global.ng.http,global.Rx,global.ng.common,global.ng.forms)}(this,function(exports,_angular_core,rxjs_Subject,rxjs_Observable,rxjs_add_operator_toPromise,rxjs_add_observable_merge,_angular_http,rxjs_add_operator_map,_angular_common,_angular_forms){"use strict";function Language(){function DecoratorFactory(target,propertyKey){function ngOnInit(){var _this=this,translation=InjectorRef.get(TranslationService);void 0!==propertyKey&&(this[propertyKey]=translation.getLanguage(),subscription=translation.translationChanged.subscribe(function(language){_this[propertyKey]=language})),targetNgOnInit&&targetNgOnInit.apply(this)}function ngOnDestroy(){void 0!==subscription&&subscription.unsubscribe(),targetNgOnDestroy&&targetNgOnDestroy.apply(this)}var subscription,targetNgOnInit=target.ngOnInit;target.ngOnInit=ngOnInit;var targetNgOnDestroy=target.ngOnDestroy;target.ngOnDestroy=ngOnDestroy,void 0!==propertyKey&&Object.defineProperty(target,propertyKey,{writable:!0,value:void 0})}return DecoratorFactory}function DefaultLocale$1(){function DecoratorFactory(target,propertyKey){function ngOnInit(){var _this=this,locale=InjectorRef.get(LocaleService);void 0!==propertyKey&&(this[propertyKey]=locale.getDefaultLocale(),subscription=locale.defaultLocaleChanged.subscribe(function(defaultLocale){_this[propertyKey]=defaultLocale})),targetNgOnInit&&targetNgOnInit.apply(this)}function ngOnDestroy(){void 0!==subscription&&subscription.unsubscribe(),targetNgOnDestroy&&targetNgOnDestroy.apply(this)}var subscription,targetNgOnInit=target.ngOnInit;target.ngOnInit=ngOnInit;var targetNgOnDestroy=target.ngOnDestroy;target.ngOnDestroy=ngOnDestroy,void 0!==propertyKey&&Object.defineProperty(target,propertyKey,{writable:!0,value:void 0})}return DecoratorFactory}function Currency(){function DecoratorFactory(target,propertyKey){function ngOnInit(){var _this=this,locale=InjectorRef.get(LocaleService);void 0!==propertyKey&&(this[propertyKey]=locale.getCurrentCurrency(),subscription=locale.currencyCodeChanged.subscribe(function(currency){_this[propertyKey]=currency})),targetNgOnInit&&targetNgOnInit.apply(this)}function ngOnDestroy(){void 0!==subscription&&subscription.unsubscribe(),targetNgOnDestroy&&targetNgOnDestroy.apply(this)}var subscription,targetNgOnInit=target.ngOnInit;target.ngOnInit=ngOnInit;var targetNgOnDestroy=target.ngOnDestroy;target.ngOnDestroy=ngOnDestroy,void 0!==propertyKey&&Object.defineProperty(target,propertyKey,{writable:!0,value:void 0})}return DecoratorFactory}function validateLocaleNumber(digits,MIN_VALUE,MAX_VALUE){void 0===MIN_VALUE&&(MIN_VALUE=Number.MIN_VALUE),void 0===MAX_VALUE&&(MAX_VALUE=Number.MAX_VALUE);var defaultLocale,NUMBER_REGEXP,locale=InjectorRef.get(LocaleService),decimalCode=InjectorRef.get(DecimalCode);return function(formControl){if(null==formControl.value||""==formControl.value)return null;if(defaultLocale!=locale.getDefaultLocale()&&(NUMBER_REGEXP=decimalCode.getRegExp(digits),defaultLocale=locale.getDefaultLocale()),NUMBER_REGEXP.test(formControl.value)){var parsedValue=decimalCode.parse(formControl.value);return null!=parsedValue&&parsedValue<MIN_VALUE?{minValue:{valid:!1}}:null!=parsedValue&&parsedValue>MAX_VALUE?{maxValue:{valid:!1}}:null}return{format:{valid:!1}}}}var __extends=function(){var extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b}||function(d,b){for(var p in b)b.hasOwnProperty(p)&&(d[p]=b[p])};return function(d,b){function __(){this.constructor=d}extendStatics(d,b),d.prototype=null===b?Object.create(b):(__.prototype=b.prototype,new __)}}(),__generator=function(thisArg,body){function verb(n){return function(v){return step([n,v])}}function step(op){if(f)throw new TypeError("Generator is already executing.");for(;_;)try{if(f=1,y&&(t=y[2&op[0]?"return":op[0]?"throw":"next"])&&!(t=t.call(y,op[1])).done)return t;switch(y=0,t&&(op=[0,t.value]),op[0]){case 0:case 1:t=op;break;case 4:return _.label++,{value:op[1],done:!1};case 5:_.label++,y=op[1],op=[0];continue;case 7:op=_.ops.pop(),_.trys.pop();continue;default:if(t=_.trys,!(t=t.length>0&&t[t.length-1])&&(6===op[0]||2===op[0])){_=0;continue}if(3===op[0]&&(!t||op[1]>t[0]&&op[1]<t[3])){_.label=op[1];break}if(6===op[0]&&_.label<t[1]){_.label=t[1],t=op;break}if(t&&_.label<t[2]){_.label=t[2],_.ops.push(op);break}t[2]&&_.ops.pop(),_.trys.pop();continue}op=body.call(thisArg,_)}catch(e){op=[6,e],y=0}finally{f=t=0}if(5&op[0])throw op[1];return{value:op[0]?op[1]:void 0,done:!0}}var f,y,t,g,_={label:0,sent:function(){if(1&t[0])throw t[1];return t[1]},trys:[],ops:[]};return g={next:verb(0),throw:verb(1),return:verb(2)},"function"==typeof Symbol&&(g[Symbol.iterator]=function(){return this}),g},InjectorRef=function(){function InjectorRef(injector){this.injector=injector,InjectorRef.injector=this.injector}return InjectorRef.get=function(token){return this.injector.get(token)},InjectorRef}();InjectorRef.decorators=[{type:_angular_core.Injectable}],InjectorRef.ctorParameters=function(){return[{type:_angular_core.Injector}]};var LocaleConfig=function(){function LocaleConfig(){this.languageCodes=[],this.storageIsDisabled=!1,this.localStorage=!1,this.sessionStorage=!1}return LocaleConfig}();LocaleConfig.decorators=[{type:_angular_core.Injectable}],LocaleConfig.ctorParameters=function(){return[]};var LocaleConfigAPI=function(){function LocaleConfigAPI(configuration){this.configuration=configuration}return LocaleConfigAPI.prototype.addLanguage=function(languageCode,textDirection){return void 0===textDirection&&(textDirection="LTR"),this.configuration.languageCodes.push({code:languageCode,direction:textDirection}),this},LocaleConfigAPI.prototype.addLanguages=function(languageCodes){for(var _i=0,languageCodes_1=languageCodes;_i<languageCodes_1.length;_i++){var languageCode=languageCodes_1[_i];this.configuration.languageCodes.push({code:languageCode,direction:"ltr"})}return this},LocaleConfigAPI.prototype.disableStorage=function(){return this.configuration.storageIsDisabled=!0,this},LocaleConfigAPI.prototype.setCookieExpiration=function(days){return this.configuration.cookiesExpirationDays=days,this},LocaleConfigAPI.prototype.useLocalStorage=function(){return this.configuration.localStorage=!0,this},LocaleConfigAPI.prototype.useSessionStorage=function(){return this.configuration.sessionStorage=!0,this},LocaleConfigAPI.prototype.defineLanguage=function(languageCode){return this.configuration.languageCode=languageCode,this},LocaleConfigAPI.prototype.defineDefaultLocale=function(languageCode,countryCode,scriptCode,numberingSystem,calendar){return this.configuration.languageCode=languageCode,this.configuration.countryCode=countryCode,this.configuration.scriptCode=scriptCode,this.configuration.numberingSystem=numberingSystem,this.configuration.calendar=calendar,this},LocaleConfigAPI.prototype.defineCurrency=function(currencyCode){return this.configuration.currencyCode=currencyCode,this},LocaleConfigAPI}(),__awaiter$1=function(thisArg,_arguments,P,generator){return new(P||(P=Promise))(function(resolve,reject){function fulfilled(value){try{step(generator.next(value))}catch(e){reject(e)}}function rejected(value){try{step(generator.throw(value))}catch(e){reject(e)}}function step(result){result.done?resolve(result.value):new P(function(resolve){resolve(result.value)}).then(fulfilled,rejected)}step((generator=generator.apply(thisArg,_arguments||[])).next())})},LocaleStorage=function(){function LocaleStorage(){}return LocaleStorage.prototype.read=function(name){},LocaleStorage.prototype.write=function(name,value){},LocaleStorage}();LocaleStorage.decorators=[{type:_angular_core.Injectable}],LocaleStorage.ctorParameters=function(){return[]};var BrowserStorage=function(){function BrowserStorage(configuration){this.configuration=configuration,this.hasCookie="undefined"!=typeof navigator&&navigator.cookieEnabled,this.hasStorage="undefined"!=typeof Storage}return BrowserStorage.prototype.read=function(name){return __awaiter$1(this,void 0,void 0,function(){var value;return __generator(this,function(_a){return value=null,this.configuration.storageIsDisabled||(this.configuration.localStorage&&this.hasStorage?value=this.getLocalStorage(name):this.configuration.sessionStorage&&this.hasStorage?value=this.getSessionStorage(name):this.hasCookie&&(value=this.getCookie(name))),[2,value]})})},BrowserStorage.prototype.write=function(name,value){return __awaiter$1(this,void 0,void 0,function(){return __generator(this,function(_a){return this.configuration.storageIsDisabled||(this.configuration.localStorage&&this.hasStorage?this.setLocalStorage(name,value):this.configuration.sessionStorage&&this.hasStorage?this.setSessionStorage(name,value):this.hasCookie&&this.setCookie(name,value)),[2]})})},BrowserStorage.prototype.getLocalStorage=function(name){return localStorage.getItem(name)},BrowserStorage.prototype.getSessionStorage=function(name){return sessionStorage.getItem(name)},BrowserStorage.prototype.getCookie=function(name){var result=null;return"undefined"!=typeof document&&(result=new RegExp("(?:^|; )"+encodeURIComponent(name)+"=([^;]*)").exec(document.cookie)),result?result[1]:null},BrowserStorage.prototype.setLocalStorage=function(name,value){localStorage.setItem(name,value)},BrowserStorage.prototype.setSessionStorage=function(name,value){sessionStorage.setItem(name,value)},BrowserStorage.prototype.setCookie=function(name,value){var expires="";if(null!=this.configuration.cookiesExpirationDays){var expirationDate=new Date;expirationDate.setTime(expirationDate.getTime()+24*this.configuration.cookiesExpirationDays*60*60*1e3),expires="; expires="+expirationDate.toUTCString()}"undefined"!=typeof document&&(document.cookie=name+"="+value+expires+"; path=/")},BrowserStorage}();BrowserStorage.decorators=[{type:_angular_core.Injectable}],BrowserStorage.ctorParameters=function(){return[{type:LocaleConfig}]};var DefaultLocale=function(){function DefaultLocale(){}return Object.defineProperty(DefaultLocale.prototype,"value",{get:function(){return this._value},set:function(defaultLocale){this._value=defaultLocale,this.parseValue()},enumerable:!0,configurable:!0}),DefaultLocale.prototype.build=function(languageCode,countryCode,scriptCode,numberingSystem,calendar){this.languageCode=languageCode,this.scriptCode=scriptCode,this.countryCode=countryCode,this.numberingSystem=numberingSystem,this.calendar=calendar;var value=[];value.push(languageCode),value.push(scriptCode?"-"+scriptCode:""),value.push(countryCode?"-"+countryCode:""),value.push(numberingSystem||calendar?"-u":""),value.push(numberingSystem?"-nu-"+numberingSystem:""),value.push(calendar?"-ca-"+calendar:""),this._value=value.join("")},DefaultLocale.prototype.parseValue=function(){if(this.value){var value=this.value,index=value.search("-u");if(-1!=index){var extensions=value.substring(index+1).split("-");switch(extensions.length){case 3:"nu"==extensions[1]?this.numberingSystem=extensions[2]:"ca"==extensions[1]&&(this.calendar=extensions[2]);break;default:this.numberingSystem=extensions[2],this.calendar=extensions[4]}value=value.substring(0,index)}var codes=value.split("-");switch(codes.length){case 1:this.languageCode=codes[0];break;case 2:this.languageCode=codes[0],this.countryCode=codes[1];break;default:this.languageCode=codes[0],this.scriptCode=codes[1],this.countryCode=codes[2]}}},DefaultLocale}(),__awaiter=function(thisArg,_arguments,P,generator){return new(P||(P=Promise))(function(resolve,reject){function fulfilled(value){try{step(generator.next(value))}catch(e){reject(e)}}function rejected(value){try{step(generator.throw(value))}catch(e){reject(e)}}function step(result){result.done?resolve(result.value):new P(function(resolve){resolve(result.value)}).then(fulfilled,rejected)}step((generator=generator.apply(thisArg,_arguments||[])).next())})},LocaleService=function(){function LocaleService(configuration,storage){this.configuration=configuration,this.storage=storage,this.languageCodeChanged=new _angular_core.EventEmitter(!0),this.defaultLocaleChanged=new _angular_core.EventEmitter(!0),this.currencyCodeChanged=new _angular_core.EventEmitter(!0),this.loadTranslation=new rxjs_Subject.Subject,this.defaultLocale=new DefaultLocale}return LocaleService.prototype.addConfiguration=function(){return new LocaleConfigAPI(this.configuration)},LocaleService.prototype.getConfiguration=function(){return this.configuration},LocaleService.prototype.init=function(){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(_a){switch(_a.label){case 0:return[4,this.initStorage()];case 1:return _a.sent(),this.configuration.languageCode&&this.configuration.countryCode?this.initDefaultLocale():this.configuration.languageCode&&this.initLanguage(),this.configuration.currencyCode&&this.initCurrency(),[2]}})})},LocaleService.prototype.getAvailableLanguages=function(){return this.configuration.languageCodes.map(function(language){return language.code})},LocaleService.prototype.getLanguageDirection=function(languageCode){return void 0===languageCode&&(languageCode=this.defaultLocale.languageCode),this.matchLanguage(languageCode)[0].direction},LocaleService.prototype.getCurrentLanguage=function(){return this.defaultLocale.languageCode},LocaleService.prototype.getCurrentCountry=function(){return this.defaultLocale.countryCode?this.defaultLocale.countryCode:""},LocaleService.prototype.getCurrentScript=function(){return this.defaultLocale.scriptCode?this.defaultLocale.scriptCode:""},LocaleService.prototype.getCurrentLocale=function(){return this.defaultLocale.countryCode?this.defaultLocale.languageCode+"-"+this.defaultLocale.countryCode:this.defaultLocale.languageCode},LocaleService.prototype.getCurrentNumberingSystem=function(){return this.defaultLocale.numberingSystem?this.defaultLocale.numberingSystem:""},LocaleService.prototype.getCurrentCalendar=function(){return this.defaultLocale.calendar?this.defaultLocale.calendar:""},LocaleService.prototype.getDefaultLocale=function(){return this.defaultLocale.value},LocaleService.prototype.getCurrentCurrency=function(){return this.currencyCode},LocaleService.prototype.setCurrentLanguage=function(languageCode){this.defaultLocale.languageCode!=languageCode&&(this.defaultLocale.build(languageCode),this.storage.write("defaultLocale",this.defaultLocale.value),this.sendLanguageEvents(),this.sendTranslationEvents())},LocaleService.prototype.setDefaultLocale=function(languageCode,countryCode,scriptCode,numberingSystem,calendar){this.defaultLocale.languageCode==languageCode&&this.defaultLocale.countryCode==countryCode&&this.defaultLocale.scriptCode==scriptCode&&this.defaultLocale.numberingSystem==numberingSystem&&this.defaultLocale.calendar==calendar||(this.defaultLocale.build(languageCode,countryCode,scriptCode,numberingSystem,calendar),this.storage.write("defaultLocale",this.defaultLocale.value),this.sendDefaultLocaleEvents(),this.sendTranslationEvents())},LocaleService.prototype.setCurrentCurrency=function(currencyCode){this.currencyCode!=currencyCode&&(this.currencyCode=currencyCode,this.storage.write("currency",this.currencyCode),this.sendCurrencyEvents())},LocaleService.prototype.initStorage=function(){return __awaiter(this,void 0,void 0,function(){var defaultLocale,currencyCode;return __generator(this,function(_a){switch(_a.label){case 0:return this.defaultLocale.value?[3,2]:[4,this.storage.read("defaultLocale")];case 1:defaultLocale=_a.sent(),defaultLocale&&(this.defaultLocale.value=defaultLocale),_a.label=2;case 2:return null!=this.currencyCode?[3,4]:[4,this.storage.read("currency")];case 3:currencyCode=_a.sent(),currencyCode&&(this.currencyCode=currencyCode),_a.label=4;case 4:return[2]}})})},LocaleService.prototype.initLanguage=function(){if(!this.defaultLocale.languageCode){var browserLanguage=this.getBrowserLanguage(),matchedLanguages=[];browserLanguage&&(matchedLanguages=this.matchLanguage(browserLanguage)),browserLanguage&&matchedLanguages.length>0?this.defaultLocale.build(browserLanguage):this.defaultLocale.build(this.configuration.languageCode),this.storage.write("defaultLocale",this.defaultLocale.value)}this.sendLanguageEvents()},LocaleService.prototype.initDefaultLocale=function(){this.defaultLocale.value||(this.defaultLocale.build(this.configuration.languageCode,this.configuration.countryCode,this.configuration.scriptCode,this.configuration.numberingSystem,this.configuration.calendar),this.storage.write("defaultLocale",this.defaultLocale.value)),this.sendDefaultLocaleEvents()},LocaleService.prototype.initCurrency=function(){null==this.currencyCode&&(this.currencyCode=this.configuration.currencyCode,this.storage.write("currency",this.currencyCode)),this.sendCurrencyEvents()},LocaleService.prototype.getBrowserLanguage=function(){var browserLanguage=null;if("undefined"!=typeof navigator&&navigator.language&&(browserLanguage=navigator.language),null!=browserLanguage){var index=browserLanguage.indexOf("-");-1!=index&&(browserLanguage=browserLanguage.substring(0,index))}return browserLanguage},LocaleService.prototype.matchLanguage=function(languageCode){return this.configuration.languageCodes.filter(function(language){return language.code==languageCode})},LocaleService.prototype.sendLanguageEvents=function(){this.languageCodeChanged.emit(this.defaultLocale.languageCode)},LocaleService.prototype.sendDefaultLocaleEvents=function(){this.defaultLocaleChanged.emit(this.defaultLocale.value)},LocaleService.prototype.sendCurrencyEvents=function(){this.currencyCodeChanged.emit(this.currencyCode)},LocaleService.prototype.sendTranslationEvents=function(){this.loadTranslation.next()},LocaleService}();LocaleService.decorators=[{type:_angular_core.Injectable}],LocaleService.ctorParameters=function(){return[{type:LocaleConfig},{type:LocaleStorage}]},LocaleService.propDecorators={languageCodeChanged:[{type:_angular_core.Output}],defaultLocaleChanged:[{type:_angular_core.Output}],currencyCodeChanged:[{type:_angular_core.Output}]};var TranslationConfig=function(){function TranslationConfig(){this.translationData={},this.providers=[],this.localeAsLanguage=!1,this.keySeparator=".",this.i18nPlural=!0}return TranslationConfig}();TranslationConfig.decorators=[{type:_angular_core.Injectable}],TranslationConfig.ctorParameters=function(){return[]};var IntlAPI=function(){function IntlAPI(){}return IntlAPI.hasDateTimeFormat=function(){return this.hasIntl&&Intl.hasOwnProperty("DateTimeFormat")},IntlAPI.hasNumberFormat=function(){return this.hasIntl&&Intl.hasOwnProperty("NumberFormat")},IntlAPI.hasCollator=function(){return this.hasIntl&&Intl.hasOwnProperty("Collator")},IntlAPI}();IntlAPI.hasIntl=Intl&&"object"==typeof Intl;var TranslationConfigAPI=function(){function TranslationConfigAPI(configuration){this.configuration=configuration}return TranslationConfigAPI.prototype.addTranslation=function(languageCode,translation){return this.configuration.translationData[languageCode]=void 0!==this.configuration.translationData[languageCode]?Object.assign({},this.configuration.translationData[languageCode],translation):translation,this},TranslationConfigAPI.prototype.addProvider=function(prefix,dataFormat){return void 0===dataFormat&&(dataFormat="json"),this.configuration.providers.push({args:{type:"Static",prefix:prefix,dataFormat:dataFormat}}),this},TranslationConfigAPI.prototype.addWebAPIProvider=function(path,dataFormat){return void 0===dataFormat&&(dataFormat="json"),this.configuration.providers.push({args:{type:"WebAPI",path:path,dataFormat:dataFormat}}),this},TranslationConfigAPI.prototype.addCustomProvider=function(args){return this.configuration.providers.push({args:args}),this},TranslationConfigAPI.prototype.useLocaleAsLanguage=function(){return this.configuration.localeAsLanguage=!0,this},TranslationConfigAPI.prototype.setMissingValue=function(value){return this.configuration.missingValue=value,this},TranslationConfigAPI.prototype.setMissingKey=function(key){return this.configuration.missingKey=key,this},TranslationConfigAPI.prototype.setComposedKeySeparator=function(keySeparator){return this.configuration.keySeparator=keySeparator,this},TranslationConfigAPI.prototype.disableI18nPlural=function(){return this.configuration.i18nPlural=!1,this},TranslationConfigAPI}(),TranslationProvider=function(){function TranslationProvider(){}return TranslationProvider.prototype.getTranslation=function(language,args){},TranslationProvider}();TranslationProvider.decorators=[{type:_angular_core.Injectable}],TranslationProvider.ctorParameters=function(){return[]};var HttpTranslationProvider=function(){function HttpTranslationProvider(http){this.http=http}return HttpTranslationProvider.prototype.getTranslation=function(language,args){var url="";switch(args.type){case"WebAPI":url+=args.path+language;break;default:url+=args.prefix+language+"."+args.dataFormat}return this.http.get(url).map(function(res){return res.json()})},HttpTranslationProvider}();HttpTranslationProvider.decorators=[{type:_angular_core.Injectable}],HttpTranslationProvider.ctorParameters=function(){return[{type:_angular_http.Http}]};var TranslationHandler=function(){function TranslationHandler(){}return TranslationHandler.prototype.parseValue=function(path,key,value,args,lang){},TranslationHandler}();TranslationHandler.decorators=[{type:_angular_core.Injectable}],TranslationHandler.ctorParameters=function(){return[]};var DefaultTranslationHandler=function(){function DefaultTranslationHandler(configuration){this.configuration=configuration}return DefaultTranslationHandler.prototype.parseValue=function(path,key,value,args,lang){return null==value?this.handleMissingValue(path):args?this.handleArgs(value,args):value},DefaultTranslationHandler.prototype.handleMissingValue=function(path){return null!=this.configuration.missingValue?this.configuration.missingValue:path},DefaultTranslationHandler.prototype.handleArgs=function(value,args){var TEMPLATE_REGEXP=/{{\s?([^{}\s]*)\s?}}/g;return value.replace(TEMPLATE_REGEXP,function(substring,parsedKey){var replacer=args[parsedKey];return void 0!==replacer?replacer:substring})},DefaultTranslationHandler}();DefaultTranslationHandler.decorators=[{type:_angular_core.Injectable}],DefaultTranslationHandler.ctorParameters=function(){return[{type:TranslationConfig}]};var LoadingMode={};LoadingMode.Direct=0,LoadingMode.Async=1,LoadingMode[LoadingMode.Direct]="Direct",LoadingMode[LoadingMode.Async]="Async";var ServiceState={};ServiceState.isReady=0,ServiceState.isLoading=1,ServiceState.isWaiting=2,ServiceState[ServiceState.isReady]="isReady",ServiceState[ServiceState.isLoading]="isLoading",ServiceState[ServiceState.isWaiting]="isWaiting";var __awaiter$2=function(thisArg,_arguments,P,generator){return new(P||(P=Promise))(function(resolve,reject){function fulfilled(value){try{step(generator.next(value))}catch(e){reject(e)}}function rejected(value){try{step(generator.throw(value))}catch(e){reject(e)}}function step(result){result.done?resolve(result.value):new P(function(resolve){resolve(result.value)}).then(fulfilled,rejected)}step((generator=generator.apply(thisArg,_arguments||[])).next())})},TranslationService=function(){function TranslationService(locale,configuration,translationProvider,translationHandler){this.locale=locale,this.configuration=configuration,this.translationProvider=translationProvider,this.translationHandler=translationHandler,this.translationChanged=new _angular_core.EventEmitter(!0),this.translationError=new _angular_core.EventEmitter(!0),this.translationData={},this.serviceState=ServiceState.isWaiting}return TranslationService.prototype.addConfiguration=function(){return new TranslationConfigAPI(this.configuration)},TranslationService.prototype.getConfiguration=function(){return this.configuration},TranslationService.prototype.init=function(){return __awaiter$2(this,void 0,void 0,function(){var _this=this;return __generator(this,function(_a){switch(_a.label){case 0:return[4,this.locale.init()];case 1:return _a.sent(),this.configuration.providers.length>0?this.loadingMode=LoadingMode.Async:this.loadingMode=LoadingMode.Direct,this.locale.loadTranslation.subscribe(function(){_this.loadTranslation()}),[4,this.loadTranslation()];case 2:return _a.sent(),[2]}})})},TranslationService.prototype.getLanguage=function(){return this.language},TranslationService.prototype.translate=function(keys,args,lang){if(void 0===args&&(args=null),void 0===lang&&(lang=this.language),this.serviceState!=ServiceState.isReady)return keys;if(Array.isArray(keys)){for(var data={},_i=0,keys_1=keys;_i<keys_1.length;_i++){var key=keys_1[_i];data[key]=this.translateKey(key,args,lang)}return data}return this.translateKey(keys,args,lang)},TranslationService.prototype.translateAsync=function(keys,args,lang){var _this=this;return void 0===lang&&(lang=this.language),rxjs_Observable.Observable.create(function(observer){var values=_this.translate(keys,args,lang);observer.next(values),observer.complete()})},TranslationService.prototype.translateKey=function(key,args,lang){return null==key||""==key?null:this.configuration.i18nPlural&&/^\d+\b/.exec(key)?this.translateI18nPlural(key,args,lang):this.getValue(key,args,lang)},TranslationService.prototype.getValue=function(key,args,lang){var path=key,value=null;if(this.translationData[lang]){var translation=this.translationData[lang],sequences=key.split(this.configuration.keySeparator);do{key=sequences.shift(),translation[key]&&"object"==typeof translation[key]&&(translation=translation[key])}while(sequences.length>0);value=translation[key]||translation[this.configuration.missingKey]}return this.translationHandler.parseValue(path,key,value,args,lang)},TranslationService.prototype.translateI18nPlural=function(key,args,lang){var keyText=key.replace(/^\d+\b/,"");keyText=keyText.trim();var keyNumber=parseFloat(key);return key=key.replace(/^\d+/,this.translateNumber(keyNumber)),key.replace(keyText,this.getValue(keyText,args,lang))},TranslationService.prototype.translateNumber=function(keyNumber){if(!isNaN(keyNumber)&&IntlAPI.hasNumberFormat()){return new Intl.NumberFormat(this.language).format(keyNumber)}return keyNumber.toString()},TranslationService.prototype.loadTranslation=function(){return __awaiter$2(this,void 0,void 0,function(){var language;return __generator(this,function(_a){switch(_a.label){case 0:return language=this.configuration.localeAsLanguage?this.locale.getCurrentLocale():this.locale.getCurrentLanguage(),null==language||language==this.language?[3,3]:this.loadingMode!=LoadingMode.Async?[3,2]:[4,this.getTranslation(language).toPromise()];case 1:return _a.sent(),[3,3];case 2:this.translationData={},this.translationData[language]=this.configuration.translationData[language],this.releaseTranslation(language),_a.label=3;case 3:return[2]}})})},TranslationService.prototype.getTranslation=function(language){var _this=this;return rxjs_Observable.Observable.create(function(observer){_this.translationData={},_this.serviceState=ServiceState.isLoading;for(var sequencesOfTranslationData=[],_i=0,_a=_this.configuration.providers;_i<_a.length;_i++){var provider=_a[_i];sequencesOfTranslationData.push(_this.translationProvider.getTranslation(language,provider.args))}rxjs_Observable.Observable.merge.apply(rxjs_Observable.Observable,sequencesOfTranslationData).subscribe(function(data){_this.addData(data,language)},function(error){_this.translationError.emit(error),_this.releaseTranslation(language),observer.next(null),observer.complete()},function(){_this.releaseTranslation(language),observer.next(null),observer.complete()})})},TranslationService.prototype.addData=function(data,language){this.translationData[language]=void 0!==this.translationData[language]?Object.assign({},this.translationData[language],data):data},TranslationService.prototype.releaseTranslation=function(language){this.serviceState=ServiceState.isReady,this.language=language,this.sendEvents()},TranslationService.prototype.sendEvents=function(){this.translationChanged.emit(this.language)},TranslationService}();TranslationService.decorators=[{type:_angular_core.Injectable}],TranslationService.ctorParameters=function(){return[{type:LocaleService},{type:TranslationConfig},{type:TranslationProvider},{type:TranslationHandler}]},TranslationService.propDecorators={translationChanged:[{type:_angular_core.Output}],translationError:[{type:_angular_core.Output}]};var Translation=function(){function Translation(translation,changeDetectorRef){void 0===translation&&(translation=InjectorRef.get(TranslationService));var _this=this;this.translation=translation,this.changeDetectorRef=changeDetectorRef,this.paramSubscriptions=[],this.lang=this.translation.getLanguage(),this.paramSubscriptions.push(this.translation.translationChanged.subscribe(function(language){_this.lang=language,_this.changeDetectorRef&&_this.changeDetectorRef.markForCheck()}))}return Translation.prototype.cancelParamSubscriptions=function(){this.paramSubscriptions.forEach(function(subscription){void 0!==subscription&&subscription.unsubscribe()})},Translation}();Translation.decorators=[{type:_angular_core.Injectable}],Translation.ctorParameters=function(){return[{type:TranslationService},{type:_angular_core.ChangeDetectorRef}]};var Localization=function(_super){function Localization(locale,translation,changeDetectorRef){void 0===locale&&(locale=InjectorRef.get(LocaleService)),void 0===translation&&(translation=InjectorRef.get(TranslationService));var _this=_super.call(this,translation,changeDetectorRef)||this;return _this.locale=locale,_this.translation=translation,_this.changeDetectorRef=changeDetectorRef,_this.defaultLocale=_this.locale.getDefaultLocale(),_this.paramSubscriptions.push(_this.locale.defaultLocaleChanged.subscribe(function(defaultLocale){_this.defaultLocale=defaultLocale,_this.changeDetectorRef&&_this.changeDetectorRef.markForCheck()})),_this.currency=_this.locale.getCurrentCurrency(),_this.paramSubscriptions.push(_this.locale.currencyCodeChanged.subscribe(function(currency){_this.currency=currency,_this.changeDetectorRef&&_this.changeDetectorRef.markForCheck()})),_this}return __extends(Localization,_super),Localization}(Translation);Localization.decorators=[{type:_angular_core.Injectable}],Localization.ctorParameters=function(){return[{type:LocaleService},{type:TranslationService},{type:_angular_core.ChangeDetectorRef}]};var NumberCode=function(){function NumberCode(locale){this.locale=locale}return Object.defineProperty(NumberCode.prototype,"numberCodes",{get:function(){for(var numberCodes=[],num=0;num<=9;num++)numberCodes.push(this.toUnicode(num.toString()));if(IntlAPI.hasNumberFormat())for(var num=0;num<=9;num++)numberCodes[num]=this.toUnicode(new Intl.NumberFormat(this.locale.getDefaultLocale()).format(num));return numberCodes},enumerable:!0,configurable:!0}),NumberCode.prototype.parse=function(s){},NumberCode.prototype.getRegExp=function(digits){},NumberCode.prototype.toChar=function(pattern){return pattern.replace(/\\u[\dA-F]{4}/gi,function(match){return String.fromCharCode(parseInt(match.replace(/\\u/g,""),16))})},NumberCode.prototype.toUnicode=function(c){return"\\u"+this.toHex(c.charCodeAt(0))},NumberCode.prototype.toHex=function(value){var hex=value.toString(16).toUpperCase();return hex="0000".substr(0,4-hex.length)+hex},NumberCode}();NumberCode.decorators=[{type:_angular_core.Injectable}], | ||
NumberCode.ctorParameters=function(){return[{type:LocaleService}]};var DecimalCode=function(_super){function DecimalCode(locale){var _this=_super.call(this,locale)||this;return _this.locale=locale,_this}return __extends(DecimalCode,_super),Object.defineProperty(DecimalCode.prototype,"decimalCodes",{get:function(){var decimalCodes={minusSign:this.toUnicode("-"),decimalSeparator:this.toUnicode(".")};if(IntlAPI.hasNumberFormat()){var localeValue=new Intl.NumberFormat(this.locale.getDefaultLocale()).format(-.9),unicodeChars=[];unicodeChars.push(this.toUnicode(localeValue.charAt(0))),unicodeChars.push(this.toUnicode(localeValue.charAt(1))),unicodeChars.push(this.toUnicode(localeValue.charAt(2))),unicodeChars.push(this.toUnicode(localeValue.charAt(3))),decimalCodes="\\u200F"==unicodeChars[0]||"\\u061C"==unicodeChars[0]?{minusSign:unicodeChars[1],decimalSeparator:unicodeChars[3]}:unicodeChars[0]==this.toUnicode(new Intl.NumberFormat(this.locale.getDefaultLocale()).format(0))?{minusSign:unicodeChars[3],decimalSeparator:unicodeChars[1]}:"\\u200E"==unicodeChars[0]?{minusSign:unicodeChars[1],decimalSeparator:unicodeChars[3]}:{minusSign:unicodeChars[0],decimalSeparator:unicodeChars[2]}}return decimalCodes},enumerable:!0,configurable:!0}),DecimalCode.prototype.parse=function(s){for(var value="",decimalCodes=this.decimalCodes,characters=s.split(""),_i=0,characters_1=characters;_i<characters_1.length;_i++){var char=characters_1[_i],charCode=this.toUnicode(char),index=this.numberCodes.indexOf(charCode);if(-1!=index)value+=index;else if(charCode==decimalCodes.minusSign)value+="-";else{if(charCode!=decimalCodes.decimalSeparator)return NaN;value+="."}}return parseFloat(value)},DecimalCode.prototype.getRegExp=function(digits){var minInt=1,minFraction=0,maxFraction=3;if(digits){var NUMBER_FORMAT_REGEXP=/^(\d+)?\.((\d+)(\-(\d+))?)?$/,parts=digits.match(NUMBER_FORMAT_REGEXP);null!=parts&&(null!=parts[1]&&(minInt=parseInt(parts[1])),null!=parts[3]&&(minFraction=parseInt(parts[3])),null!=parts[5]&&(maxFraction=parseInt(parts[5])))}var pattern,minusSign=this.decimalCodes.minusSign,zero=this.numberCodes[0],decimalSeparator=this.decimalCodes.decimalSeparator,nine=this.numberCodes[9];return pattern=minFraction>0&&maxFraction>0?"^"+minusSign+"?["+zero+"-"+nine+"]{"+minInt+",}\\"+decimalSeparator+"["+zero+"-"+nine+"]{"+minFraction+","+maxFraction+"}$":0==minFraction&&maxFraction>0?"^"+minusSign+"?["+zero+"-"+nine+"]{"+minInt+",}\\"+decimalSeparator+"?["+zero+"-"+nine+"]{"+minFraction+","+maxFraction+"}$":"^"+minusSign+"?["+zero+"-"+nine+"]{"+minInt+",}$",pattern=this.toChar(pattern),new RegExp(pattern)},DecimalCode}(NumberCode);DecimalCode.decorators=[{type:_angular_core.Injectable}],DecimalCode.ctorParameters=function(){return[{type:LocaleService}]};var LocaleValidation=function(){function LocaleValidation(decimalCode){this.decimalCode=decimalCode}return LocaleValidation.prototype.parseNumber=function(s){return""==s?null:this.decimalCode.parse(s)},LocaleValidation}();LocaleValidation.decorators=[{type:_angular_core.Injectable}],LocaleValidation.ctorParameters=function(){return[{type:DecimalCode}]};var Collator=function(){function Collator(locale,translation){this.locale=locale,this.translation=translation}return Collator.prototype.compare=function(key1,key2,extension,options){if(void 0===options&&(options={usage:"sort",sensitivity:"variant"}),!IntlAPI.hasCollator())return 0;var value1=this.translation.translate(key1),value2=this.translation.translate(key2),locale=this.addExtension(this.locale.getCurrentLocale(),extension);return new Intl.Collator(locale,options).compare(value1,value2)},Collator.prototype.sort=function(list,keyName,order,extension,options){var _this=this;return void 0===order&&(order="asc"),void 0===options&&(options={usage:"sort",sensitivity:"variant"}),list&&keyName&&IntlAPI.hasCollator()?(list.sort(function(key1,key2){return _this.compare(key1[keyName],key2[keyName],extension,options)}),"desc"==order&&list.reverse(),list):list},Collator.prototype.sortAsync=function(list,keyName,order,extension,options){var _this=this;return void 0===options&&(options={usage:"sort",sensitivity:"variant"}),rxjs_Observable.Observable.create(function(observer){observer.next(_this.sort(list,keyName,order,extension,options)),observer.complete()})},Collator.prototype.search=function(s,list,keyNames,options){var _this=this;if(void 0===options&&(options={usage:"search"}),!list||!keyNames||""==s||null==s||!IntlAPI.hasCollator())return list;var locale=this.locale.getCurrentLocale(),collator=new Intl.Collator(locale,options);return list.filter(function(key){for(var found=!1,i=0;i<keyNames.length;i++)if(_this.match(key[keyNames[i]],s,collator)){found=!0;break}return found})},Collator.prototype.searchAsync=function(s,list,keyNames,options){var _this=this;return void 0===options&&(options={usage:"search"}),rxjs_Observable.Observable.create(function(observer){observer.next(_this.search(s,list,keyNames,options)),observer.complete()})},Collator.prototype.addExtension=function(locale,extension){return extension&&(locale=locale+"-u-"+extension),locale},Collator.prototype.match=function(key,s,collator){var value=this.translation.translate(key),valueLength=value.length,sLength=s.length;if(sLength>valueLength)return!1;if(sLength==valueLength)return 0==collator.compare(value,s);for(var found=!1,i=0;i<valueLength-(sLength-1);i++){var str=value.substr(i,sLength);if(0==collator.compare(str,s)){found=!0;break}}return found},Collator}();Collator.decorators=[{type:_angular_core.Injectable}],Collator.ctorParameters=function(){return[{type:LocaleService},{type:TranslationService}]};var TranslatePipe=function(){function TranslatePipe(translation){this.translation=translation}return TranslatePipe.prototype.transform=function(key,lang,args){return this.translation.translate(key,args,lang)},TranslatePipe}();TranslatePipe.decorators=[{type:_angular_core.Pipe,args:[{name:"translate",pure:!0}]}],TranslatePipe.ctorParameters=function(){return[{type:TranslationService}]};var LocaleDatePipe=function(){function LocaleDatePipe(){}return LocaleDatePipe.prototype.transform=function(value,defaultLocale,pattern){if(void 0===pattern&&(pattern="mediumDate"),void 0===defaultLocale)return null;if(IntlAPI.hasDateTimeFormat()){return new _angular_common.DatePipe(defaultLocale).transform(value,pattern)}return value},LocaleDatePipe}();LocaleDatePipe.decorators=[{type:_angular_core.Pipe,args:[{name:"localeDate",pure:!0}]}],LocaleDatePipe.ctorParameters=function(){return[]};var LocaleDecimalPipe=function(){function LocaleDecimalPipe(){}return LocaleDecimalPipe.prototype.transform=function(value,defaultLocale,digits){if(void 0===defaultLocale)return null;if(IntlAPI.hasNumberFormat()){return new _angular_common.DecimalPipe(defaultLocale).transform(value,digits)}return value},LocaleDecimalPipe}();LocaleDecimalPipe.decorators=[{type:_angular_core.Pipe,args:[{name:"localeDecimal",pure:!0}]}],LocaleDecimalPipe.ctorParameters=function(){return[]};var LocalePercentPipe=function(){function LocalePercentPipe(){}return LocalePercentPipe.prototype.transform=function(value,defaultLocale,digits){if(void 0===defaultLocale)return null;if(IntlAPI.hasNumberFormat()){return new _angular_common.PercentPipe(defaultLocale).transform(value,digits)}return value},LocalePercentPipe}();LocalePercentPipe.decorators=[{type:_angular_core.Pipe,args:[{name:"localePercent",pure:!0}]}],LocalePercentPipe.ctorParameters=function(){return[]};var LocaleCurrencyPipe=function(){function LocaleCurrencyPipe(){}return LocaleCurrencyPipe.prototype.transform=function(value,defaultLocale,currency,symbolDisplay,digits){if(void 0===symbolDisplay&&(symbolDisplay=!1),void 0===defaultLocale||void 0===currency)return null;if(IntlAPI.hasNumberFormat()){return new _angular_common.CurrencyPipe(defaultLocale).transform(value,currency,symbolDisplay,digits)}return value+" "+currency},LocaleCurrencyPipe}();LocaleCurrencyPipe.decorators=[{type:_angular_core.Pipe,args:[{name:"localeCurrency",pure:!0}]}],LocaleCurrencyPipe.ctorParameters=function(){return[]};var BFS=function(){function BFS(){}return BFS.getTargetNode=function(rootNode){return this.walk(rootNode)},BFS.walk=function(rootNode){var iNode,queue=[],depth=0,nodeToDepthIncrease=1;for(queue.push(rootNode);queue.length>0&&depth<=this.MAX_DEPTH;){if(iNode=queue.shift(),this.isTargetNode(iNode))return iNode;if(depth<this.MAX_DEPTH&&null!=iNode.childNodes)for(var _i=0,_a=iNode.childNodes;_i<_a.length;_i++){var child=_a[_i];this.isValidNode(child)&&queue.push(child)}0==--nodeToDepthIncrease&&(depth++,nodeToDepthIncrease=queue.length)}return rootNode},BFS.isTargetNode=function(node){return void 0!==node&&3==node.nodeType&&null!=node.nodeValue&&""!=node.nodeValue.trim()},BFS.isValidNode=function(node){if(void 0!==node&&1==node.nodeType&&node.attributes)for(var _i=0,_a=node.attributes;_i<_a.length;_i++){var attr=_a[_i];if(this.SELECTOR.test(attr.name))return!1}return!0},BFS}();BFS.SELECTOR=/^l10n|translate|locale/,BFS.MAX_DEPTH=3;var BaseDirective=function(){function BaseDirective(el,renderer){this.el=el,this.renderer=renderer,this.attributes=[],this.subscriptions=[],this.TEXT_MUTATION_CONFIG={subtree:!0,characterData:!0},this.SELECTOR=/^l10n-/}return BaseDirective.prototype.ngAfterViewInit=function(){this.el&&this.el.nativeElement&&(this.element=this.el.nativeElement,this.renderNode=BFS.getTargetNode(this.element),this.getKey(),this.getAttributes(),this.addTextListener(),this.setup())},BaseDirective.prototype.ngOnChanges=function(changes){this.key&&(null!=this.nodeValue&&""!=this.nodeValue||(this.valueAttribute?this.key=this.valueAttribute:this.innerHTMLProperty&&(this.key=this.innerHTMLProperty)),this.replaceText()),this.attributes.length>0&&this.replaceAttributes()},BaseDirective.prototype.ngOnDestroy=function(){this.removeTextListener(),this.cancelSubscriptions()},BaseDirective.prototype.setup=function(){},BaseDirective.prototype.replace=function(){},BaseDirective.prototype.replaceText=function(){},BaseDirective.prototype.replaceAttributes=function(){},BaseDirective.prototype.getAttributesData=function(){for(var keys=this.getAttributesKeys(),data={},_i=0,keys_2=keys;_i<keys_2.length;_i++){var key=keys_2[_i];data[key]=this.getValues(key)}return data},BaseDirective.prototype.getAttributesKeys=function(){return this.attributes.map(function(attr){return attr.key})},BaseDirective.prototype.getValues=function(keys){},BaseDirective.prototype.setText=function(value){value&&(this.nodeValue&&this.key?(this.removeTextListener(),this.renderer.setValue(this.renderNode,this.nodeValue.replace(this.key,value)),this.addTextListener()):this.valueAttribute?this.renderer.setAttribute(this.element,"value",value):this.innerHTMLProperty&&this.renderer.setProperty(this.element,"innerHTML",value))},BaseDirective.prototype.setAttributes=function(data){for(var _i=0,_a=this.attributes;_i<_a.length;_i++){var attr=_a[_i];this.renderer.setAttribute(this.element,attr.name,data[attr.key])}},BaseDirective.prototype.addTextListener=function(){var _this=this;"undefined"!=typeof MutationObserver&&(this.textObserver=new MutationObserver(function(mutations){_this.renderNode=BFS.getTargetNode(_this.element),_this.getKey(),_this.replaceText()}),this.textObserver.observe(this.renderNode,this.TEXT_MUTATION_CONFIG))},BaseDirective.prototype.removeTextListener=function(){void 0!==this.textObserver&&this.textObserver.disconnect()},BaseDirective.prototype.getText=function(){return this.nodeValue=null!=this.renderNode?this.renderNode.nodeValue:"",this.nodeValue?this.nodeValue.trim():""},BaseDirective.prototype.getKey=function(){this.element.childNodes.length>0?this.key=this.getText():this.valueAttribute?this.key=this.valueAttribute:this.innerHTMLProperty&&(this.key=this.innerHTMLProperty)},BaseDirective.prototype.getAttributes=function(){if(this.element.attributes)for(var _i=0,_a=this.element.attributes;_i<_a.length;_i++){var attr=_a[_i];if(this.SELECTOR.test(attr.name))for(var name=attr.name.substr(5),_b=0,_c=this.element.attributes;_b<_c.length;_b++){var targetAttr=_c[_b];new RegExp("^"+name+"$").test(targetAttr.name)&&this.attributes.push({name:name,key:targetAttr.value})}}},BaseDirective.prototype.cancelSubscriptions=function(){this.subscriptions.forEach(function(subscription){void 0!==subscription&&subscription.unsubscribe()})},BaseDirective}();BaseDirective.propDecorators={valueAttribute:[{type:_angular_core.Input,args:["value"]}],innerHTMLProperty:[{type:_angular_core.Input,args:["innerHTML"]}]};var TranslateDirective=function(_super){function TranslateDirective(translation,el,renderer){var _this=_super.call(this,el,renderer)||this;return _this.translation=translation,_this.el=el,_this.renderer=renderer,_this}return __extends(TranslateDirective,_super),Object.defineProperty(TranslateDirective.prototype,"l10nTranslate",{set:function(params){this.params=params},enumerable:!0,configurable:!0}),Object.defineProperty(TranslateDirective.prototype,"translate",{set:function(params){this.params=params},enumerable:!0,configurable:!0}),TranslateDirective.prototype.setup=function(){var _this=this;this.replace(),this.subscriptions.push(this.translation.translationChanged.subscribe(function(){_this.replace()}))},TranslateDirective.prototype.replace=function(){this.replaceText(),this.replaceAttributes()},TranslateDirective.prototype.replaceText=function(){this.key&&this.setText(this.getValues(this.key))},TranslateDirective.prototype.replaceAttributes=function(){if(this.attributes.length>0){var keys=this.getAttributesKeys();this.setAttributes(this.getValues(keys))}},TranslateDirective.prototype.getValues=function(keys){return this.translation.translate(keys,this.params)},TranslateDirective}(BaseDirective);TranslateDirective.decorators=[{type:_angular_core.Directive,args:[{selector:"[l10nTranslate],[translate]"}]}],TranslateDirective.ctorParameters=function(){return[{type:TranslationService},{type:_angular_core.ElementRef},{type:_angular_core.Renderer2}]},TranslateDirective.propDecorators={l10nTranslate:[{type:_angular_core.Input}],translate:[{type:_angular_core.Input}]};var LocaleDateDirective=function(_super){function LocaleDateDirective(locale,el,renderer){var _this=_super.call(this,el,renderer)||this;return _this.locale=locale,_this.el=el,_this.renderer=renderer,_this.defaultPattern="mediumDate",_this.localeDatePipe=new LocaleDatePipe,_this}return __extends(LocaleDateDirective,_super),Object.defineProperty(LocaleDateDirective.prototype,"l10nDate",{set:function(pattern){this.pattern=pattern},enumerable:!0,configurable:!0}),Object.defineProperty(LocaleDateDirective.prototype,"localeDate",{set:function(pattern){this.pattern=pattern},enumerable:!0,configurable:!0}),LocaleDateDirective.prototype.setup=function(){var _this=this;this.replace(),this.subscriptions.push(this.locale.defaultLocaleChanged.subscribe(function(){_this.replace()}))},LocaleDateDirective.prototype.replace=function(){this.replaceText(),this.replaceAttributes()},LocaleDateDirective.prototype.replaceText=function(){this.key&&this.setText(this.getValues(this.key))},LocaleDateDirective.prototype.replaceAttributes=function(){this.attributes.length>0&&this.setAttributes(this.getAttributesData())},LocaleDateDirective.prototype.getValues=function(keys){return this.localeDatePipe.transform(keys,this.locale.getDefaultLocale(),this.pattern||this.defaultPattern)},LocaleDateDirective}(BaseDirective);LocaleDateDirective.decorators=[{type:_angular_core.Directive,args:[{selector:"[l10nDate],[localeDate]"}]}],LocaleDateDirective.ctorParameters=function(){return[{type:LocaleService},{type:_angular_core.ElementRef},{type:_angular_core.Renderer2}]},LocaleDateDirective.propDecorators={l10nDate:[{type:_angular_core.Input}],localeDate:[{type:_angular_core.Input}]};var LocaleDecimalDirective=function(_super){function LocaleDecimalDirective(locale,el,renderer){var _this=_super.call(this,el,renderer)||this;return _this.locale=locale,_this.el=el,_this.renderer=renderer,_this.localeDecimalPipe=new LocaleDecimalPipe,_this}return __extends(LocaleDecimalDirective,_super),Object.defineProperty(LocaleDecimalDirective.prototype,"l10nDecimal",{set:function(digits){this.digits=digits},enumerable:!0,configurable:!0}),Object.defineProperty(LocaleDecimalDirective.prototype,"localeDecimal",{set:function(digits){this.digits=digits},enumerable:!0,configurable:!0}),LocaleDecimalDirective.prototype.setup=function(){var _this=this;this.replace(),this.subscriptions.push(this.locale.defaultLocaleChanged.subscribe(function(){_this.replace()}))},LocaleDecimalDirective.prototype.replace=function(){this.replaceText(),this.replaceAttributes()},LocaleDecimalDirective.prototype.replaceText=function(){this.key&&this.setText(this.getValues(this.key))},LocaleDecimalDirective.prototype.replaceAttributes=function(){this.attributes.length>0&&this.setAttributes(this.getAttributesData())},LocaleDecimalDirective.prototype.getValues=function(keys){return this.localeDecimalPipe.transform(keys,this.locale.getDefaultLocale(),this.digits)},LocaleDecimalDirective}(BaseDirective);LocaleDecimalDirective.decorators=[{type:_angular_core.Directive,args:[{selector:"[l10nDecimal],[localeDecimal]"}]}],LocaleDecimalDirective.ctorParameters=function(){return[{type:LocaleService},{type:_angular_core.ElementRef},{type:_angular_core.Renderer2}]},LocaleDecimalDirective.propDecorators={l10nDecimal:[{type:_angular_core.Input}],localeDecimal:[{type:_angular_core.Input}]};var LocalePercentDirective=function(_super){function LocalePercentDirective(locale,el,renderer){var _this=_super.call(this,el,renderer)||this;return _this.locale=locale,_this.el=el,_this.renderer=renderer,_this.localePercentPipe=new LocalePercentPipe,_this}return __extends(LocalePercentDirective,_super),Object.defineProperty(LocalePercentDirective.prototype,"l10nPercent",{set:function(digits){this.digits=digits},enumerable:!0,configurable:!0}),Object.defineProperty(LocalePercentDirective.prototype,"localePercent",{set:function(digits){this.digits=digits},enumerable:!0,configurable:!0}),LocalePercentDirective.prototype.setup=function(){var _this=this;this.replace(),this.subscriptions.push(this.locale.defaultLocaleChanged.subscribe(function(){_this.replace()}))},LocalePercentDirective.prototype.replace=function(){this.replaceText(),this.replaceAttributes()},LocalePercentDirective.prototype.replaceText=function(){this.key&&this.setText(this.getValues(this.key))},LocalePercentDirective.prototype.replaceAttributes=function(){this.attributes.length>0&&this.setAttributes(this.getAttributesData())},LocalePercentDirective.prototype.getValues=function(keys){return this.localePercentPipe.transform(keys,this.locale.getDefaultLocale(),this.digits)},LocalePercentDirective}(BaseDirective);LocalePercentDirective.decorators=[{type:_angular_core.Directive,args:[{selector:"[l10nPercent],[localePercent]"}]}],LocalePercentDirective.ctorParameters=function(){return[{type:LocaleService},{type:_angular_core.ElementRef},{type:_angular_core.Renderer2}]},LocalePercentDirective.propDecorators={l10nPercent:[{type:_angular_core.Input}],localePercent:[{type:_angular_core.Input}]};var LocaleCurrencyDirective=function(_super){function LocaleCurrencyDirective(locale,el,renderer){var _this=_super.call(this,el,renderer)||this;return _this.locale=locale,_this.el=el,_this.renderer=renderer,_this.localeCurrencyPipe=new LocaleCurrencyPipe,_this}return __extends(LocaleCurrencyDirective,_super),Object.defineProperty(LocaleCurrencyDirective.prototype,"l10nCurrency",{set:function(digits){this.digits=digits},enumerable:!0,configurable:!0}),Object.defineProperty(LocaleCurrencyDirective.prototype,"localeCurrency",{set:function(digits){this.digits=digits},enumerable:!0,configurable:!0}),LocaleCurrencyDirective.prototype.setup=function(){var _this=this;this.replace(),this.subscriptions.push(this.locale.defaultLocaleChanged.subscribe(function(){_this.replace()})),this.subscriptions.push(this.locale.currencyCodeChanged.subscribe(function(){_this.replace()}))},LocaleCurrencyDirective.prototype.replace=function(){this.replaceText(),this.replaceAttributes()},LocaleCurrencyDirective.prototype.replaceText=function(){this.key&&this.setText(this.getValues(this.key))},LocaleCurrencyDirective.prototype.replaceAttributes=function(){this.attributes.length>0&&this.setAttributes(this.getAttributesData())},LocaleCurrencyDirective.prototype.getValues=function(keys){return this.localeCurrencyPipe.transform(keys,this.locale.getDefaultLocale(),this.locale.getCurrentCurrency(),this.symbol,this.digits)},LocaleCurrencyDirective}(BaseDirective);LocaleCurrencyDirective.decorators=[{type:_angular_core.Directive,args:[{selector:"[l10nCurrency],[localeCurrency]"}]}],LocaleCurrencyDirective.ctorParameters=function(){return[{type:LocaleService},{type:_angular_core.ElementRef},{type:_angular_core.Renderer2}]},LocaleCurrencyDirective.propDecorators={l10nCurrency:[{type:_angular_core.Input}],localeCurrency:[{type:_angular_core.Input}],symbol:[{type:_angular_core.Input}]};var LocaleNumberValidatorDirective=function(){function LocaleNumberValidatorDirective(){this.MIN_VALUE=Number.MIN_VALUE,this.MAX_VALUE=Number.MAX_VALUE}return Object.defineProperty(LocaleNumberValidatorDirective.prototype,"l10nValidateNumber",{set:function(digits){this.digits=digits},enumerable:!0,configurable:!0}),Object.defineProperty(LocaleNumberValidatorDirective.prototype,"validateLocaleNumber",{set:function(digits){this.digits=digits},enumerable:!0,configurable:!0}),LocaleNumberValidatorDirective.prototype.ngOnInit=function(){this.validator=validateLocaleNumber(this.digits,this.minValue||this.MIN_VALUE,this.maxValue||this.MAX_VALUE)},LocaleNumberValidatorDirective.prototype.validate=function(formControl){return this.validator(formControl)},LocaleNumberValidatorDirective}();LocaleNumberValidatorDirective.decorators=[{type:_angular_core.Directive,args:[{selector:"[l10nValidateNumber][ngModel],[l10nValidateNumber][formControl], [validateLocaleNumber][ngModel],[validateLocaleNumber][formControl]",providers:[{provide:_angular_forms.NG_VALIDATORS,useExisting:_angular_core.forwardRef(function(){return LocaleNumberValidatorDirective}),multi:!0}]}]}],LocaleNumberValidatorDirective.ctorParameters=function(){return[]},LocaleNumberValidatorDirective.propDecorators={l10nValidateNumber:[{type:_angular_core.Input}],validateLocaleNumber:[{type:_angular_core.Input}],minValue:[{type:_angular_core.Input}],maxValue:[{type:_angular_core.Input}]};var TranslationModule=function(){function TranslationModule(injector){this.injector=injector}return TranslationModule.forRoot=function(token){return void 0===token&&(token={}),{ngModule:TranslationModule,providers:[InjectorRef,LocaleConfig,LocaleService,{provide:LocaleStorage,useClass:token.localeStorage||BrowserStorage},TranslationConfig,TranslationService,{provide:TranslationProvider,useClass:token.translationProvider||HttpTranslationProvider},{provide:TranslationHandler,useClass:token.translationHandler||DefaultTranslationHandler}]}},TranslationModule.forChild=function(token){return void 0===token&&(token={}),{ngModule:TranslationModule,providers:[InjectorRef,TranslationConfig,TranslationService,{provide:TranslationProvider,useClass:token.translationProvider||HttpTranslationProvider},{provide:TranslationHandler,useClass:token.translationHandler||DefaultTranslationHandler}]}},TranslationModule}();TranslationModule.decorators=[{type:_angular_core.NgModule,args:[{declarations:[TranslatePipe,TranslateDirective],exports:[TranslatePipe,TranslateDirective]}]}],TranslationModule.ctorParameters=function(){return[{type:InjectorRef}]};var LocalizationModule=function(){function LocalizationModule(injector){this.injector=injector}return LocalizationModule.forRoot=function(token){return void 0===token&&(token={}),{ngModule:LocalizationModule,providers:[InjectorRef,LocaleConfig,LocaleService,{provide:LocaleStorage,useClass:token.localeStorage||BrowserStorage},TranslationConfig,TranslationService,{provide:TranslationProvider,useClass:token.translationProvider||HttpTranslationProvider},{provide:TranslationHandler,useClass:token.translationHandler||DefaultTranslationHandler}]}},LocalizationModule.forChild=function(token){return void 0===token&&(token={}),{ngModule:LocalizationModule,providers:[InjectorRef,TranslationConfig,TranslationService,{provide:TranslationProvider,useClass:token.translationProvider||HttpTranslationProvider},{provide:TranslationHandler,useClass:token.translationHandler||DefaultTranslationHandler}]}},LocalizationModule}();LocalizationModule.decorators=[{type:_angular_core.NgModule,args:[{declarations:[LocaleDatePipe,LocaleDecimalPipe,LocalePercentPipe,LocaleCurrencyPipe,LocaleDateDirective,LocaleDecimalDirective,LocalePercentDirective,LocaleCurrencyDirective],imports:[TranslationModule],exports:[TranslationModule,LocaleDatePipe,LocaleDecimalPipe,LocalePercentPipe,LocaleCurrencyPipe,LocaleDateDirective,LocaleDecimalDirective,LocalePercentDirective,LocaleCurrencyDirective]}]}],LocalizationModule.ctorParameters=function(){return[{type:InjectorRef}]};var LocaleValidationModule=function(){function LocaleValidationModule(){}return LocaleValidationModule.forRoot=function(){return{ngModule:LocaleValidationModule,providers:[DecimalCode,LocaleValidation]}},LocaleValidationModule}();LocaleValidationModule.decorators=[{type:_angular_core.NgModule,args:[{declarations:[LocaleNumberValidatorDirective],exports:[LocaleNumberValidatorDirective]}]}],LocaleValidationModule.ctorParameters=function(){return[]},exports.InjectorRef=InjectorRef,exports.LocaleConfig=LocaleConfig,exports.LocaleService=LocaleService,exports.LocaleStorage=LocaleStorage,exports.BrowserStorage=BrowserStorage,exports.TranslationConfig=TranslationConfig,exports.TranslationService=TranslationService,exports.TranslationProvider=TranslationProvider,exports.HttpTranslationProvider=HttpTranslationProvider,exports.TranslationHandler=TranslationHandler,exports.DefaultTranslationHandler=DefaultTranslationHandler,exports.Translation=Translation,exports.Localization=Localization,exports.NumberCode=NumberCode,exports.DecimalCode=DecimalCode,exports.LocaleValidation=LocaleValidation,exports.Collator=Collator,exports.IntlAPI=IntlAPI,exports.Language=Language,exports.DefaultLocale=DefaultLocale$1,exports.Currency=Currency,exports.TranslatePipe=TranslatePipe,exports.LocaleDatePipe=LocaleDatePipe,exports.LocaleDecimalPipe=LocaleDecimalPipe,exports.LocalePercentPipe=LocalePercentPipe,exports.LocaleCurrencyPipe=LocaleCurrencyPipe,exports.BaseDirective=BaseDirective,exports.TranslateDirective=TranslateDirective,exports.LocaleDateDirective=LocaleDateDirective,exports.LocaleDecimalDirective=LocaleDecimalDirective,exports.LocalePercentDirective=LocalePercentDirective,exports.LocaleCurrencyDirective=LocaleCurrencyDirective,exports.LocaleNumberValidatorDirective=LocaleNumberValidatorDirective,exports.validateLocaleNumber=validateLocaleNumber,exports.TranslationModule=TranslationModule,exports.LocalizationModule=LocalizationModule,exports.LocaleValidationModule=LocaleValidationModule,Object.defineProperty(exports,"__esModule",{value:!0})}); | ||
NumberCode.ctorParameters=function(){return[{type:LocaleService}]};var DecimalCode=function(_super){function DecimalCode(locale){var _this=_super.call(this,locale)||this;return _this.locale=locale,_this}return __extends(DecimalCode,_super),Object.defineProperty(DecimalCode.prototype,"decimalCodes",{get:function(){var decimalCodes={minusSign:this.toUnicode("-"),decimalSeparator:this.toUnicode(".")};if(IntlAPI.hasNumberFormat()){var localeValue=new Intl.NumberFormat(this.locale.getDefaultLocale()).format(-.9),unicodeChars=[];unicodeChars.push(this.toUnicode(localeValue.charAt(0))),unicodeChars.push(this.toUnicode(localeValue.charAt(1))),unicodeChars.push(this.toUnicode(localeValue.charAt(2))),unicodeChars.push(this.toUnicode(localeValue.charAt(3))),decimalCodes="\\u200F"==unicodeChars[0]||"\\u061C"==unicodeChars[0]?{minusSign:unicodeChars[1],decimalSeparator:unicodeChars[3]}:unicodeChars[0]==this.toUnicode(new Intl.NumberFormat(this.locale.getDefaultLocale()).format(0))?{minusSign:unicodeChars[3],decimalSeparator:unicodeChars[1]}:"\\u200E"==unicodeChars[0]?{minusSign:unicodeChars[1],decimalSeparator:unicodeChars[3]}:{minusSign:unicodeChars[0],decimalSeparator:unicodeChars[2]}}return decimalCodes},enumerable:!0,configurable:!0}),DecimalCode.prototype.parse=function(s){for(var value="",decimalCodes=this.decimalCodes,characters=s.split(""),_i=0,characters_1=characters;_i<characters_1.length;_i++){var char=characters_1[_i],charCode=this.toUnicode(char),index=this.numberCodes.indexOf(charCode);if(-1!=index)value+=index;else if(charCode==decimalCodes.minusSign)value+="-";else{if(charCode!=decimalCodes.decimalSeparator)return NaN;value+="."}}return parseFloat(value)},DecimalCode.prototype.getRegExp=function(digits){var minInt=1,minFraction=0,maxFraction=3;if(digits){var NUMBER_FORMAT_REGEXP=/^(\d+)?\.((\d+)(\-(\d+))?)?$/,parts=digits.match(NUMBER_FORMAT_REGEXP);null!=parts&&(null!=parts[1]&&(minInt=parseInt(parts[1])),null!=parts[3]&&(minFraction=parseInt(parts[3])),null!=parts[5]&&(maxFraction=parseInt(parts[5])))}var pattern,minusSign=this.decimalCodes.minusSign,zero=this.numberCodes[0],decimalSeparator=this.decimalCodes.decimalSeparator,nine=this.numberCodes[9];return pattern=minFraction>0&&maxFraction>0?"^"+minusSign+"?["+zero+"-"+nine+"]{"+minInt+",}\\"+decimalSeparator+"["+zero+"-"+nine+"]{"+minFraction+","+maxFraction+"}$":0==minFraction&&maxFraction>0?"^"+minusSign+"?["+zero+"-"+nine+"]{"+minInt+",}\\"+decimalSeparator+"?["+zero+"-"+nine+"]{"+minFraction+","+maxFraction+"}$":"^"+minusSign+"?["+zero+"-"+nine+"]{"+minInt+",}$",pattern=this.toChar(pattern),new RegExp(pattern)},DecimalCode}(NumberCode);DecimalCode.decorators=[{type:_angular_core.Injectable}],DecimalCode.ctorParameters=function(){return[{type:LocaleService}]};var LocaleValidation=function(){function LocaleValidation(decimalCode){this.decimalCode=decimalCode}return LocaleValidation.prototype.parseNumber=function(s){return""==s?null:this.decimalCode.parse(s)},LocaleValidation}();LocaleValidation.decorators=[{type:_angular_core.Injectable}],LocaleValidation.ctorParameters=function(){return[{type:DecimalCode}]};var Collator=function(){function Collator(locale,translation){this.locale=locale,this.translation=translation}return Collator.prototype.compare=function(key1,key2,extension,options){if(void 0===options&&(options={usage:"sort",sensitivity:"variant"}),!IntlAPI.hasCollator())return 0;var value1=this.translation.translate(key1),value2=this.translation.translate(key2),locale=this.addExtension(this.locale.getCurrentLocale(),extension);return new Intl.Collator(locale,options).compare(value1,value2)},Collator.prototype.sort=function(list,keyName,order,extension,options){var _this=this;return void 0===order&&(order="asc"),void 0===options&&(options={usage:"sort",sensitivity:"variant"}),list&&keyName&&IntlAPI.hasCollator()?(list.sort(function(key1,key2){return _this.compare(key1[keyName],key2[keyName],extension,options)}),"desc"==order&&list.reverse(),list):list},Collator.prototype.sortAsync=function(list,keyName,order,extension,options){var _this=this;return void 0===options&&(options={usage:"sort",sensitivity:"variant"}),rxjs_Observable.Observable.create(function(observer){observer.next(_this.sort(list,keyName,order,extension,options)),observer.complete()})},Collator.prototype.search=function(s,list,keyNames,options){var _this=this;if(void 0===options&&(options={usage:"search"}),!list||!keyNames||""==s||null==s||!IntlAPI.hasCollator())return list;var locale=this.locale.getCurrentLocale(),collator=new Intl.Collator(locale,options);return list.filter(function(key){for(var found=!1,i=0;i<keyNames.length;i++)if(_this.match(key[keyNames[i]],s,collator)){found=!0;break}return found})},Collator.prototype.searchAsync=function(s,list,keyNames,options){var _this=this;return void 0===options&&(options={usage:"search"}),rxjs_Observable.Observable.create(function(observer){observer.next(_this.search(s,list,keyNames,options)),observer.complete()})},Collator.prototype.addExtension=function(locale,extension){return extension&&(locale=locale+"-u-"+extension),locale},Collator.prototype.match=function(key,s,collator){var value=this.translation.translate(key),valueLength=value.length,sLength=s.length;if(sLength>valueLength)return!1;if(sLength==valueLength)return 0==collator.compare(value,s);for(var found=!1,i=0;i<valueLength-(sLength-1);i++){var str=value.substr(i,sLength);if(0==collator.compare(str,s)){found=!0;break}}return found},Collator}();Collator.decorators=[{type:_angular_core.Injectable}],Collator.ctorParameters=function(){return[{type:LocaleService},{type:TranslationService}]};var TranslatePipe=function(){function TranslatePipe(translation){this.translation=translation}return TranslatePipe.prototype.transform=function(key,lang,args){return this.translation.translate(key,args,lang)},TranslatePipe}();TranslatePipe.decorators=[{type:_angular_core.Pipe,args:[{name:"translate",pure:!0}]}],TranslatePipe.ctorParameters=function(){return[{type:TranslationService}]};var LocaleDatePipe=function(){function LocaleDatePipe(){}return LocaleDatePipe.prototype.transform=function(value,defaultLocale,pattern){if(void 0===pattern&&(pattern="mediumDate"),void 0===defaultLocale)return null;if(IntlAPI.hasDateTimeFormat()){return new _angular_common.DatePipe(defaultLocale).transform(value,pattern)}return value},LocaleDatePipe}();LocaleDatePipe.decorators=[{type:_angular_core.Pipe,args:[{name:"localeDate",pure:!0}]}],LocaleDatePipe.ctorParameters=function(){return[]};var LocaleDecimalPipe=function(){function LocaleDecimalPipe(){}return LocaleDecimalPipe.prototype.transform=function(value,defaultLocale,digits){if(void 0===defaultLocale)return null;if(IntlAPI.hasNumberFormat()){return new _angular_common.DecimalPipe(defaultLocale).transform(value,digits)}return value},LocaleDecimalPipe}();LocaleDecimalPipe.decorators=[{type:_angular_core.Pipe,args:[{name:"localeDecimal",pure:!0}]}],LocaleDecimalPipe.ctorParameters=function(){return[]};var LocalePercentPipe=function(){function LocalePercentPipe(){}return LocalePercentPipe.prototype.transform=function(value,defaultLocale,digits){if(void 0===defaultLocale)return null;if(IntlAPI.hasNumberFormat()){return new _angular_common.PercentPipe(defaultLocale).transform(value,digits)}return value},LocalePercentPipe}();LocalePercentPipe.decorators=[{type:_angular_core.Pipe,args:[{name:"localePercent",pure:!0}]}],LocalePercentPipe.ctorParameters=function(){return[]};var LocaleCurrencyPipe=function(){function LocaleCurrencyPipe(){}return LocaleCurrencyPipe.prototype.transform=function(value,defaultLocale,currency,symbolDisplay,digits){if(void 0===symbolDisplay&&(symbolDisplay=!1),void 0===defaultLocale||void 0===currency)return null;if(IntlAPI.hasNumberFormat()){return new _angular_common.CurrencyPipe(defaultLocale).transform(value,currency,symbolDisplay,digits)}return value+" "+currency},LocaleCurrencyPipe}();LocaleCurrencyPipe.decorators=[{type:_angular_core.Pipe,args:[{name:"localeCurrency",pure:!0}]}],LocaleCurrencyPipe.ctorParameters=function(){return[]};var BFS=function(){function BFS(){}return BFS.getTargetNode=function(rootNode){return this.walk(rootNode)},BFS.walk=function(rootNode){var iNode,queue=[],depth=0,nodeToDepthIncrease=1;for(queue.push(rootNode);queue.length>0&&depth<=this.MAX_DEPTH;){if(iNode=queue.shift(),this.isTargetNode(iNode))return iNode;if(depth<this.MAX_DEPTH&&null!=iNode.childNodes)for(var _i=0,_a=iNode.childNodes;_i<_a.length;_i++){var child=_a[_i];this.isValidNode(child)&&queue.push(child)}0==--nodeToDepthIncrease&&(depth++,nodeToDepthIncrease=queue.length)}return rootNode},BFS.isTargetNode=function(node){return void 0!==node&&3==node.nodeType&&null!=node.nodeValue&&""!=node.nodeValue.trim()},BFS.isValidNode=function(node){if(void 0!==node&&1==node.nodeType&&node.attributes)for(var _i=0,_a=node.attributes;_i<_a.length;_i++){var attr=_a[_i];if(this.SELECTOR.test(attr.name))return!1}return!0},BFS}();BFS.SELECTOR=/^l10n|translate|locale/,BFS.MAX_DEPTH=10;var BaseDirective=function(){function BaseDirective(el,renderer){this.el=el,this.renderer=renderer,this.attributes=[],this.subscriptions=[],this.TEXT_MUTATION_CONFIG={subtree:!0,characterData:!0},this.SELECTOR=/^l10n-/}return BaseDirective.prototype.ngAfterViewInit=function(){this.el&&this.el.nativeElement&&(this.element=this.el.nativeElement,this.renderNode=BFS.getTargetNode(this.element),this.getKey(),this.getAttributes(),this.addTextListener(),this.setup())},BaseDirective.prototype.ngOnChanges=function(changes){this.key&&(null!=this.nodeValue&&""!=this.nodeValue||(this.valueAttribute?this.key=this.valueAttribute:this.innerHTMLProperty&&(this.key=this.innerHTMLProperty)),this.replaceText()),this.attributes.length>0&&this.replaceAttributes()},BaseDirective.prototype.ngOnDestroy=function(){this.removeTextListener(),this.cancelSubscriptions()},BaseDirective.prototype.setup=function(){},BaseDirective.prototype.replace=function(){},BaseDirective.prototype.replaceText=function(){},BaseDirective.prototype.replaceAttributes=function(){},BaseDirective.prototype.getAttributesData=function(){for(var keys=this.getAttributesKeys(),data={},_i=0,keys_2=keys;_i<keys_2.length;_i++){var key=keys_2[_i];data[key]=this.getValues(key)}return data},BaseDirective.prototype.getAttributesKeys=function(){return this.attributes.map(function(attr){return attr.key})},BaseDirective.prototype.getValues=function(keys){},BaseDirective.prototype.setText=function(value){value&&(this.nodeValue&&this.key?(this.removeTextListener(),this.renderer.setValue(this.renderNode,this.nodeValue.replace(this.key,value)),this.addTextListener()):this.valueAttribute?this.renderer.setAttribute(this.element,"value",value):this.innerHTMLProperty&&this.renderer.setProperty(this.element,"innerHTML",value))},BaseDirective.prototype.setAttributes=function(data){for(var _i=0,_a=this.attributes;_i<_a.length;_i++){var attr=_a[_i];this.renderer.setAttribute(this.element,attr.name,data[attr.key])}},BaseDirective.prototype.addTextListener=function(){var _this=this;"undefined"!=typeof MutationObserver&&(this.textObserver=new MutationObserver(function(mutations){_this.renderNode=BFS.getTargetNode(_this.element),_this.getKey(),_this.replaceText()}),this.textObserver.observe(this.renderNode,this.TEXT_MUTATION_CONFIG))},BaseDirective.prototype.removeTextListener=function(){void 0!==this.textObserver&&this.textObserver.disconnect()},BaseDirective.prototype.getText=function(){return this.nodeValue=null!=this.renderNode?this.renderNode.nodeValue:"",this.nodeValue?this.nodeValue.trim():""},BaseDirective.prototype.getKey=function(){this.element.childNodes.length>0?this.key=this.getText():this.valueAttribute?this.key=this.valueAttribute:this.innerHTMLProperty&&(this.key=this.innerHTMLProperty)},BaseDirective.prototype.getAttributes=function(){if(this.element.attributes)for(var _i=0,_a=this.element.attributes;_i<_a.length;_i++){var attr=_a[_i];if(this.SELECTOR.test(attr.name))for(var name=attr.name.substr(5),_b=0,_c=this.element.attributes;_b<_c.length;_b++){var targetAttr=_c[_b];new RegExp("^"+name+"$").test(targetAttr.name)&&this.attributes.push({name:name,key:targetAttr.value})}}},BaseDirective.prototype.cancelSubscriptions=function(){this.subscriptions.forEach(function(subscription){void 0!==subscription&&subscription.unsubscribe()})},BaseDirective}();BaseDirective.propDecorators={valueAttribute:[{type:_angular_core.Input,args:["value"]}],innerHTMLProperty:[{type:_angular_core.Input,args:["innerHTML"]}]};var TranslateDirective=function(_super){function TranslateDirective(translation,el,renderer){var _this=_super.call(this,el,renderer)||this;return _this.translation=translation,_this.el=el,_this.renderer=renderer,_this}return __extends(TranslateDirective,_super),Object.defineProperty(TranslateDirective.prototype,"l10nTranslate",{set:function(params){this.params=params},enumerable:!0,configurable:!0}),Object.defineProperty(TranslateDirective.prototype,"translate",{set:function(params){this.params=params},enumerable:!0,configurable:!0}),TranslateDirective.prototype.setup=function(){var _this=this;this.replace(),this.subscriptions.push(this.translation.translationChanged.subscribe(function(){_this.replace()}))},TranslateDirective.prototype.replace=function(){this.replaceText(),this.replaceAttributes()},TranslateDirective.prototype.replaceText=function(){this.key&&this.setText(this.getValues(this.key))},TranslateDirective.prototype.replaceAttributes=function(){if(this.attributes.length>0){var keys=this.getAttributesKeys();this.setAttributes(this.getValues(keys))}},TranslateDirective.prototype.getValues=function(keys){return this.translation.translate(keys,this.params)},TranslateDirective}(BaseDirective);TranslateDirective.decorators=[{type:_angular_core.Directive,args:[{selector:"[l10nTranslate],[translate]"}]}],TranslateDirective.ctorParameters=function(){return[{type:TranslationService},{type:_angular_core.ElementRef},{type:_angular_core.Renderer2}]},TranslateDirective.propDecorators={l10nTranslate:[{type:_angular_core.Input}],translate:[{type:_angular_core.Input}]};var LocaleDateDirective=function(_super){function LocaleDateDirective(locale,el,renderer){var _this=_super.call(this,el,renderer)||this;return _this.locale=locale,_this.el=el,_this.renderer=renderer,_this.defaultPattern="mediumDate",_this.localeDatePipe=new LocaleDatePipe,_this}return __extends(LocaleDateDirective,_super),Object.defineProperty(LocaleDateDirective.prototype,"l10nDate",{set:function(pattern){this.pattern=pattern},enumerable:!0,configurable:!0}),Object.defineProperty(LocaleDateDirective.prototype,"localeDate",{set:function(pattern){this.pattern=pattern},enumerable:!0,configurable:!0}),LocaleDateDirective.prototype.setup=function(){var _this=this;this.replace(),this.subscriptions.push(this.locale.defaultLocaleChanged.subscribe(function(){_this.replace()}))},LocaleDateDirective.prototype.replace=function(){this.replaceText(),this.replaceAttributes()},LocaleDateDirective.prototype.replaceText=function(){this.key&&this.setText(this.getValues(this.key))},LocaleDateDirective.prototype.replaceAttributes=function(){this.attributes.length>0&&this.setAttributes(this.getAttributesData())},LocaleDateDirective.prototype.getValues=function(keys){return this.localeDatePipe.transform(keys,this.locale.getDefaultLocale(),this.pattern||this.defaultPattern)},LocaleDateDirective}(BaseDirective);LocaleDateDirective.decorators=[{type:_angular_core.Directive,args:[{selector:"[l10nDate],[localeDate]"}]}],LocaleDateDirective.ctorParameters=function(){return[{type:LocaleService},{type:_angular_core.ElementRef},{type:_angular_core.Renderer2}]},LocaleDateDirective.propDecorators={l10nDate:[{type:_angular_core.Input}],localeDate:[{type:_angular_core.Input}]};var LocaleDecimalDirective=function(_super){function LocaleDecimalDirective(locale,el,renderer){var _this=_super.call(this,el,renderer)||this;return _this.locale=locale,_this.el=el,_this.renderer=renderer,_this.localeDecimalPipe=new LocaleDecimalPipe,_this}return __extends(LocaleDecimalDirective,_super),Object.defineProperty(LocaleDecimalDirective.prototype,"l10nDecimal",{set:function(digits){this.digits=digits},enumerable:!0,configurable:!0}),Object.defineProperty(LocaleDecimalDirective.prototype,"localeDecimal",{set:function(digits){this.digits=digits},enumerable:!0,configurable:!0}),LocaleDecimalDirective.prototype.setup=function(){var _this=this;this.replace(),this.subscriptions.push(this.locale.defaultLocaleChanged.subscribe(function(){_this.replace()}))},LocaleDecimalDirective.prototype.replace=function(){this.replaceText(),this.replaceAttributes()},LocaleDecimalDirective.prototype.replaceText=function(){this.key&&this.setText(this.getValues(this.key))},LocaleDecimalDirective.prototype.replaceAttributes=function(){this.attributes.length>0&&this.setAttributes(this.getAttributesData())},LocaleDecimalDirective.prototype.getValues=function(keys){return this.localeDecimalPipe.transform(keys,this.locale.getDefaultLocale(),this.digits)},LocaleDecimalDirective}(BaseDirective);LocaleDecimalDirective.decorators=[{type:_angular_core.Directive,args:[{selector:"[l10nDecimal],[localeDecimal]"}]}],LocaleDecimalDirective.ctorParameters=function(){return[{type:LocaleService},{type:_angular_core.ElementRef},{type:_angular_core.Renderer2}]},LocaleDecimalDirective.propDecorators={l10nDecimal:[{type:_angular_core.Input}],localeDecimal:[{type:_angular_core.Input}]};var LocalePercentDirective=function(_super){function LocalePercentDirective(locale,el,renderer){var _this=_super.call(this,el,renderer)||this;return _this.locale=locale,_this.el=el,_this.renderer=renderer,_this.localePercentPipe=new LocalePercentPipe,_this}return __extends(LocalePercentDirective,_super),Object.defineProperty(LocalePercentDirective.prototype,"l10nPercent",{set:function(digits){this.digits=digits},enumerable:!0,configurable:!0}),Object.defineProperty(LocalePercentDirective.prototype,"localePercent",{set:function(digits){this.digits=digits},enumerable:!0,configurable:!0}),LocalePercentDirective.prototype.setup=function(){var _this=this;this.replace(),this.subscriptions.push(this.locale.defaultLocaleChanged.subscribe(function(){_this.replace()}))},LocalePercentDirective.prototype.replace=function(){this.replaceText(),this.replaceAttributes()},LocalePercentDirective.prototype.replaceText=function(){this.key&&this.setText(this.getValues(this.key))},LocalePercentDirective.prototype.replaceAttributes=function(){this.attributes.length>0&&this.setAttributes(this.getAttributesData())},LocalePercentDirective.prototype.getValues=function(keys){return this.localePercentPipe.transform(keys,this.locale.getDefaultLocale(),this.digits)},LocalePercentDirective}(BaseDirective);LocalePercentDirective.decorators=[{type:_angular_core.Directive,args:[{selector:"[l10nPercent],[localePercent]"}]}],LocalePercentDirective.ctorParameters=function(){return[{type:LocaleService},{type:_angular_core.ElementRef},{type:_angular_core.Renderer2}]},LocalePercentDirective.propDecorators={l10nPercent:[{type:_angular_core.Input}],localePercent:[{type:_angular_core.Input}]};var LocaleCurrencyDirective=function(_super){function LocaleCurrencyDirective(locale,el,renderer){var _this=_super.call(this,el,renderer)||this;return _this.locale=locale,_this.el=el,_this.renderer=renderer,_this.localeCurrencyPipe=new LocaleCurrencyPipe,_this}return __extends(LocaleCurrencyDirective,_super),Object.defineProperty(LocaleCurrencyDirective.prototype,"l10nCurrency",{set:function(digits){this.digits=digits},enumerable:!0,configurable:!0}),Object.defineProperty(LocaleCurrencyDirective.prototype,"localeCurrency",{set:function(digits){this.digits=digits},enumerable:!0,configurable:!0}),LocaleCurrencyDirective.prototype.setup=function(){var _this=this;this.replace(),this.subscriptions.push(this.locale.defaultLocaleChanged.subscribe(function(){_this.replace()})),this.subscriptions.push(this.locale.currencyCodeChanged.subscribe(function(){_this.replace()}))},LocaleCurrencyDirective.prototype.replace=function(){this.replaceText(),this.replaceAttributes()},LocaleCurrencyDirective.prototype.replaceText=function(){this.key&&this.setText(this.getValues(this.key))},LocaleCurrencyDirective.prototype.replaceAttributes=function(){this.attributes.length>0&&this.setAttributes(this.getAttributesData())},LocaleCurrencyDirective.prototype.getValues=function(keys){return this.localeCurrencyPipe.transform(keys,this.locale.getDefaultLocale(),this.locale.getCurrentCurrency(),this.symbol,this.digits)},LocaleCurrencyDirective}(BaseDirective);LocaleCurrencyDirective.decorators=[{type:_angular_core.Directive,args:[{selector:"[l10nCurrency],[localeCurrency]"}]}],LocaleCurrencyDirective.ctorParameters=function(){return[{type:LocaleService},{type:_angular_core.ElementRef},{type:_angular_core.Renderer2}]},LocaleCurrencyDirective.propDecorators={l10nCurrency:[{type:_angular_core.Input}],localeCurrency:[{type:_angular_core.Input}],symbol:[{type:_angular_core.Input}]};var LocaleNumberValidatorDirective=function(){function LocaleNumberValidatorDirective(){this.MIN_VALUE=Number.MIN_VALUE,this.MAX_VALUE=Number.MAX_VALUE}return Object.defineProperty(LocaleNumberValidatorDirective.prototype,"l10nValidateNumber",{set:function(digits){this.digits=digits},enumerable:!0,configurable:!0}),Object.defineProperty(LocaleNumberValidatorDirective.prototype,"validateLocaleNumber",{set:function(digits){this.digits=digits},enumerable:!0,configurable:!0}),LocaleNumberValidatorDirective.prototype.ngOnInit=function(){this.validator=validateLocaleNumber(this.digits,this.minValue||this.MIN_VALUE,this.maxValue||this.MAX_VALUE)},LocaleNumberValidatorDirective.prototype.validate=function(formControl){return this.validator(formControl)},LocaleNumberValidatorDirective}();LocaleNumberValidatorDirective.decorators=[{type:_angular_core.Directive,args:[{selector:"[l10nValidateNumber][ngModel],[l10nValidateNumber][formControl], [validateLocaleNumber][ngModel],[validateLocaleNumber][formControl]",providers:[{provide:_angular_forms.NG_VALIDATORS,useExisting:_angular_core.forwardRef(function(){return LocaleNumberValidatorDirective}),multi:!0}]}]}],LocaleNumberValidatorDirective.ctorParameters=function(){return[]},LocaleNumberValidatorDirective.propDecorators={l10nValidateNumber:[{type:_angular_core.Input}],validateLocaleNumber:[{type:_angular_core.Input}],minValue:[{type:_angular_core.Input}],maxValue:[{type:_angular_core.Input}]};var TranslationModule=function(){function TranslationModule(injector){this.injector=injector}return TranslationModule.forRoot=function(token){return void 0===token&&(token={}),{ngModule:TranslationModule,providers:[InjectorRef,LocaleConfig,LocaleService,{provide:LocaleStorage,useClass:token.localeStorage||BrowserStorage},TranslationConfig,TranslationService,{provide:TranslationProvider,useClass:token.translationProvider||HttpTranslationProvider},{provide:TranslationHandler,useClass:token.translationHandler||DefaultTranslationHandler}]}},TranslationModule.forChild=function(token){return void 0===token&&(token={}),{ngModule:TranslationModule,providers:[InjectorRef,TranslationConfig,TranslationService,{provide:TranslationProvider,useClass:token.translationProvider||HttpTranslationProvider},{provide:TranslationHandler,useClass:token.translationHandler||DefaultTranslationHandler}]}},TranslationModule}();TranslationModule.decorators=[{type:_angular_core.NgModule,args:[{declarations:[TranslatePipe,TranslateDirective],exports:[TranslatePipe,TranslateDirective]}]}],TranslationModule.ctorParameters=function(){return[{type:InjectorRef}]};var LocalizationModule=function(){function LocalizationModule(injector){this.injector=injector}return LocalizationModule.forRoot=function(token){return void 0===token&&(token={}),{ngModule:LocalizationModule,providers:[InjectorRef,LocaleConfig,LocaleService,{provide:LocaleStorage,useClass:token.localeStorage||BrowserStorage},TranslationConfig,TranslationService,{provide:TranslationProvider,useClass:token.translationProvider||HttpTranslationProvider},{provide:TranslationHandler,useClass:token.translationHandler||DefaultTranslationHandler}]}},LocalizationModule.forChild=function(token){return void 0===token&&(token={}),{ngModule:LocalizationModule,providers:[InjectorRef,TranslationConfig,TranslationService,{provide:TranslationProvider,useClass:token.translationProvider||HttpTranslationProvider},{provide:TranslationHandler,useClass:token.translationHandler||DefaultTranslationHandler}]}},LocalizationModule}();LocalizationModule.decorators=[{type:_angular_core.NgModule,args:[{declarations:[LocaleDatePipe,LocaleDecimalPipe,LocalePercentPipe,LocaleCurrencyPipe,LocaleDateDirective,LocaleDecimalDirective,LocalePercentDirective,LocaleCurrencyDirective],imports:[TranslationModule],exports:[TranslationModule,LocaleDatePipe,LocaleDecimalPipe,LocalePercentPipe,LocaleCurrencyPipe,LocaleDateDirective,LocaleDecimalDirective,LocalePercentDirective,LocaleCurrencyDirective]}]}],LocalizationModule.ctorParameters=function(){return[{type:InjectorRef}]};var LocaleValidationModule=function(){function LocaleValidationModule(){}return LocaleValidationModule.forRoot=function(){return{ngModule:LocaleValidationModule,providers:[DecimalCode,LocaleValidation]}},LocaleValidationModule}();LocaleValidationModule.decorators=[{type:_angular_core.NgModule,args:[{declarations:[LocaleNumberValidatorDirective],exports:[LocaleNumberValidatorDirective]}]}],LocaleValidationModule.ctorParameters=function(){return[]},exports.InjectorRef=InjectorRef,exports.LocaleConfig=LocaleConfig,exports.LocaleService=LocaleService,exports.LocaleStorage=LocaleStorage,exports.BrowserStorage=BrowserStorage,exports.TranslationConfig=TranslationConfig,exports.TranslationService=TranslationService,exports.TranslationProvider=TranslationProvider,exports.HttpTranslationProvider=HttpTranslationProvider,exports.TranslationHandler=TranslationHandler,exports.DefaultTranslationHandler=DefaultTranslationHandler,exports.Translation=Translation,exports.Localization=Localization,exports.NumberCode=NumberCode,exports.DecimalCode=DecimalCode,exports.LocaleValidation=LocaleValidation,exports.Collator=Collator,exports.IntlAPI=IntlAPI,exports.Language=Language,exports.DefaultLocale=DefaultLocale$1,exports.Currency=Currency,exports.TranslatePipe=TranslatePipe,exports.LocaleDatePipe=LocaleDatePipe,exports.LocaleDecimalPipe=LocaleDecimalPipe,exports.LocalePercentPipe=LocalePercentPipe,exports.LocaleCurrencyPipe=LocaleCurrencyPipe,exports.BaseDirective=BaseDirective,exports.TranslateDirective=TranslateDirective,exports.LocaleDateDirective=LocaleDateDirective,exports.LocaleDecimalDirective=LocaleDecimalDirective,exports.LocalePercentDirective=LocalePercentDirective,exports.LocaleCurrencyDirective=LocaleCurrencyDirective,exports.LocaleNumberValidatorDirective=LocaleNumberValidatorDirective,exports.validateLocaleNumber=validateLocaleNumber,exports.TranslationModule=TranslationModule,exports.LocalizationModule=LocalizationModule,exports.LocaleValidationModule=LocaleValidationModule,Object.defineProperty(exports,"__esModule",{value:!0})}); | ||
//# sourceMappingURL=angular-l10n.umd.min.js.map |
{ | ||
"name": "angular-l10n", | ||
"version": "3.4.0", | ||
"version": "3.4.1", | ||
"description": "An Angular library to translate messages, dates and numbers", | ||
@@ -5,0 +5,0 @@ "main": "./bundles/angular-l10n.umd.js", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1232076