UNPKG

angular-l10n

Version:

An Angular library to translate messages, dates and numbers

7 lines 80 kB
!function(global,factory){"object"==typeof exports&&"undefined"!=typeof module?factory(exports,require("@angular/core"),require("rxjs"),require("@angular/router"),require("@angular/common"),require("rxjs/operators"),require("@angular/common/http"),require("@angular/platform-browser"),require("@angular/forms")):"function"==typeof define&&define.amd?define("angular-l10n",["exports","@angular/core","rxjs","@angular/router","@angular/common","rxjs/operators","@angular/common/http","@angular/platform-browser","@angular/forms"],factory):factory(((global=global||self).ng=global.ng||{},global.ng.l10n={}),global.ng.core,global.rxjs,global.ng.router,global.ng.common,global.rxjs.operators,global.ng.commmon.http,global.ng.platformBrowser,global.ng.forms)}(this,function(exports,core,rxjs,router,common,operators,http,platformBrowser,forms){"use strict";var extendStatics=function(d,b){return(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])})(d,b)};function __extends(d,b){function __(){this.constructor=d}extendStatics(d,b),d.prototype=null===b?Object.create(b):(__.prototype=b.prototype,new __)}function __awaiter(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())})}function __generator(thisArg,body){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;function verb(n){return function(v){return function(op){if(f)throw new TypeError("Generator is already executing.");for(;_;)try{if(f=1,y&&(t=2&op[0]?y.return:op[0]?y.throw||((t=y.return)&&t.call(y),0):y.next)&&!(t=t.call(y,op[1])).done)return t;switch(y=0,t&&(op=[2&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=0<(t=_.trys).length&&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}}([n,v])}}} /** * @license Angular l10n * Copyright Roberto Simonetti * MIT license * https://github.com/robisim74/angular-l10n */var InjectorRef=function(){function InjectorRef(injector){this.injector=injector,this.translations=[],InjectorRef.injector=this.injector}return InjectorRef.get=function(token,notFoundValue){return InjectorRef.injector.get(token,notFoundValue)},InjectorRef.injector=core.Injector.NULL,InjectorRef.decorators=[{type:core.Injectable}],InjectorRef.ctorParameters=function(){return[{type:core.Injector}]},InjectorRef}(),L10N_CONFIG=new core.InjectionToken("L10N_CONFIG");function l10nConfigFactory(l10nConfig){return{locale:l10nConfig.locale||{},translation:l10nConfig.translation||{},logger:l10nConfig.logger||{},localizedRouting:l10nConfig.localizedRouting||{},search:l10nConfig.search||{},localeInterceptor:l10nConfig.localeInterceptor||{}}}var StorageStrategy={Session:0,Local:1,Cookie:2,Disabled:3};StorageStrategy[StorageStrategy.Session]="Session",StorageStrategy[StorageStrategy.Local]="Local",StorageStrategy[StorageStrategy.Cookie]="Cookie",StorageStrategy[StorageStrategy.Disabled]="Disabled";var ProviderType={Fallback:0,Static:1,WebAPI:2};ProviderType[ProviderType.Fallback]="Fallback",ProviderType[ProviderType.Static]="Static",ProviderType[ProviderType.WebAPI]="WebAPI";var ISOCode={Language:"languageCode",Country:"countryCode",Script:"scriptCode"},ExtraCode_NumberingSystem="numberingSystem",ExtraCode_Calendar="calendar",ExtraCode_Currency="currency",ExtraCode_Timezone="timezone",LogLevel={Error:"error",Warn:"warn",Info:"info",Log:"log",Off:"off"},NumberFormatStyle={Decimal:0,Percent:1,Currency:2};NumberFormatStyle[NumberFormatStyle.Decimal]="Decimal",NumberFormatStyle[NumberFormatStyle.Percent]="Percent",NumberFormatStyle[NumberFormatStyle.Currency]="Currency";var NUMBER_FORMAT_REGEXP=/^(\d+)?\.((\d+)(\-(\d+))?)?$/,ISO8601_DATE_REGEX=/^(\d{4})-?(\d\d)-?(\d\d)(?:T(\d\d)(?::?(\d\d)(?::?(\d\d)(?:\.(\d+))?)?)?(Z|([+-])(\d\d):?(\d\d))?)?$/,FORMAT_ALIASES={short:{year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric"},medium:{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"},long:{year:"numeric",month:"long",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"},full:{weekday:"long",year:"numeric",month:"long",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"},shortDate:{year:"numeric",month:"numeric",day:"numeric"},mediumDate:{year:"numeric",month:"short",day:"numeric"},longDate:{year:"numeric",month:"long",day:"numeric"},fullDate:{weekday:"long",year:"numeric",month:"long",day:"numeric"},shortTime:{hour:"numeric",minute:"numeric"},mediumTime:{hour:"numeric",minute:"numeric",second:"numeric"}},LOG_MESSAGES={missingOnInit:"Missing 'ngOnInit' method: required by AoT compilation",missingOnDestroy:"Missing 'ngOnDestroy' method to cancel subscriptions: required by AoT compilation",missingLang:"Missing 'lang' parameter",missingDefaultLocale:"Missing 'defaultLocale' parameter",missingCurrency:"Missing 'currency' parameter",invalidNumberFormatAlias:"Invalid number format alias: the default format will be used",invalidDateFormatAlias:"Invalid date format alias: the default format will be used"},Logger=function(){function Logger(configuration){var _this=this;this.configuration=configuration,(Logger.level=this.configuration.logger.level||LogLevel.Off)!=LogLevel.Off&&Logger.buffer.subscribe(function(log){_this.send(log)})}return Logger.log=function(name,message){Logger.level!=LogLevel.Off&&Logger.buffer.next({name:name,message:message})},Logger.prototype.send=function(log){var message="angular-l10n ("+log.name+"): "+LOG_MESSAGES[log.message];console[Logger.level](message)},Logger.level=null,Logger.buffer=new rxjs.ReplaySubject,Logger.decorators=[{type:core.Injectable}],Logger.ctorParameters=function(){return[{type:void 0,decorators:[{type:core.Inject,args:[L10N_CONFIG]}]}]},Logger}(),Caching=function(){function Caching(){this.cache={}}return Caching.prototype.read=function(key,request){var _this=this,cached=this.cache[key];if(cached)return cached;var buffer=new rxjs.ReplaySubject(1);request.subscribe(function(value){return buffer.next(value)},function(error){buffer.error(error),_this.cache[key]=void 0},function(){return buffer.complete()});var response=buffer.asObservable();return this.cache[key]=response},Caching.decorators=[{type:core.Injectable}],Caching}(),IntlAPI=function(){function IntlAPI(){}return IntlAPI.hasIntl=function(){return"object"==typeof Intl&&!!Intl},IntlAPI.hasDateTimeFormat=function(){return IntlAPI.hasIntl()&&Intl.hasOwnProperty("DateTimeFormat")},IntlAPI.hasTimezone=function(){if(IntlAPI.hasIntl()&&IntlAPI.hasDateTimeFormat()){try{new Intl.DateTimeFormat("en-US",{timeZone:"America/Los_Angeles"}).format(new Date)}catch(e){return!1}return!0}return!1},IntlAPI.hasNumberFormat=function(){return IntlAPI.hasIntl()&&Intl.hasOwnProperty("NumberFormat")},IntlAPI.hasCollator=function(){return IntlAPI.hasIntl()&&Intl.hasOwnProperty("Collator")},IntlAPI.hasRelativeTimeFormat=function(){return IntlAPI.hasIntl()&&Intl.hasOwnProperty("RelativeTimeFormat")},IntlAPI}();var LocaleStorage=function(){function LocaleStorage(){}return LocaleStorage.decorators=[{type:core.Injectable}],LocaleStorage}(),L10nStorage=function(){function L10nStorage(configuration){this.configuration=configuration,this.hasCookie="undefined"!=typeof navigator&&navigator.cookieEnabled,this.hasStorage="undefined"!=typeof Storage}return L10nStorage.prototype.read=function(name){return __awaiter(this,void 0,void 0,function(){var value;return __generator(this,function(_a){return value=null,this.configuration.locale.storage!=StorageStrategy.Disabled&&(this.configuration.locale.storage==StorageStrategy.Local&&this.hasStorage?value=function(name){return localStorage.getItem(name)}(this.getName(name)):this.configuration.locale.storage==StorageStrategy.Session&&this.hasStorage?value=function(name){return sessionStorage.getItem(name)}(this.getName(name)):this.configuration.locale.storage==StorageStrategy.Cookie&&this.hasCookie&&(value=function(name){var result=null;return"undefined"!=typeof document&&(result=new RegExp("(?:^|; )"+encodeURIComponent(name)+"=([^;]*)").exec(document.cookie)),result?result[1]:null}(this.getName(name)))),[2,value]})})},L10nStorage.prototype.write=function(name,value){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(_a){return this.configuration.locale.storage!=StorageStrategy.Disabled&&(this.configuration.locale.storage==StorageStrategy.Local&&this.hasStorage?function(name,value){localStorage.setItem(name,value)}(this.getName(name),value):this.configuration.locale.storage==StorageStrategy.Session&&this.hasStorage?function(name,value){sessionStorage.setItem(name,value)}(this.getName(name),value):this.configuration.locale.storage==StorageStrategy.Cookie&&this.hasCookie&&function(name,value,expiration){var expires="";if(null!=expiration){var expirationDate=new Date;expirationDate.setTime(expirationDate.getTime()+24*expiration*60*60*1e3),expires="; expires="+expirationDate.toUTCString()}"undefined"!=typeof document&&(document.cookie=name+"="+value+expires+"; path=/")}(this.getName(name),value,this.configuration.locale.cookieExpiration)),[2]})})},L10nStorage.prototype.getName=function(name){return this.configuration.locale.storageNames&&this.configuration.locale.storageNames[name]||name},L10nStorage.decorators=[{type:core.Injectable}],L10nStorage.ctorParameters=function(){return[{type:void 0,decorators:[{type:core.Inject,args:[L10N_CONFIG]}]}]},L10nStorage}(),DefaultLocale=function(){function DefaultLocale(){}return Object.defineProperty(DefaultLocale.prototype,"value",{get:function(){return this.formattedValue},set:function(defaultLocale){this.formattedValue=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=languageCode;value+=scriptCode?"-"+scriptCode:"",value+=countryCode?"-"+countryCode:"",value+=numberingSystem||calendar?"-u":"",value+=numberingSystem?"-nu-"+numberingSystem:"",value+=calendar?"-ca-"+calendar:"",this.formattedValue=value},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],this.calendar=void 0):"ca"==extensions[1]&&(this.numberingSystem=void 0,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],this.scriptCode=void 0,this.countryCode=void 0;break;case 2:this.languageCode=codes[0],this.scriptCode=void 0,this.countryCode=codes[1];break;default:this.languageCode=codes[0],this.scriptCode=codes[1],this.countryCode=codes[2]}}},DefaultLocale}(),IntlFormatter=function(){function IntlFormatter(){}return IntlFormatter.formatNumber=function(value,defaultLocale,style,digits,currency,currencyDisplay){return IntlAPI.hasNumberFormat()?(value="string"!=typeof value||isNaN(+value-parseFloat(value))?value:+value,IntlFormatter.numberFormatter(value,defaultLocale,style,digits,currency,currencyDisplay)):currency?value+" "+currency:value},IntlFormatter.formatDate=function(value,defaultLocale,format,timezone){if(!IntlAPI.hasDateTimeFormat())return value;var date;if("string"==typeof value&&(value=value.trim()),IntlFormatter.isDate(value))date=value;else if(isNaN(value-parseFloat(value)))if("string"==typeof value&&/^(\d{4}-\d{1,2}-\d{1,2})$/.test(value)){var _a=value.split("-").map(function(val){return parseInt(val,10)}),y=_a[0],m=_a[1],d=_a[2];date=new Date(y,m-1,d)}else date=new Date(value);else date=new Date(parseFloat(value));if(!IntlFormatter.isDate(date)){var match=void 0;"string"==typeof value&&(match=value.match(ISO8601_DATE_REGEX))&&(date=IntlFormatter.isoStringToDate(match))}return IntlFormatter.dateTimeFormatter(date,defaultLocale,format,timezone)},IntlFormatter.formatRelativeTime=function(value,unit,defaultLocale,format){return IntlAPI.hasRelativeTimeFormat()?(value="string"!=typeof value||isNaN(+value-parseFloat(value))?value:+value,IntlFormatter.relativeTimeFormatter(value,unit,defaultLocale,format)):value+" "+unit},IntlFormatter.numberFormatter=function(num,defaultLocale,style,digits,currency,currencyDisplay){var options={};if(digits)if("string"==typeof digits){var digitsOptions=formatDigitsAliases(digits);null!=digitsOptions?options=digitsOptions:Logger.log("IntlFormatter","invalidNumberFormatAlias")}else options=digits;return options.style=NumberFormatStyle[style].toLowerCase(),style==NumberFormatStyle.Currency&&(options.currency=currency,options.currencyDisplay=currencyDisplay),new Intl.NumberFormat(defaultLocale,options).format(num)},IntlFormatter.dateTimeFormatter=function(date,defaultLocale,format,timezone){var options={};if(format)if("string"==typeof format){var dateTimeOptions=FORMAT_ALIASES[format];dateTimeOptions?options=dateTimeOptions:Logger.log("IntlFormatter","invalidDateFormatAlias")}else options=format;return options.timeZone=IntlAPI.hasTimezone()?timezone:"UTC",new Intl.DateTimeFormat(defaultLocale,options).format(date).replace(/[\u200e\u200f]/g,"")},IntlFormatter.relativeTimeFormatter=function(value,unit,defaultLocale,format){var options={};return format&&(options=format),new Intl.RelativeTimeFormat(defaultLocale,options).format(value,unit)},IntlFormatter.isDate=function(value){return value instanceof Date&&!isNaN(value.valueOf())},IntlFormatter.isoStringToDate=function(match){var date=new Date(0),tzHour=0,tzMin=0,dateSetter=match[8]?date.setUTCFullYear:date.setFullYear,timeSetter=match[8]?date.setUTCHours:date.setHours;match[9]&&(tzHour=+(match[9]+match[10]),tzMin=+(match[9]+match[11])),dateSetter.call(date,+match[1],+match[2]-1,+match[3]);var h=+(match[4]||"0")-tzHour,m=+(match[5]||"0")-tzMin,s=+(match[6]||"0"),ms=Math.round(1e3*parseFloat("0."+(match[7]||0)));return timeSetter.call(date,h,m,s,ms),date},IntlFormatter}();function formatDigitsAliases(digits){var parts=digits.match(NUMBER_FORMAT_REGEXP);if(null==parts)return null;var digitsOptions={};return null!=parts[1]&&(digitsOptions.minimumIntegerDigits=parseInt(parts[1])),null!=parts[3]&&(digitsOptions.minimumFractionDigits=parseInt(parts[3])),null!=parts[5]&&(digitsOptions.maximumFractionDigits=parseInt(parts[5])),digitsOptions}var LocaleService=function(){function LocaleService(configuration,storage){this.configuration=configuration,this.storage=storage,this.languageCodeChanged=new rxjs.Subject,this.defaultLocaleChanged=new rxjs.Subject,this.currencyCodeChanged=new rxjs.Subject,this.timezoneChanged=new rxjs.Subject,this.defaultLocale=new DefaultLocale}return LocaleService.prototype.getConfiguration=function(){return this.configuration.locale},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.initLanguage()];case 1:return _a.sent(),[4,this.initDefaultLocale()];case 2:return _a.sent(),[4,this.initCurrency()];case 3:return _a.sent(),[4,this.initTimezone()];case 4:return _a.sent(),[2]}})})},LocaleService.prototype.getBrowserLanguage=function(){var browserLanguage=null;return"undefined"!=typeof navigator&&navigator.language&&(browserLanguage=navigator.language),null!=browserLanguage&&(browserLanguage=browserLanguage.split("-")[0]),browserLanguage},LocaleService.prototype.getAvailableLanguages=function(){var languages=[];return this.configuration.locale.languages&&(languages=this.configuration.locale.languages.map(function(language){return language.code})),languages},LocaleService.prototype.getLanguageDirection=function(languageCode){void 0===languageCode&&(languageCode=this.defaultLocale.languageCode);var matchedLanguage=this.matchLanguage(languageCode);return matchedLanguage?matchedLanguage.dir:""},LocaleService.prototype.getCurrentLanguage=function(){return this.defaultLocale.languageCode},LocaleService.prototype.getCurrentCountry=function(){return this.defaultLocale.countryCode||""},LocaleService.prototype.getCurrentScript=function(){return this.defaultLocale.scriptCode||""},LocaleService.prototype.getCurrentLocale=function(){var locale=this.defaultLocale.languageCode;return locale+=this.defaultLocale.scriptCode?"-"+this.defaultLocale.scriptCode:"",locale+=this.defaultLocale.countryCode?"-"+this.defaultLocale.countryCode:""},LocaleService.prototype.getCurrentNumberingSystem=function(){return this.defaultLocale.numberingSystem||""},LocaleService.prototype.getCurrentCalendar=function(){return this.defaultLocale.calendar||""},LocaleService.prototype.getDefaultLocale=function(){return this.defaultLocale.value},LocaleService.prototype.getCurrentCurrency=function(){return this.currencyCode},LocaleService.prototype.getCurrencySymbol=function(currencyDisplay,defaultLocale,currency){var currencySymbol=this.currencyCode;if(IntlAPI.hasNumberFormat()){var localeZero=this.formatDecimal(0,"1.0-0",defaultLocale);currencySymbol=(currencySymbol=this.formatCurrency(0,"1.0-0",currencyDisplay,defaultLocale,currency).replace(localeZero,"")).trim()}return currencySymbol},LocaleService.prototype.getCurrentTimezone=function(){return this.timezone},LocaleService.prototype.setCurrentLanguage=function(languageCode){this.defaultLocale.languageCode!=languageCode&&(this.rollbackLanguageCode=this.defaultLocale.languageCode,this.defaultLocale.build(languageCode),this.releaseLanguage())},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.rollbackDefaultLocale=this.defaultLocale.value,this.defaultLocale.build(languageCode,countryCode,scriptCode,numberingSystem,calendar),this.releaseDefaultLocale())},LocaleService.prototype.setCurrentCurrency=function(currencyCode){this.currencyCode!=currencyCode&&(this.rollbackCurrencyCode=this.currencyCode,this.currencyCode=currencyCode,this.releaseCurrency())},LocaleService.prototype.setCurrentTimezone=function(zoneName){this.timezone!=zoneName&&(this.rollbackTimezone=this.timezone,this.timezone=zoneName,this.releaseTimezone())},LocaleService.prototype.formatDate=function(value,format,defaultLocale,timezone){return IntlFormatter.formatDate(value,defaultLocale||this.defaultLocale.value,format||"mediumDate",timezone||this.timezone)},LocaleService.prototype.formatRelativeTime=function(value,unit,format,defaultLocale){return IntlFormatter.formatRelativeTime(value,unit,defaultLocale||this.defaultLocale.value,format)},LocaleService.prototype.formatDecimal=function(value,digits,defaultLocale){return IntlFormatter.formatNumber(value,defaultLocale||this.defaultLocale.value,NumberFormatStyle.Decimal,digits)},LocaleService.prototype.formatPercent=function(value,digits,defaultLocale){return IntlFormatter.formatNumber(value,defaultLocale||this.defaultLocale.value,NumberFormatStyle.Percent,digits)},LocaleService.prototype.formatCurrency=function(value,digits,currencyDisplay,defaultLocale,currency){return IntlFormatter.formatNumber(value,defaultLocale||this.defaultLocale.value,NumberFormatStyle.Currency,digits,currency||this.currencyCode,currencyDisplay||"symbol")},LocaleService.prototype.composeLocale=function(codes){var locale="";if(this.defaultLocale.languageCode)for(var _i=0,codes_1=codes;_i<codes_1.length;_i++){switch(codes_1[_i]){case ISOCode.Script:locale+="-"+this.defaultLocale.scriptCode;break;case ISOCode.Country:locale+="-"+this.defaultLocale.countryCode;break;default:locale+=this.defaultLocale.languageCode}}return locale},LocaleService.prototype.rollback=function(){this.rollbackLanguageCode&&this.rollbackLanguageCode!=this.defaultLocale.languageCode&&(this.defaultLocale.value=this.rollbackLanguageCode,this.releaseLanguage()),this.rollbackDefaultLocale&&this.rollbackDefaultLocale!=this.defaultLocale.value&&(this.defaultLocale.value=this.rollbackDefaultLocale,this.releaseDefaultLocale()),this.rollbackCurrencyCode&&this.rollbackCurrencyCode!=this.currencyCode&&(this.currencyCode=this.rollbackCurrencyCode,this.releaseCurrency()),this.rollbackTimezone&&this.rollbackTimezone!=this.timezone&&(this.timezone=this.rollbackTimezone,this.releaseTimezone())},LocaleService.prototype.initLanguage=function(){return __awaiter(this,void 0,void 0,function(){var defaultLocale,browserLanguage,matchedLanguage;return __generator(this,function(_a){switch(_a.label){case 0:return this.configuration.locale.language?this.defaultLocale.languageCode?[3,2]:[4,this.storage.read("defaultLocale")]:[3,2];case 1:(defaultLocale=_a.sent())?this.defaultLocale.value=defaultLocale:(browserLanguage=this.getBrowserLanguage(),matchedLanguage=this.matchLanguage(browserLanguage),browserLanguage&&matchedLanguage?this.defaultLocale.build(browserLanguage):this.defaultLocale.build(this.configuration.locale.language),this.storage.write("defaultLocale",this.defaultLocale.value)),this.rollbackLanguageCode=this.defaultLocale.languageCode,this.sendLanguageEvents(),_a.label=2;case 2:return[2]}})})},LocaleService.prototype.initDefaultLocale=function(){return __awaiter(this,void 0,void 0,function(){var defaultLocale;return __generator(this,function(_a){switch(_a.label){case 0:return this.configuration.locale.defaultLocale?this.defaultLocale.value?[3,2]:[4,this.storage.read("defaultLocale")]:[3,2];case 1:(defaultLocale=_a.sent())?this.defaultLocale.value=defaultLocale:(this.defaultLocale.build(this.configuration.locale.defaultLocale.languageCode,this.configuration.locale.defaultLocale.countryCode,this.configuration.locale.defaultLocale.scriptCode,this.configuration.locale.defaultLocale.numberingSystem,this.configuration.locale.defaultLocale.calendar),this.storage.write("defaultLocale",this.defaultLocale.value)),this.rollbackDefaultLocale=this.defaultLocale.value,this.sendDefaultLocaleEvents(),_a.label=2;case 2:return[2]}})})},LocaleService.prototype.initCurrency=function(){return __awaiter(this,void 0,void 0,function(){var currencyCode;return __generator(this,function(_a){switch(_a.label){case 0:return this.configuration.locale.currency?this.currencyCode?[3,2]:[4,this.storage.read("currency")]:[3,2];case 1:(currencyCode=_a.sent())?this.currencyCode=currencyCode:(this.currencyCode=this.configuration.locale.currency,this.storage.write("currency",this.currencyCode)),this.rollbackCurrencyCode=this.currencyCode,this.sendCurrencyEvents(),_a.label=2;case 2:return[2]}})})},LocaleService.prototype.initTimezone=function(){return __awaiter(this,void 0,void 0,function(){var zoneName;return __generator(this,function(_a){switch(_a.label){case 0:return this.configuration.locale.timezone?this.timezone?[3,2]:[4,this.storage.read("timezone")]:[3,2];case 1:(zoneName=_a.sent())?this.timezone=zoneName:(this.timezone=this.configuration.locale.timezone,this.storage.write("timezone",this.timezone)),this.rollbackTimezone=this.timezone,this.sendTimezoneEvents(),_a.label=2;case 2:return[2]}})})},LocaleService.prototype.matchLanguage=function(languageCode){var matchedLanguage;return this.configuration.locale.languages&&null!=languageCode&&(matchedLanguage=this.configuration.locale.languages.find(function(language){return language.code==languageCode})),matchedLanguage},LocaleService.prototype.releaseLanguage=function(){this.storage.write("defaultLocale",this.defaultLocale.value),this.sendLanguageEvents()},LocaleService.prototype.releaseDefaultLocale=function(){this.storage.write("defaultLocale",this.defaultLocale.value),this.sendDefaultLocaleEvents()},LocaleService.prototype.releaseCurrency=function(){this.storage.write("currency",this.currencyCode),this.sendCurrencyEvents()},LocaleService.prototype.releaseTimezone=function(){this.storage.write("timezone",this.timezone),this.sendTimezoneEvents()},LocaleService.prototype.sendLanguageEvents=function(){this.languageCodeChanged.next(this.defaultLocale.languageCode)},LocaleService.prototype.sendDefaultLocaleEvents=function(){this.defaultLocaleChanged.next(this.defaultLocale.value)},LocaleService.prototype.sendCurrencyEvents=function(){this.currencyCodeChanged.next(this.currencyCode)},LocaleService.prototype.sendTimezoneEvents=function(){this.timezoneChanged.next(this.timezone)},LocaleService.decorators=[{type:core.Injectable}],LocaleService.ctorParameters=function(){return[{type:void 0,decorators:[{type:core.Inject,args:[L10N_CONFIG]}]},{type:LocaleStorage}]},LocaleService}(),LocalizedRouting=function(){function LocalizedRouting(configuration,locale){this.configuration=configuration,this.locale=locale}return Object.defineProperty(LocalizedRouting.prototype,"router",{get:function(){return InjectorRef.get(router.Router)},enumerable:!0,configurable:!0}),Object.defineProperty(LocalizedRouting.prototype,"location",{get:function(){return InjectorRef.get(common.Location)},enumerable:!0,configurable:!0}),LocalizedRouting.prototype.init=function(){var _this=this;if(this.configuration.localizedRouting.format){var path=this.location.path(!0);this.parsePath(path),this.router.events.pipe(operators.filter(function(event){return event instanceof router.NavigationStart})).subscribe(function(data){_this.redirectToPath(data.url)}),this.router.events.pipe(operators.filter(function(event){return event instanceof router.NavigationEnd})).subscribe(function(data){var url=data.url&&"/"!=data.url&&data.url==data.urlAfterRedirects?data.url:data.urlAfterRedirects;_this.replacePath(_this.locale.composeLocale(_this.configuration.localizedRouting.format),url)}),this.locale.languageCodeChanged.subscribe(function(){_this.replacePath(_this.locale.composeLocale(_this.configuration.localizedRouting.format))}),this.locale.defaultLocaleChanged.subscribe(function(){_this.replacePath(_this.locale.composeLocale(_this.configuration.localizedRouting.format))})}},LocalizedRouting.prototype.parsePath=function(path){if(path){var segment=this.getLocalizedSegment(path);if(null!=segment){var locale=segment.replace(/\//gi,""),localeCodes=this.splitLocale(locale,this.configuration.localizedRouting.format);if(this.configuration.localizedRouting.schema&&!this.compareLocale(localeCodes,{languageCode:localeCodes.languageCode,scriptCode:this.getSchema(ISOCode.Script,localeCodes),countryCode:this.getSchema(ISOCode.Country,localeCodes)}))return;if(this.configuration.locale.language&&this.locale.setCurrentLanguage(localeCodes.languageCode),this.configuration.locale.defaultLocale&&this.locale.setDefaultLocale(localeCodes.languageCode,localeCodes.countryCode||this.getSchema(ISOCode.Country,localeCodes),localeCodes.scriptCode||this.getSchema(ISOCode.Script,localeCodes),this.getSchema(ExtraCode_NumberingSystem,localeCodes),this.getSchema(ExtraCode_Calendar,localeCodes)),this.configuration.locale.currency){var currency=this.getSchema(ExtraCode_Currency,localeCodes);currency&&this.locale.setCurrentCurrency(currency)}if(this.configuration.locale.timezone){var timezone=this.getSchema(ExtraCode_Timezone,localeCodes);timezone&&this.locale.setCurrentTimezone(timezone)}}}},LocalizedRouting.prototype.redirectToPath=function(path){var segment=this.getLocalizedSegment(path);if(null!=segment){var url=path.replace(segment,"/");this.router.navigateByUrl(url,{skipLocationChange:!0})}},LocalizedRouting.prototype.replacePath=function(locale,path){if(path)this.isDefaultRouting()||this.location.replaceState(this.getLocalizedPath(locale,path));else{path=this.location.path(!0);var segment=this.getLocalizedSegment(path);null!=segment&&(path=path.replace(segment,"/"),this.isDefaultRouting()&&this.location.replaceState(path)),this.isDefaultRouting()||this.location.replaceState(this.getLocalizedPath(locale,path))}},LocalizedRouting.prototype.getLocalizedSegment=function(path){for(var _i=0,_a=this.locale.getAvailableLanguages();_i<_a.length;_i++){var lang=_a[_i],regex=new RegExp("(/"+lang+"/)|(/"+lang+"$)|(/"+lang+"-.*?/)|(/"+lang+"-.*?$)"),segments=path.match(regex);if(null!=segments)return segments[0]}return null},LocalizedRouting.prototype.splitLocale=function(locale,codes){var values=locale.split("-"),localeCodes={languageCode:""};if(0<codes.length)for(var i=0;i<codes.length;i++)values[i]&&(localeCodes[codes[i]]=values[i]);return localeCodes},LocalizedRouting.prototype.compareLocale=function(locale1,locale2){return!(locale1.languageCode!=locale2.languageCode||locale1.scriptCode&&locale1.scriptCode!=locale2.scriptCode||locale1.countryCode&&locale1.countryCode!=locale2.countryCode)},LocalizedRouting.prototype.getSchema=function(code,locale){var _this=this;if(this.configuration.localizedRouting.schema){var schema=this.configuration.localizedRouting.schema.find(function(s){return _this.compareLocale(locale,s)});return schema?schema[code]:void 0}},LocalizedRouting.prototype.isDefaultRouting=function(){return!!this.configuration.localizedRouting.defaultRouting&&(this.configuration.locale.language?this.locale.getCurrentLanguage()==this.configuration.locale.language:!!this.configuration.locale.defaultLocale&&this.compareLocale({languageCode:this.locale.getCurrentLanguage(),scriptCode:this.locale.getCurrentScript(),countryCode:this.locale.getCurrentCountry()},this.configuration.locale.defaultLocale))},LocalizedRouting.prototype.getLocalizedPath=function(locale,path){return common.Location.stripTrailingSlash("/"+locale+path)},LocalizedRouting.decorators=[{type:core.Injectable}],LocalizedRouting.ctorParameters=function(){return[{type:void 0,decorators:[{type:core.Inject,args:[L10N_CONFIG]}]},{type:LocaleService}]},LocalizedRouting}(),TranslationProvider=function(){function TranslationProvider(){}return TranslationProvider.decorators=[{type:core.Injectable}],TranslationProvider}(),L10nTranslationProvider=function(){function L10nTranslationProvider(http$1,configuration,caching){this.http=http$1,this.configuration=configuration,this.caching=caching,this.headers=new http.HttpHeaders({"Content-Type":"application/json"}),this.options={}}return L10nTranslationProvider.prototype.getTranslation=function(language,args){this.setOptions();var url="";switch(args.type){case ProviderType.WebAPI:url+=args.path+language;break;default:url+=args.prefix+language+".json"}return this.getRequest(url)},L10nTranslationProvider.prototype.setOptions=function(){this.options={headers:this.headers,params:this.configuration.translation.version?(new http.HttpParams).set("ver",this.configuration.translation.version):void 0}},L10nTranslationProvider.prototype.getRequest=function(url){var request;return request=this.configuration.translation.timeout?this.http.get(url,this.options).pipe(operators.timeout(this.configuration.translation.timeout)):this.http.get(url,this.options),this.configuration.translation.caching?this.caching.read(url,request):request},L10nTranslationProvider.decorators=[{type:core.Injectable}],L10nTranslationProvider.ctorParameters=function(){return[{type:http.HttpClient,decorators:[{type:core.Optional}]},{type:void 0,decorators:[{type:core.Inject,args:[L10N_CONFIG]}]},{type:Caching}]},L10nTranslationProvider}(),TranslationHandler=function(){function TranslationHandler(){}return TranslationHandler.decorators=[{type:core.Injectable}],TranslationHandler}(),L10nTranslationHandler=function(){function L10nTranslationHandler(configuration){this.configuration=configuration}return L10nTranslationHandler.prototype.parseValue=function(path,key,value,args,lang){return null==value?this.handleMissingValue(path):args?this.handleArgs(value,args):value},L10nTranslationHandler.prototype.handleMissingValue=function(path){return null!=this.configuration.translation.missingValue?"function"==typeof this.configuration.translation.missingValue?this.configuration.translation.missingValue(path):this.configuration.translation.missingValue:path},L10nTranslationHandler.prototype.handleArgs=function(value,args){return value.replace(/{{\s?([^{}\s]*)\s?}}/g,function(substring,parsedKey){var replacer=args[parsedKey];return void 0!==replacer?replacer:substring})},L10nTranslationHandler.decorators=[{type:core.Injectable}],L10nTranslationHandler.ctorParameters=function(){return[{type:void 0,decorators:[{type:core.Inject,args:[L10N_CONFIG]}]}]},L10nTranslationHandler}();function isObject(item){return"object"==typeof item&&!Array.isArray(item)}var TranslationService=function(){function TranslationService(configuration,locale,translationProvider,translationHandler,injector){this.configuration=configuration,this.locale=locale,this.translationProvider=translationProvider,this.translationHandler=translationHandler,this.injector=injector,this.translationError=new rxjs.Subject,this.translation=new rxjs.BehaviorSubject(""),this.translationData={},this.injector.translations.push(this)}return TranslationService.prototype.getConfiguration=function(){return this.configuration.translation},TranslationService.prototype.init=function(){return __awaiter(this,void 0,void 0,function(){var _this=this;return __generator(this,function(_a){switch(_a.label){case 0:return rxjs.race(this.locale.languageCodeChanged,this.locale.defaultLocaleChanged).subscribe(function(){_this.loadTranslation().catch(function(error){return null})}),[4,this.loadTranslation().catch(function(error){throw error})];case 1:return _a.sent(),[2]}})})},TranslationService.prototype.loadTranslation=function(){return __awaiter(this,void 0,void 0,function(){var language;return __generator(this,function(_a){switch(_a.label){case 0:return(language=this.configuration.translation.composedLanguage?this.locale.composeLocale(this.configuration.translation.composedLanguage):this.locale.getCurrentLanguage())?(this.translationData={},this.configuration.translation.translationData&&this.getTranslation(language),this.configuration.translation.providers?[4,this.getTranslationAsync(language).toPromise().catch(function(error){throw error})]:[3,2]):[3,2];case 1:_a.sent(),_a.label=2;case 2:return[2]}})})},TranslationService.prototype.translationChanged=function(){return this.translation.asObservable()},TranslationService.prototype.latestTranslation=function(){for(var sequencesOfTranslation=[],_i=0,_a=this.injector.translations;_i<_a.length;_i++){var translation=_a[_i];sequencesOfTranslation.push(translation.translationChanged())}return rxjs.combineLatest(sequencesOfTranslation).pipe(operators.filter(function(languages){return languages.length==sequencesOfTranslation.length&&languages.every(function(lang,i,arr){return lang==arr[0]})}),operators.map(function(languages){return languages[0]}))},TranslationService.prototype.translate=function(keys,args,lang){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||this.translation.getValue())}return data}return this.translateKey(keys,args,lang||this.translation.getValue())},TranslationService.prototype.translateAsync=function(keys,args,lang){var _this=this;return new rxjs.Observable(function(observer){var values=_this.translate(keys,args,lang);observer.next(values),observer.complete()})},TranslationService.prototype.has=function(key,lang){void 0===lang&&(lang=this.translation.getValue());var path=key,translation={nested:this.translationData[lang]};return!!translation.nested&&(key=this.extractKey(translation,path),void 0!==translation.nested[key])},TranslationService.prototype.translateKey=function(key,args,lang){return this.configuration.translation.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,translation={nested:this.translationData[lang]},value=null;return translation.nested&&(key=this.extractKey(translation,path),value=void 0===translation.nested[key]?translation.nested[this.configuration.translation.missingKey||""]:translation.nested[key]),this.translationHandler.parseValue(path,key,value,args,lang)},TranslationService.prototype.extractKey=function(translation,path){if(!this.configuration.translation.composedKeySeparator)return path;for(var sequences=path.split(this.configuration.translation.composedKeySeparator),key=sequences.shift();0<sequences.length&&translation.nested[key];)translation.nested=translation.nested[key],key=sequences.shift();return key},TranslationService.prototype.translateI18nPlural=function(key,args,lang){var keyText=key.replace(/^\d+\b/,"");keyText=keyText.trim();var keyNumber=parseFloat(key);return isNaN(keyNumber)||(key=key.replace(/^\d+/,this.locale.formatDecimal(keyNumber))),key.replace(keyText,this.getValue(keyText,args,lang))},TranslationService.prototype.getTranslation=function(language){for(var _i=0,translations_1=this.configuration.translation.translationData.filter(function(value){return value.languageCode==language});_i<translations_1.length;_i++){var translation=translations_1[_i];this.addData(translation.data,language)}this.configuration.translation.providers||this.releaseTranslation(language)},TranslationService.prototype.getTranslationAsync=function(language){var _this=this;return new rxjs.Observable(function(observer){for(var sequencesOfOrderedTranslationData=[],sequencesOfTranslationData=[],_i=0,_a=_this.configuration.translation.providers;_i<_a.length;_i++){var provider=_a[_i];if(void 0!==provider.type&&provider.type==ProviderType.Fallback){var fallbackLanguage=language;provider.fallbackLanguage&&(fallbackLanguage=_this.locale.composeLocale(provider.fallbackLanguage)),sequencesOfOrderedTranslationData.push(_this.translationProvider.getTranslation(fallbackLanguage,provider))}else sequencesOfTranslationData.push(_this.translationProvider.getTranslation(language,provider))}var mergedSequencesOfTranslationData=rxjs.merge.apply(void 0,sequencesOfTranslationData);sequencesOfOrderedTranslationData.push(mergedSequencesOfTranslationData),rxjs.concat.apply(void 0,sequencesOfOrderedTranslationData).subscribe(function(data){_this.addData(data,language)},function(error){_this.handleError(error,language),observer.error(error),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]?function mergeDeep(target,source){var output=Object.assign({},target);return isObject(target)&&isObject(source)&&Object.keys(source).forEach(function(key){var _a,_b;isObject(source[key])?key in target?output[key]=mergeDeep(target[key],source[key]):Object.assign(output,((_a={})[key]=source[key],_a)):Object.assign(output,((_b={})[key]=source[key],_b))}),output}(this.translationData[language],data):data},TranslationService.prototype.releaseTranslation=function(language){this.translation.next(language)},TranslationService.prototype.handleError=function(error,language){this.configuration.translation.rollbackOnError?this.locale.rollback():this.releaseTranslation(language),this.translationError.next(error)},TranslationService.decorators=[{type:core.Injectable}],TranslationService.ctorParameters=function(){return[{type:void 0,decorators:[{type:core.Inject,args:[L10N_CONFIG]}]},{type:LocaleService},{type:TranslationProvider},{type:TranslationHandler},{type:InjectorRef}]},TranslationService}(),L10nLoader=function(){function L10nLoader(){}return L10nLoader.decorators=[{type:core.Injectable}],L10nLoader}(),LocaleLoader=function(){function LocaleLoader(locale,translation){this.locale=locale,this.translation=translation}return LocaleLoader.prototype.load=function(){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(_a){switch(_a.label){case 0:return[4,this.locale.init()];case 1:return _a.sent(),[4,this.translation.init().catch(function(error){throw error})];case 2:return _a.sent(),[2]}})})},LocaleLoader.decorators=[{type:core.Injectable}],LocaleLoader.ctorParameters=function(){return[{type:LocaleService},{type:TranslationService}]},LocaleLoader}(),TranslationLoader=function(){function TranslationLoader(translation){this.translation=translation}return TranslationLoader.prototype.load=function(){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(_a){switch(_a.label){case 0:return[4,this.translation.init().catch(function(error){throw error})];case 1:return _a.sent(),[2]}})})},TranslationLoader.decorators=[{type:core.Injectable}],TranslationLoader.ctorParameters=function(){return[{type:TranslationService}]},TranslationLoader}(),LocalizedRoutingLoader=function(){function LocalizedRoutingLoader(localizedRouting,locale,translation){this.localizedRouting=localizedRouting,this.locale=locale,this.translation=translation}return LocalizedRoutingLoader.prototype.load=function(){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(_a){switch(_a.label){case 0:return this.localizedRouting.init(),[4,this.locale.init()];case 1:return _a.sent(),[4,this.translation.init().catch(function(error){throw error})];case 2:return _a.sent(),[2]}})})},LocalizedRoutingLoader.decorators=[{type:core.Injectable}],LocalizedRoutingLoader.ctorParameters=function(){return[{type:LocalizedRouting},{type:LocaleService},{type:TranslationService}]},LocalizedRoutingLoader}();function takeUntilDestroyed(target){var destroy=new rxjs.Subject,targetNgOnDestroy=target.ngOnDestroy;return void 0===targetNgOnDestroy&&Logger.log(target.constructor?target.constructor.name:"takeUntilDestroyed","missingOnDestroy"),target.ngOnDestroy=function(){destroy.next(!0),destroy.complete(),targetNgOnDestroy&&targetNgOnDestroy.apply(this)},operators.takeUntil(destroy)}var Translation=function(){function Translation(changeDetectorRef){var _this=this;this.changeDetectorRef=changeDetectorRef,this.lang="",InjectorRef.get(TranslationService).latestTranslation().pipe(takeUntilDestroyed(this)).subscribe(function(language){_this.lang=language,_this.changeDetectorRef&&_this.changeDetectorRef.markForCheck()})}return Translation.prototype.ngOnDestroy=function(){},Translation.decorators=[{type:core.Injectable}],Translation.ctorParameters=function(){return[{type:core.ChangeDetectorRef}]},Translation}(),Localization=function(_super){function Localization(changeDetectorRef){var _this=_super.call(this)||this;_this.changeDetectorRef=changeDetectorRef,_this.defaultLocale="",_this.currency="",_this.timezone="";var locale=InjectorRef.get(LocaleService);return _this.defaultLocale=locale.getDefaultLocale(),locale.defaultLocaleChanged.pipe(takeUntilDestroyed(_this)).subscribe(function(defaultLocale){_this.defaultLocale=defaultLocale,_this.changeDetectorRef&&_this.changeDetectorRef.markForCheck()}),_this.currency=locale.getCurrentCurrency(),locale.currencyCodeChanged.pipe(takeUntilDestroyed(_this)).subscribe(function(currency){_this.currency=currency,_this.changeDetectorRef&&_this.changeDetectorRef.markForCheck()}),_this.timezone=locale.getCurrentTimezone(),locale.timezoneChanged.pipe(takeUntilDestroyed(_this)).subscribe(function(zoneName){_this.timezone=zoneName,_this.changeDetectorRef&&_this.changeDetectorRef.markForCheck()}),_this}return __extends(Localization,_super),Localization.decorators=[{type:core.Injectable}],Localization.ctorParameters=function(){return[{type:core.ChangeDetectorRef}]},Localization}(Translation),LocaleValidation=function(){function LocaleValidation(locale){this.locale=locale}return LocaleValidation.prototype.parseNumber=function(s,digits,defaultLocale){if(""==s||null==s)return null;if(s=s.replace(/\s/g," "),this.decimalCode=this.getDecimalCode(defaultLocale),this.numberCodes=this.getNumberCodes(defaultLocale),!this.validateNumber(s,digits))return NaN;for(var value="",_i=0,characters_1=s.split("");_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==this.decimalCode.minusSign)value+="-";else{if(charCode!=this.decimalCode.decimalSeparator){if(charCode==this.decimalCode.thousandSeparator)continue;return NaN}value+="."}}return parseFloat(value)},LocaleValidation.prototype.validateNumber=function(s,digits){var options={};if(digits){var digitsOptions=formatDigitsAliases(digits);null!=digitsOptions?options=digitsOptions:Logger.log("LocaleValidation","invalidNumberFormatAlias")}var minInt=void 0!==options.minimumIntegerDigits?options.minimumIntegerDigits:1,minFraction=void 0!==options.minimumFractionDigits?options.minimumFractionDigits:0,maxFraction=void 0!==options.maximumFractionDigits?options.maximumFractionDigits:3,minusSign=this.decimalCode.minusSign,zero=this.numberCodes[0],decimalSeparator=this.decimalCode.decimalSeparator,thousandSeparator=this.decimalCode.thousandSeparator,d="["+zero+"-"+this.numberCodes[9]+"]",n="{"+minInt+",}",nm="{"+minFraction+","+maxFraction+"}",pattern="^"+minusSign+"?("+(d+n)+"|"+("(?=(?:\\"+thousandSeparator+"*"+d+")"+n+"(\\"+decimalSeparator+"|$))(?!"+zero+"(?!\\"+decimalSeparator+"|"+d+"))"+d+"{1,3}(\\"+thousandSeparator+d+"{3})*")+")";return pattern+=0<minFraction&&0<maxFraction?"\\"+decimalSeparator+d+nm+"$":0==minFraction&&0<maxFraction?"(\\"+decimalSeparator+d+nm+")?$":"$",pattern=this.toChar(pattern),new RegExp(pattern).test(s)},LocaleValidation.prototype.getDecimalCode=function(defaultLocale){var decimalCode={minusSign:this.toUnicode("-"),decimalSeparator:this.toUnicode("."),thousandSeparator:this.toUnicode(",")};if(IntlAPI.hasNumberFormat()){for(var localeValue=this.locale.formatDecimal(-1000.9,"1.1-1",defaultLocale),unicodeChars=[],i=0;i<localeValue.length;i++){var unicodeChar=this.toUnicode(localeValue.charAt(i));unicodeChar=(unicodeChar=unicodeChar.replace("\\u202F","\\u0020")).replace("\\u00A0","\\u0020"),unicodeChars.push(unicodeChar)}var thousandSeparator=8<=localeValue.length,positions=void 0;decimalCode={minusSign:unicodeChars[(positions="\\u200F"==unicodeChars[0]||"\\u061C"==unicodeChars[0]?thousandSeparator?[1,7,3]:[1,6]:unicodeChars[0]==this.toUnicode(this.locale.formatDecimal(1,"1.0-0",defaultLocale))?thousandSeparator?[7,5,1]:[6,4]:"\\u200E"==unicodeChars[0]?thousandSeparator?[1,7,3]:[1,6]:thousandSeparator?[0,6,2]:[0,5])[0]],decimalSeparator:unicodeChars[positions[1]],thousandSeparator:thousandSeparator?unicodeChars[positions[2]]:""}}return decimalCode},LocaleValidation.prototype.getNumberCodes=function(defaultLocale){for(var numberCodes=[],num=0;num<=9;num++)numberCodes.push(this.toUnicode(num.toString()));if(IntlAPI.hasNumberFormat())for(num=0;num<=9;num++)numberCodes[num]=this.toUnicode(this.locale.formatDecimal(num,"1.0-0",defaultLocale));return numberCodes},LocaleValidation.prototype.toChar=function(pattern){return pattern.replace(/\\u[\dA-F]{4}/gi,function(match){return String.fromCharCode(parseInt(match.replace(/\\u/g,""),16))})},LocaleValidation.prototype.toUnicode=function(c){return"\\u"+this.toHex(c.charCodeAt(0))},LocaleValidation.prototype.toHex=function(value){var hex=value.toString(16).toUpperCase();return hex="0000".substr(0,4-hex.length)+hex},LocaleValidation.decorators=[{type:core.Injectable}],LocaleValidation.ctorParameters=function(){return[{type:LocaleService}]},LocaleValidation}(),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},Collator.prototype.sortAsync=function(list,keyName,order,extension,options){var _this=this;return void 0===options&&(options={usage:"sort",sensitivity:"variant"}),new rxjs.Observable(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"}),new rxjs.Observable(fu