angular-l10n
Advanced tools
Comparing version 2.0.9 to 2.0.10
@@ -1,2 +0,2 @@ | ||
(function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?factory(exports,require("@angular/core"),require("@angular/http"),require("rxjs/Observable"),require("rxjs/add/operator/map"),require("rxjs/add/observable/merge"),require("@angular/common"),require("@angular/forms")):typeof define==="function"&&define.amd?define(["exports","@angular/core","@angular/http","rxjs/Observable","rxjs/add/operator/map","rxjs/add/observable/merge","@angular/common","@angular/forms"],factory):factory((global.ng=global.ng||{},global.ng.l10n=global.ng.l10n||{}),global.ng.core,global.ng.http,global.Rx,global.Rx,global.Rx,global.ng.common,global.ng.forms)})(this,function(exports,_angular_core,_angular_http,rxjs_Observable,rxjs_add_operator_map,rxjs_add_observable_merge,_angular_common,_angular_forms){"use strict";var LocaleConfig=function(){function LocaleConfig(locale){this.locale=locale}LocaleConfig.prototype.AddLanguage=function(languageCode,textDirection){if(textDirection===void 0){textDirection="LTR"}var language={code:languageCode,direction:textDirection};this.locale.configuration.languageCodes.push(language);return this};LocaleConfig.prototype.AddLanguages=function(languageCodes){for(var _i=0,languageCodes_1=languageCodes;_i<languageCodes_1.length;_i++){var languageCode=languageCodes_1[_i];var language={code:languageCode,direction:"ltr"};this.locale.configuration.languageCodes.push(language)}return this};LocaleConfig.prototype.DisableStorage=function(){this.locale.configuration.storageIsDisabled=true;return this};LocaleConfig.prototype.SetCookieExpiration=function(days){if(days===void 0){days=null}this.locale.configuration.cookiesExpirationDays=days;return this};LocaleConfig.prototype.UseLocalStorage=function(){this.locale.configuration.localStorage=true;return this};LocaleConfig.prototype.DefineLanguage=function(languageCode){this.locale.configuration.languageCode=languageCode;return this};LocaleConfig.prototype.DefineDefaultLocale=function(languageCode,countryCode,scriptCode,numberingSystem,calendar){this.locale.configuration.languageCode=languageCode;this.locale.configuration.countryCode=countryCode;this.locale.configuration.scriptCode=scriptCode;this.locale.configuration.numberingSystem=numberingSystem;this.locale.configuration.calendar=calendar;return this};LocaleConfig.prototype.DefineCurrency=function(currencyCode){this.locale.configuration.currencyCode=currencyCode;return this};return LocaleConfig}();var DefaultLocaleCodes=function(){function DefaultLocaleCodes(){}return DefaultLocaleCodes}();var __extends$1=undefined&&undefined.__extends||function(d,b){for(var p in b)if(b.hasOwnProperty(p))d[p]=b[p];function __(){this.constructor=d}d.prototype=b===null?Object.create(b):(__.prototype=b.prototype,new __)};var Codes=function(_super){__extends$1(Codes,_super);function Codes(){_super.apply(this,arguments)}return Codes}(DefaultLocaleCodes);var __extends=undefined&&undefined.__extends||function(d,b){for(var p in b)if(b.hasOwnProperty(p))d[p]=b[p];function __(){this.constructor=d}d.prototype=b===null?Object.create(b):(__.prototype=b.prototype,new __)};var Config=function(_super){__extends(Config,_super);function Config(){_super.apply(this,arguments);this.languageCodes=[];this.storageIsDisabled=false;this.localStorage=false}return Config}(Codes);var __extends$2=undefined&&undefined.__extends||function(d,b){for(var p in b)if(b.hasOwnProperty(p))d[p]=b[p];function __(){this.constructor=d}d.prototype=b===null?Object.create(b):(__.prototype=b.prototype,new __)};var DefaultLocale=function(_super){__extends$2(DefaultLocale,_super);function DefaultLocale(){_super.apply(this,arguments)}Object.defineProperty(DefaultLocale.prototype,"value",{get:function(){return this._value},set:function(defaultLocale){this._value=defaultLocale;this.parseValue()},enumerable:true,configurable:true});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;var index=value.search("-u");if(index!=-1){var extensions=value.substring(index+1).split("-");switch(extensions.length){case 3:if(extensions[1]=="nu"){this.numberingSystem=extensions[2]}else if(extensions[1]=="ca"){this.calendar=extensions[2]}break;default:this.numberingSystem=extensions[2];this.calendar=extensions[4];break}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];break}}};return DefaultLocale}(DefaultLocaleCodes);var Browser=function(){function Browser(locale){this.locale=locale;this.hasCookie=typeof navigator!=="undefined"&&typeof navigator.cookieEnabled!=="undefined"&&navigator.cookieEnabled;this.hasLocalStorage=typeof Storage!=="undefined"}Browser.prototype.readStorage=function(name){var value;if(!this.storageIsDisabled){if(this.locale.configuration.localStorage&&this.hasLocalStorage){value=this.getLocalStorage(name)}else if(this.hasCookie){value=this.getCookie(name)}}return value};Browser.prototype.writeStorage=function(name,value){if(!this.storageIsDisabled){if(this.locale.configuration.localStorage&&this.hasLocalStorage){this.setLocalStorage(name,value)}else if(this.hasCookie){this.setCookie(name,value)}}};Browser.prototype.getBrowserLanguage=function(){var browserLanguage;if(typeof navigator!=="undefined"&&typeof navigator.language!=="undefined"){browserLanguage=navigator.language}if(browserLanguage!=null){var index=browserLanguage.indexOf("-");if(index!=-1){browserLanguage=browserLanguage.substring(0,index)}}return browserLanguage};Browser.prototype.getLocalStorage=function(name){return localStorage.getItem(name)};Browser.prototype.getCookie=function(name){var result;if(typeof document!=="undefined"){result=new RegExp("(?:^|; )"+encodeURIComponent(name)+"=([^;]*)").exec(document.cookie)}return result?result[1]:null};Browser.prototype.setLocalStorage=function(name,value){localStorage.setItem(name,value)};Browser.prototype.setCookie=function(name,value){var expires="";if(this.locale.configuration.cookiesExpirationDays!=null){var expirationDate=new Date;expirationDate.setTime(expirationDate.getTime()+this.locale.configuration.cookiesExpirationDays*24*60*60*1e3);expires="; expires="+expirationDate.toUTCString()}if(typeof document!=="undefined"){document.cookie=name+"="+value+expires+"; path=/"}};return Browser}();var LocaleService=function(){function LocaleService(){this.languageCodeChanged=new _angular_core.EventEmitter(true);this.defaultLocaleChanged=new _angular_core.EventEmitter(true);this.currencyCodeChanged=new _angular_core.EventEmitter(true);this.loadTranslation=new _angular_core.EventEmitter(true);this._configuration=new Config;this.defaultLocale=new DefaultLocale;this.browser=new Browser(this)}Object.defineProperty(LocaleService.prototype,"configuration",{get:function(){return this._configuration},enumerable:true,configurable:true});LocaleService.prototype.AddConfiguration=function(){return new LocaleConfig(this)};LocaleService.prototype.init=function(){this.initStorage();if(!!this.configuration.languageCode&&!!this.configuration.countryCode){this.initDefaultLocale()}else if(!!this.configuration.languageCode){this.initLanguage()}if(!!this.configuration.currencyCode){this.initCurrency()}};LocaleService.prototype.getAvailableLanguages=function(){return this.configuration.languageCodes.map(function(language){return language.code})};LocaleService.prototype.getLanguageDirection=function(languageCode){if(languageCode===void 0){languageCode=this.defaultLocale.languageCode}var matchedLanguages=this.matchLanguage(languageCode);return matchedLanguages[0].direction};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.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.setCurrentLanguage=function(languageCode){if(this.defaultLocale.languageCode!=languageCode){this.defaultLocale.build(languageCode);this.browser.writeStorage("locale",this.defaultLocale.value);this.sendLanguageEvents();this.sendTranslationEvents()}};LocaleService.prototype.setDefaultLocale=function(languageCode,countryCode,scriptCode,numberingSystem,calendar){if(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.browser.writeStorage("locale",this.defaultLocale.value);this.sendDefaultLocaleEvents();this.sendTranslationEvents()}};LocaleService.prototype.setCurrentCurrency=function(currencyCode){if(this.currencyCode!=currencyCode){this.currencyCode=currencyCode;this.browser.writeStorage("currency",this.currencyCode);this.sendCurrencyEvents()}};LocaleService.prototype.initStorage=function(){this.browser.storageIsDisabled=this.configuration.storageIsDisabled;this.defaultLocale.value=this.browser.readStorage("locale");this.currencyCode=this.browser.readStorage("currency")};LocaleService.prototype.initLanguage=function(){if(this.defaultLocale.languageCode==null){var browserLanguage=this.browser.getBrowserLanguage();var matchedLanguages=this.matchLanguage(browserLanguage);if(matchedLanguages.length>0){this.defaultLocale.build(browserLanguage)}else{this.defaultLocale.build(this.configuration.languageCode)}this.browser.writeStorage("locale",this.defaultLocale.value)}this.sendLanguageEvents()};LocaleService.prototype.matchLanguage=function(languageCode){var matchedLanguages=this.configuration.languageCodes.filter(function(language){return language.code==languageCode});return matchedLanguages};LocaleService.prototype.initDefaultLocale=function(){if(this.defaultLocale.value==null){this.defaultLocale.build(this.configuration.languageCode,this.configuration.countryCode,this.configuration.scriptCode,this.configuration.numberingSystem,this.configuration.calendar);this.browser.writeStorage("locale",this.defaultLocale.value)}this.sendDefaultLocaleEvents()};LocaleService.prototype.initCurrency=function(){if(this.currencyCode==null){this.currencyCode=this.configuration.currencyCode;this.browser.writeStorage("currency",this.currencyCode)}this.sendCurrencyEvents()};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.emit(null)};LocaleService.decorators=[{type:_angular_core.Injectable}];LocaleService.ctorParameters=function(){return[]};LocaleService.propDecorators={languageCodeChanged:[{type:_angular_core.Output}],defaultLocaleChanged:[{type:_angular_core.Output}],currencyCodeChanged:[{type:_angular_core.Output}],loadTranslation:[{type:_angular_core.Output}]};return LocaleService}();var IntlAPI=function(){function IntlAPI(){}IntlAPI.HasDateTimeFormat=function(){var hasIntl=Intl&&typeof Intl==="object";return hasIntl&&Intl.hasOwnProperty("DateTimeFormat")};IntlAPI.HasNumberFormat=function(){var hasIntl=Intl&&typeof Intl==="object";return hasIntl&&Intl.hasOwnProperty("NumberFormat")};IntlAPI.HasCollator=function(){var hasIntl=Intl&&typeof Intl==="object";return hasIntl&&Intl.hasOwnProperty("Collator")};return IntlAPI}();var TranslationConfig=function(){function TranslationConfig(translation){this.translation=translation}TranslationConfig.prototype.AddTranslation=function(languageCode,translation){this.translation.addData(translation,languageCode);return this};TranslationConfig.prototype.AddProvider=function(prefix,dataFormat){if(dataFormat===void 0){dataFormat="json"}this.translation.configuration.providers.push({path:prefix,dataFormat:"json",webAPI:false});return this};TranslationConfig.prototype.AddWebAPIProvider=function(path,dataFormat){if(dataFormat===void 0){dataFormat="json"}this.translation.configuration.providers.push({path:path,dataFormat:dataFormat,webAPI:true});return this};TranslationConfig.prototype.UseLocaleAsLanguage=function(){this.translation.configuration.localeAsLanguage=true;return this};TranslationConfig.prototype.SetMissingValue=function(value){this.translation.configuration.missingValue=value;return this};TranslationConfig.prototype.SetMissingKey=function(key){this.translation.configuration.missingKey=key;return this};TranslationConfig.prototype.SetComposedKeySeparator=function(keySeparator){this.translation.configuration.keySeparator=keySeparator;return this};return TranslationConfig}();var Config$1=function(){function Config(){this.providers=[];this.localeAsLanguage=false;this.keySeparator="."}return Config}();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 TranslationService=function(){function TranslationService(locale,http){var _this=this;this.locale=locale;this.http=http;this.translationChanged=new _angular_core.EventEmitter(true);this.translationError=new _angular_core.EventEmitter(true);this._configuration=new Config$1;this.translationData={};this.serviceState=ServiceState.isWaiting;this.locale.loadTranslation.subscribe(function(){_this.loadTranslation()})}Object.defineProperty(TranslationService.prototype,"configuration",{get:function(){return this._configuration},enumerable:true,configurable:true});TranslationService.prototype.AddConfiguration=function(){return new TranslationConfig(this)};TranslationService.prototype.init=function(){if(this.configuration.providers.length>0){this.loadingMode=LoadingMode.Async}else{this.loadingMode=LoadingMode.Direct}this.loadTranslation()};TranslationService.prototype.getLanguage=function(){return this.language};TranslationService.prototype.translate=function(key,args,lang){if(args===void 0){args=null}if(lang===void 0){lang=this.language}if(key==null||key==""){return""}if(/^\d+\b/.exec(key)){return this.translateI18nPlural(key,args,lang)}return this.getValue(key,args,lang)};TranslationService.prototype.translateAsync=function(key,args,lang){var _this=this;if(lang===void 0){lang=this.language}return rxjs_Observable.Observable.create(function(observer){var value=_this.translate(key,args,lang);observer.next(value);observer.complete()})};TranslationService.prototype.addData=function(data,languageCode){this.translationData[languageCode]=typeof this.translationData[languageCode]!=="undefined"?this.extend(this.translationData[languageCode],data):data};TranslationService.prototype.translateI18nPlural=function(key,args,lang){var keyText=key.replace(/^\d+\b/,"");keyText=keyText.trim();var keyNumber=parseFloat(key);key=key.replace(/^\d+/,this.translateNumber(keyNumber));return key.replace(keyText,this.getValue(keyText,args,lang))};TranslationService.prototype.getValue=function(key,args,lang){var value;if(this.translationData[lang]){var translation=this.translationData[lang];var keys=key.split(this.configuration.keySeparator);do{key=keys.shift();if(translation[key]&&typeof translation[key]==="object"){translation=translation[key]}}while(keys.length>0);value=translation[key]}return this.parseValue(key,value,args,lang)};TranslationService.prototype.translateNumber=function(keyNumber){if(!isNaN(keyNumber)&&IntlAPI.HasNumberFormat()){var localeNumber=new Intl.NumberFormat(this.language).format(keyNumber);return localeNumber}return keyNumber.toString()};TranslationService.prototype.parseValue=function(key,value,args,lang){if(value==null){return this.handleMissingValue(key,args,lang)}else if(args){return this.handleArgs(value,args)}return value};TranslationService.prototype.handleMissingValue=function(key,args,lang){if(this.configuration.missingKey!=null){return this.translate(this.configuration.missingKey,args,lang)}else if(this.configuration.missingValue!=null){return this.configuration.missingValue}return key};TranslationService.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 typeof replacer!=="undefined"?replacer:substring})};TranslationService.prototype.loadTranslation=function(){var language=!this.configuration.localeAsLanguage?this.locale.getCurrentLanguage():this.locale.getCurrentLanguage()+"-"+this.locale.getCurrentCountry();if(language!=null&&language!=this.language){if(this.loadingMode==LoadingMode.Async){this.getTranslation(language)}else{this.releaseTranslation(language)}}};TranslationService.prototype.getTranslation=function(language){var _this=this;this.translationData={};this.serviceState=ServiceState.isLoading;var observableSequencesOfTranslationData=[];for(var _i=0,_a=this.configuration.providers;_i<_a.length;_i++){var provider=_a[_i];var url=provider.path;if(provider.webAPI){url+=language}else{url+=language+"."+provider.dataFormat}observableSequencesOfTranslationData.push(this.getTranslationByProvider(url))}rxjs_Observable.Observable.merge.apply(rxjs_Observable.Observable,observableSequencesOfTranslationData).subscribe(function(data){_this.addData(data,language)},function(error){_this.translationError.emit(error);_this.releaseTranslation(language)},function(){_this.releaseTranslation(language)})};TranslationService.prototype.getTranslationByProvider=function(url){return this.http.get(url).map(function(res){return res.json()})};TranslationService.prototype.extend=function(){var args=[];for(var _i=0;_i<arguments.length;_i++){args[_i-0]=arguments[_i]}var newObj={};for(var _a=0,args_1=args;_a<args_1.length;_a++){var obj=args_1[_a];for(var key in obj){newObj[key]=obj[key]}}return newObj};TranslationService.prototype.releaseTranslation=function(language){this.serviceState=ServiceState.isReady;this.language=language;this.translationChanged.emit(language)};TranslationService.decorators=[{type:_angular_core.Injectable}];TranslationService.ctorParameters=function(){return[{type:LocaleService},{type:_angular_http.Http}]};TranslationService.propDecorators={translationChanged:[{type:_angular_core.Output}],translationError:[{type:_angular_core.Output}]};return TranslationService}();var Translation=function(){function Translation(translation,changeDetectorRef){var _this=this;this.translation=translation;this.changeDetectorRef=changeDetectorRef;this.pipesSubscriptions=[];this.lang=this.translation.getLanguage();this.pipesSubscriptions.push(this.translation.translationChanged.subscribe(function(language){_this.lang=language;if(_this.changeDetectorRef){_this.changeDetectorRef.markForCheck()}}))}Translation.prototype.ngOnDestroy=function(){this.cancelPipesSubscriptions()};Translation.prototype.cancelPipesSubscriptions=function(){this.pipesSubscriptions.forEach(function(subscription){if(typeof subscription!=="undefined"){subscription.unsubscribe()}})};return Translation}();var __extends$3=undefined&&undefined.__extends||function(d,b){for(var p in b)if(b.hasOwnProperty(p))d[p]=b[p];function __(){this.constructor=d}d.prototype=b===null?Object.create(b):(__.prototype=b.prototype,new __)};var Localization=function(_super){__extends$3(Localization,_super);function Localization(locale,translation,changeDetectorRef){var _this=this;_super.call(this,translation,changeDetectorRef);this.locale=locale;this.translation=translation;this.changeDetectorRef=changeDetectorRef;this.defaultLocale=this.locale.getDefaultLocale();this.pipesSubscriptions.push(this.locale.defaultLocaleChanged.subscribe(function(defaultLocale){_this.defaultLocale=defaultLocale;if(_this.changeDetectorRef){_this.changeDetectorRef.markForCheck()}}));this.currency=this.locale.getCurrentCurrency();this.pipesSubscriptions.push(this.locale.currencyCodeChanged.subscribe(function(currency){_this.currency=currency;if(_this.changeDetectorRef){_this.changeDetectorRef.markForCheck()}}))}return Localization}(Translation);var NumberCode=function(){function NumberCode(defaultLocale){this.defaultLocale=defaultLocale;this.numbersCodes=[];for(var num=0;num<=9;num++){this.numbersCodes.push(this.Unicode(num.toString()))}if(IntlAPI.HasNumberFormat()){for(var num=0;num<=9;num++){this.numbersCodes[num]=this.Unicode(new Intl.NumberFormat(defaultLocale).format(num))}}}NumberCode.prototype.parse=function(s){};NumberCode.prototype.UnicodeToChar=function(pattern){return pattern.replace(/\\u[\dA-F]{4}/gi,function(match){return String.fromCharCode(parseInt(match.replace(/\\u/g,""),16))})};NumberCode.prototype.Unicode=function(c){return"\\u"+this.HexEncode(c.charCodeAt(0))};NumberCode.prototype.HexEncode=function(value){var hex=value.toString(16).toUpperCase();hex="0000".substr(0,4-hex.length)+hex;return hex};return NumberCode}();var __extends$4=undefined&&undefined.__extends||function(d,b){for(var p in b)if(b.hasOwnProperty(p))d[p]=b[p];function __(){this.constructor=d}d.prototype=b===null?Object.create(b):(__.prototype=b.prototype,new __)};var DecimalCode=function(_super){__extends$4(DecimalCode,_super);function DecimalCode(defaultLocale){_super.call(this,defaultLocale);this.defaultLocale=defaultLocale;this.minusSignCode=this.Unicode("-");this.decimalSeparatorCode=this.Unicode(".");if(IntlAPI.HasNumberFormat()){var value=-.9;var localeValue=new Intl.NumberFormat(defaultLocale).format(value);if(this.Unicode(localeValue.charAt(0))=="\\u200F"){this.minusSignCode=this.Unicode(localeValue.charAt(1));this.decimalSeparatorCode=this.Unicode(localeValue.charAt(3))}else if(this.Unicode(localeValue.charAt(0))==this.Unicode(new Intl.NumberFormat(defaultLocale).format(0))){this.minusSignCode=this.Unicode(localeValue.charAt(3));this.decimalSeparatorCode=this.Unicode(localeValue.charAt(1))}else{this.minusSignCode=this.Unicode(localeValue.charAt(0));this.decimalSeparatorCode=this.Unicode(localeValue.charAt(2))}}}DecimalCode.prototype.parse=function(s){var characters=s.split("");var value="";for(var _i=0,characters_1=characters;_i<characters_1.length;_i++){var char=characters_1[_i];var charCode=this.Unicode(char);var index=this.numbersCodes.indexOf(charCode);if(index!=-1){value+=index}else if(charCode==this.minusSignCode){value+="-"}else if(charCode==this.decimalSeparatorCode){value+="."}else{return NaN}}return parseFloat(value)};return DecimalCode}(NumberCode);var LocaleValidation=function(){function LocaleValidation(locale){this.locale=locale}LocaleValidation.prototype.parseNumber=function(s){if(s==""){return null}var decimalCode=new DecimalCode(this.locale.getDefaultLocale());return decimalCode.parse(s)};LocaleValidation.decorators=[{type:_angular_core.Injectable}];LocaleValidation.ctorParameters=function(){return[{type:LocaleService}]};return LocaleValidation}();var Collator=function(){function Collator(translation){this.translation=translation}Collator.prototype.compare=function(key1,key2,extension,options){if(options===void 0){options={usage:"sort",sensitivity:"variant"}}if(!IntlAPI.HasCollator()){return 0}var value1=this.translation.translate(key1);var value2=this.translation.translate(key2);var locale=this.addExtension(this.translation.getLanguage(),extension);return new Intl.Collator(locale,options).compare(value1,value2)};Collator.prototype.sort=function(list,keyName,order,extension,options){var _this=this;if(order===void 0){order="asc"}if(options===void 0){options={usage:"sort",sensitivity:"variant"}}if(!list||!keyName||!IntlAPI.HasCollator()){return list}list.sort(function(key1,key2){return _this.compare(key1[keyName],key2[keyName],extension,options)});if(order=="desc"){list.reverse()}return list};Collator.prototype.sortAsync=function(list,keyName,order,extension,options){var _this=this;if(options===void 0){options={usage:"sort",sensitivity:"variant"}}return 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(options===void 0){options={usage:"search"}}if(!list||!keyNames||s==""||s==null||!IntlAPI.HasCollator()){return list}var locale=this.translation.getLanguage();var collator=new Intl.Collator(locale,options);var matches=list.filter(function(key){var found=false;for(var i=0;i<keyNames.length;i++){if(_this.match(key[keyNames[i]],s,collator)){found=true;break}}return found});return matches};Collator.prototype.searchAsync=function(s,list,keyNames,options){var _this=this;if(options===void 0){options={usage:"search"}}return rxjs_Observable.Observable.create(function(observer){observer.next(_this.search(s,list,keyNames,options));observer.complete()})};Collator.prototype.addExtension=function(locale,extension){if(!!extension){locale=locale+"-u-"+extension}return locale};Collator.prototype.match=function(key,s,collator){var value=this.translation.translate(key);var valueLength=value.length;var sLength=s.length;if(sLength>valueLength){return false}if(sLength==valueLength){return collator.compare(value,s)==0}var found=false;for(var i=0;i<valueLength-(sLength-1);i++){var str=value.substr(i,sLength);if(collator.compare(str,s)==0){found=true;break}}return found};Collator.decorators=[{type:_angular_core.Injectable}];Collator.ctorParameters=function(){return[{type:TranslationService}]};return Collator}();var TranslatePipe=function(){function TranslatePipe(translation){this.translation=translation}TranslatePipe.prototype.transform=function(key,lang){var args=[];for(var _i=2;_i<arguments.length;_i++){args[_i-2]=arguments[_i]}if(this.translation.serviceState==ServiceState.isReady){return this.translation.translate(key,args[0],lang)}return""};TranslatePipe.decorators=[{type:_angular_core.Pipe,args:[{name:"translate",pure:true}]}];TranslatePipe.ctorParameters=function(){return[{type:TranslationService}]};return TranslatePipe}();var LocaleDatePipe=function(){function LocaleDatePipe(){}LocaleDatePipe.prototype.transform=function(value,defaultLocale,pattern){if(pattern===void 0){pattern="mediumDate"}if(IntlAPI.HasDateTimeFormat()){var localeDate=new _angular_common.DatePipe(defaultLocale);return localeDate.transform(value,pattern)}return value};LocaleDatePipe.decorators=[{type:_angular_core.Pipe,args:[{name:"localeDate",pure:true}]}];LocaleDatePipe.ctorParameters=function(){return[]};return LocaleDatePipe}();var LocaleDecimalPipe=function(){function LocaleDecimalPipe(){}LocaleDecimalPipe.prototype.transform=function(value,defaultLocale,digits){if(digits===void 0){digits=null}if(IntlAPI.HasNumberFormat()){var localeDecimal=new _angular_common.DecimalPipe(defaultLocale);return localeDecimal.transform(value,digits)}return value};LocaleDecimalPipe.decorators=[{type:_angular_core.Pipe,args:[{name:"localeDecimal",pure:true}]}];LocaleDecimalPipe.ctorParameters=function(){return[]};return LocaleDecimalPipe}();var LocalePercentPipe=function(){function LocalePercentPipe(){}LocalePercentPipe.prototype.transform=function(value,defaultLocale,digits){if(digits===void 0){digits=null}if(IntlAPI.HasNumberFormat()){var localePercent=new _angular_common.PercentPipe(defaultLocale);return localePercent.transform(value,digits)}return value};LocalePercentPipe.decorators=[{type:_angular_core.Pipe,args:[{name:"localePercent",pure:true}]}];LocalePercentPipe.ctorParameters=function(){return[]};return LocalePercentPipe}();var LocaleCurrencyPipe=function(){function LocaleCurrencyPipe(){}LocaleCurrencyPipe.prototype.transform=function(value,defaultLocale,currency,symbolDisplay,digits){if(symbolDisplay===void 0){symbolDisplay=false}if(digits===void 0){digits=null}if(IntlAPI.HasNumberFormat()){var localeCurrency=new _angular_common.CurrencyPipe(defaultLocale);return localeCurrency.transform(value,currency,symbolDisplay,digits)}return value+" "+currency};LocaleCurrencyPipe.decorators=[{type:_angular_core.Pipe,args:[{name:"localeCurrency",pure:true}]}];LocaleCurrencyPipe.ctorParameters=function(){return[]};return LocaleCurrencyPipe}();var BFS=function(){function BFS(){}BFS.getTargetNode=function(rootNode){return this.walk(rootNode)};BFS.walk=function(rootNode){var queue=[];var iNode;queue.push(rootNode);while(queue.length>0){iNode=queue.shift();if(this.isTargetNode(iNode)){return iNode}if(iNode.childNodes!=null){for(var _i=0,_a=iNode.childNodes;_i<_a.length;_i++){var child=_a[_i];queue.push(child)}}}return null};BFS.isTargetNode=function(node){return typeof node!=="undefined"&&node.nodeValue!=null&&node.nodeValue.trim()!=""&&node.nodeType==3};return BFS}();var BaseDirective=function(){function BaseDirective(el,renderer){this.el=el;this.renderer=renderer;this.subscriptions=[];this.MUTATION_CONFIG={subtree:true,characterData:true}}Object.defineProperty(BaseDirective.prototype,"value",{set:function(valueAttribute){this.valueAttribute=valueAttribute},enumerable:true,configurable:true});BaseDirective.prototype.ngAfterViewInit=function(){this.element=this.el.nativeElement;this.renderNode=BFS.getTargetNode(this.element);this.getKey();if(!!this.key){this.setup()}};BaseDirective.prototype.ngOnChanges=function(changes){if(!!this.key){if(this.element.childNodes.length==0&&!!this.valueAttribute){this.key=this.valueAttribute}this.replace()}};BaseDirective.prototype.ngOnDestroy=function(){this.removeTextListener();this.cancelSubscriptions()};BaseDirective.prototype.setup=function(){};BaseDirective.prototype.replace=function(){};BaseDirective.prototype.setText=function(value){if(!!this.nodeValue){this.removeTextListener();this.renderer.setText(this.renderNode,this.nodeValue.replace(this.key,value));this.addTextListener()}else if(!!this.valueAttribute){this.renderer.setElementAttribute(this.element,"value",value)}};BaseDirective.prototype.addTextListener=function(){var _this=this;if(typeof MutationObserver!=="undefined"){this.textObserver=new MutationObserver(function(mutations){_this.getKey();if(!!_this.key){_this.replace()}});this.textObserver.observe(this.renderNode,this.MUTATION_CONFIG)}};BaseDirective.prototype.removeTextListener=function(){if(typeof this.textObserver!=="undefined"){this.textObserver.disconnect()}};BaseDirective.prototype.getText=function(){this.nodeValue=this.renderNode!=null?this.renderNode.nodeValue:null;return this.nodeValue!=null?this.nodeValue.trim():null};BaseDirective.prototype.getKey=function(){if(this.element.childNodes.length>0){this.key=this.getText()}else if(!!this.valueAttribute){this.key=this.valueAttribute}};BaseDirective.prototype.cancelSubscriptions=function(){this.subscriptions.forEach(function(subscription){if(typeof subscription!=="undefined"){subscription.unsubscribe()}})};BaseDirective.propDecorators={value:[{type:_angular_core.Input}]};return BaseDirective}();var __extends$5=undefined&&undefined.__extends||function(d,b){ | ||
for(var p in b)if(b.hasOwnProperty(p))d[p]=b[p];function __(){this.constructor=d}d.prototype=b===null?Object.create(b):(__.prototype=b.prototype,new __)};var TranslateDirective=function(_super){__extends$5(TranslateDirective,_super);function TranslateDirective(translation,el,renderer){_super.call(this,el,renderer);this.translation=translation;this.el=el;this.renderer=renderer}TranslateDirective.prototype.setup=function(){var _this=this;this.replace();this.subscriptions.push(this.translation.translationChanged.subscribe(function(){_this.replace()}))};TranslateDirective.prototype.replace=function(){var _this=this;this.subscriptions.push(this.translation.translateAsync(this.key,this.params).subscribe(function(value){_this.setText(value)}))};TranslateDirective.decorators=[{type:_angular_core.Directive,args:[{selector:"[translate]"}]}];TranslateDirective.ctorParameters=function(){return[{type:TranslationService},{type:_angular_core.ElementRef},{type:_angular_core.Renderer}]};TranslateDirective.propDecorators={params:[{type:_angular_core.Input,args:["translate"]}]};return TranslateDirective}(BaseDirective);var __extends$6=undefined&&undefined.__extends||function(d,b){for(var p in b)if(b.hasOwnProperty(p))d[p]=b[p];function __(){this.constructor=d}d.prototype=b===null?Object.create(b):(__.prototype=b.prototype,new __)};var LocaleDateDirective=function(_super){__extends$6(LocaleDateDirective,_super);function LocaleDateDirective(locale,el,renderer){_super.call(this,el,renderer);this.locale=locale;this.el=el;this.renderer=renderer;this.defaultPattern="mediumDate"}LocaleDateDirective.prototype.setup=function(){var _this=this;this.replace();this.subscriptions.push(this.locale.defaultLocaleChanged.subscribe(function(){_this.replace()}))};LocaleDateDirective.prototype.replace=function(){if(IntlAPI.HasDateTimeFormat()){var localeDate=new _angular_common.DatePipe(this.locale.getDefaultLocale());var value=localeDate.transform(this.key,this.pattern||this.defaultPattern);this.setText(value)}};LocaleDateDirective.decorators=[{type:_angular_core.Directive,args:[{selector:"[localeDate]"}]}];LocaleDateDirective.ctorParameters=function(){return[{type:LocaleService},{type:_angular_core.ElementRef},{type:_angular_core.Renderer}]};LocaleDateDirective.propDecorators={pattern:[{type:_angular_core.Input,args:["localeDate"]}]};return LocaleDateDirective}(BaseDirective);var __extends$7=undefined&&undefined.__extends||function(d,b){for(var p in b)if(b.hasOwnProperty(p))d[p]=b[p];function __(){this.constructor=d}d.prototype=b===null?Object.create(b):(__.prototype=b.prototype,new __)};var LocaleDecimalDirective=function(_super){__extends$7(LocaleDecimalDirective,_super);function LocaleDecimalDirective(locale,el,renderer){_super.call(this,el,renderer);this.locale=locale;this.el=el;this.renderer=renderer;this.defaultDigits=null}LocaleDecimalDirective.prototype.setup=function(){var _this=this;this.replace();this.subscriptions.push(this.locale.defaultLocaleChanged.subscribe(function(){_this.replace()}))};LocaleDecimalDirective.prototype.replace=function(){if(IntlAPI.HasNumberFormat()){var localeDecimal=new _angular_common.DecimalPipe(this.locale.getDefaultLocale());var value=localeDecimal.transform(this.key,this.digits||this.defaultDigits);this.setText(value)}};LocaleDecimalDirective.decorators=[{type:_angular_core.Directive,args:[{selector:"[localeDecimal]"}]}];LocaleDecimalDirective.ctorParameters=function(){return[{type:LocaleService},{type:_angular_core.ElementRef},{type:_angular_core.Renderer}]};LocaleDecimalDirective.propDecorators={digits:[{type:_angular_core.Input,args:["localeDecimal"]}]};return LocaleDecimalDirective}(BaseDirective);var LocalePercentDirective=function(_super){__extends$7(LocalePercentDirective,_super);function LocalePercentDirective(locale,el,renderer){_super.call(this,el,renderer);this.locale=locale;this.el=el;this.renderer=renderer;this.defaultDigits=null}LocalePercentDirective.prototype.setup=function(){var _this=this;this.replace();this.subscriptions.push(this.locale.defaultLocaleChanged.subscribe(function(){_this.replace()}))};LocalePercentDirective.prototype.replace=function(){if(IntlAPI.HasNumberFormat()){var localePercent=new _angular_common.PercentPipe(this.locale.getDefaultLocale());var value=localePercent.transform(this.key,this.digits||this.defaultDigits);this.setText(value)}};LocalePercentDirective.decorators=[{type:_angular_core.Directive,args:[{selector:"[localePercent]"}]}];LocalePercentDirective.ctorParameters=function(){return[{type:LocaleService},{type:_angular_core.ElementRef},{type:_angular_core.Renderer}]};LocalePercentDirective.propDecorators={digits:[{type:_angular_core.Input,args:["localePercent"]}]};return LocalePercentDirective}(BaseDirective);var LocaleCurrencyDirective=function(_super){__extends$7(LocaleCurrencyDirective,_super);function LocaleCurrencyDirective(locale,el,renderer){_super.call(this,el,renderer);this.locale=locale;this.el=el;this.renderer=renderer;this.symbolDisplay=false;this.defaultDigits=null}Object.defineProperty(LocaleCurrencyDirective.prototype,"symbol",{set:function(symbolDisplay){this.symbolDisplay=symbolDisplay||this.symbolDisplay},enumerable:true,configurable:true});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(){if(IntlAPI.HasNumberFormat()){var localeCurrency=new _angular_common.CurrencyPipe(this.locale.getDefaultLocale());var value=localeCurrency.transform(this.key,this.locale.getCurrentCurrency(),this.symbolDisplay,this.digits||this.defaultDigits);this.setText(value)}};LocaleCurrencyDirective.decorators=[{type:_angular_core.Directive,args:[{selector:"[localeCurrency]"}]}];LocaleCurrencyDirective.ctorParameters=function(){return[{type:LocaleService},{type:_angular_core.ElementRef},{type:_angular_core.Renderer}]};LocaleCurrencyDirective.propDecorators={digits:[{type:_angular_core.Input,args:["localeCurrency"]}],symbol:[{type:_angular_core.Input}]};return LocaleCurrencyDirective}(BaseDirective);function isPresent(obj){return typeof obj!=="undefined"&&obj!=null}var RegExpFactory=function(){function RegExpFactory(){}RegExpFactory.prototype.number=function(defaultLocale,digits){var minInt=1;var minFraction=0;var maxFraction=3;if(isPresent(digits)){var NUMBER_FORMAT_REGEXP=/^(\d+)?\.((\d+)(\-(\d+))?)?$/;var parts=digits.match(NUMBER_FORMAT_REGEXP);if(isPresent(parts[1])){minInt=parseInt(parts[1])}if(isPresent(parts[3])){minFraction=parseInt(parts[3])}if(isPresent(parts[5])){maxFraction=parseInt(parts[5])}}var decimalCode=new DecimalCode(defaultLocale);var minusSign=decimalCode.minusSignCode;var zero=decimalCode.numbersCodes[0];var decimalSeparator=decimalCode.decimalSeparatorCode;var nine=decimalCode.numbersCodes[9];var pattern;if(minFraction>0&&maxFraction>0){pattern="^"+minusSign+"?["+zero+"-"+nine+"]{"+minInt+",}\\"+decimalSeparator+"["+zero+"-"+nine+"]{"+minFraction+","+maxFraction+"}$"}else if(minFraction==0&&maxFraction>0){pattern="^"+minusSign+"?["+zero+"-"+nine+"]{"+minInt+",}\\"+decimalSeparator+"?["+zero+"-"+nine+"]{"+minFraction+","+maxFraction+"}$"}else{pattern="^"+minusSign+"?["+zero+"-"+nine+"]{"+minInt+",}$"}pattern=decimalCode.UnicodeToChar(pattern);var regExp=new RegExp(pattern);return regExp};return RegExpFactory}();function validateLocaleNumber(locale,digits,MIN_VALUE,MAX_VALUE){if(MIN_VALUE===void 0){MIN_VALUE=Number.MIN_VALUE}if(MAX_VALUE===void 0){MAX_VALUE=Number.MAX_VALUE}var defaultLocale;var NUMBER_REGEXP;return function(formControl){if(formControl.value==null||formControl.value==""){return null}if(defaultLocale!=locale.getDefaultLocale()){var regExpFactory=new RegExpFactory;NUMBER_REGEXP=regExpFactory.number(locale.getDefaultLocale(),digits);defaultLocale=locale.getDefaultLocale()}if(NUMBER_REGEXP.test(formControl.value)){var parsedValue=void 0;var localeValidation=new LocaleValidation(locale);parsedValue=localeValidation.parseNumber(formControl.value);if(parsedValue<MIN_VALUE){return{minValue:{valid:false}}}else if(parsedValue>MAX_VALUE){return{maxValue:{valid:false}}}return null}else{return{format:{valid:false}}}}}var LocaleNumberValidatorDirective=function(){function LocaleNumberValidatorDirective(locale){this.locale=locale;this.MIN_VALUE=Number.MIN_VALUE;this.MAX_VALUE=Number.MAX_VALUE}Object.defineProperty(LocaleNumberValidatorDirective.prototype,"minValue",{set:function(value){this.MIN_VALUE=value||this.MIN_VALUE},enumerable:true,configurable:true});Object.defineProperty(LocaleNumberValidatorDirective.prototype,"maxValue",{set:function(value){this.MAX_VALUE=value||this.MAX_VALUE},enumerable:true,configurable:true});LocaleNumberValidatorDirective.prototype.ngOnInit=function(){this.validator=validateLocaleNumber(this.locale,this.digits,this.MIN_VALUE,this.MAX_VALUE)};LocaleNumberValidatorDirective.prototype.validate=function(formControl){return this.validator(formControl)};LocaleNumberValidatorDirective.decorators=[{type:_angular_core.Directive,args:[{selector:"[validateLocaleNumber][ngModel],[validateLocaleNumber][formControl]",providers:[{provide:_angular_forms.NG_VALIDATORS,useExisting:_angular_core.forwardRef(function(){return LocaleNumberValidatorDirective}),multi:true}]}]}];LocaleNumberValidatorDirective.ctorParameters=function(){return[{type:LocaleService}]};LocaleNumberValidatorDirective.propDecorators={digits:[{type:_angular_core.Input,args:["validateLocaleNumber"]}],minValue:[{type:_angular_core.Input}],maxValue:[{type:_angular_core.Input}]};return LocaleNumberValidatorDirective}();var TranslationModule=function(){function TranslationModule(){}TranslationModule.forRoot=function(){return{ngModule:TranslationModule,providers:[LocaleService,TranslationService]}};TranslationModule.forChild=function(){return{ngModule:TranslationModule,providers:[TranslationService]}};TranslationModule.decorators=[{type:_angular_core.NgModule,args:[{declarations:[TranslatePipe,TranslateDirective],exports:[TranslatePipe,TranslateDirective]}]}];TranslationModule.ctorParameters=function(){return[]};return TranslationModule}();var LocalizationModule=function(){function LocalizationModule(){}LocalizationModule.forRoot=function(){return{ngModule:LocalizationModule,providers:[LocaleService,TranslationService]}};LocalizationModule.forChild=function(){return{ngModule:LocalizationModule,providers:[TranslationService]}};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[]};return LocalizationModule}();var LocaleValidationModule=function(){function LocaleValidationModule(){}LocaleValidationModule.forRoot=function(){return{ngModule:LocaleValidationModule,providers:[LocaleValidation]}};LocaleValidationModule.decorators=[{type:_angular_core.NgModule,args:[{declarations:[LocaleNumberValidatorDirective],exports:[LocaleNumberValidatorDirective]}]}];LocaleValidationModule.ctorParameters=function(){return[]};return LocaleValidationModule}();exports.LocaleService=LocaleService;exports.TranslationService=TranslationService;exports.Translation=Translation;exports.Localization=Localization;exports.LocaleValidation=LocaleValidation;exports.Collator=Collator;exports.IntlAPI=IntlAPI;exports.ServiceState=ServiceState;exports.TranslatePipe=TranslatePipe;exports.LocaleDatePipe=LocaleDatePipe;exports.LocaleDecimalPipe=LocaleDecimalPipe;exports.LocalePercentPipe=LocalePercentPipe;exports.LocaleCurrencyPipe=LocaleCurrencyPipe;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:true})}); | ||
(function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?factory(exports,require("@angular/core"),require("@angular/http"),require("rxjs/Observable"),require("rxjs/add/operator/map"),require("rxjs/add/observable/merge"),require("@angular/common"),require("@angular/forms")):typeof define==="function"&&define.amd?define(["exports","@angular/core","@angular/http","rxjs/Observable","rxjs/add/operator/map","rxjs/add/observable/merge","@angular/common","@angular/forms"],factory):factory((global.ng=global.ng||{},global.ng.l10n=global.ng.l10n||{}),global.ng.core,global.ng.http,global.Rx,global.Rx,global.Rx,global.ng.common,global.ng.forms)})(this,function(exports,_angular_core,_angular_http,rxjs_Observable,rxjs_add_operator_map,rxjs_add_observable_merge,_angular_common,_angular_forms){"use strict";var LocaleConfig=function(){function LocaleConfig(locale){this.locale=locale}LocaleConfig.prototype.AddLanguage=function(languageCode,textDirection){if(textDirection===void 0){textDirection="LTR"}var language={code:languageCode,direction:textDirection};this.locale.configuration.languageCodes.push(language);return this};LocaleConfig.prototype.AddLanguages=function(languageCodes){for(var _i=0,languageCodes_1=languageCodes;_i<languageCodes_1.length;_i++){var languageCode=languageCodes_1[_i];var language={code:languageCode,direction:"ltr"};this.locale.configuration.languageCodes.push(language)}return this};LocaleConfig.prototype.DisableStorage=function(){this.locale.configuration.storageIsDisabled=true;return this};LocaleConfig.prototype.SetCookieExpiration=function(days){if(days===void 0){days=null}this.locale.configuration.cookiesExpirationDays=days;return this};LocaleConfig.prototype.UseLocalStorage=function(){this.locale.configuration.localStorage=true;return this};LocaleConfig.prototype.DefineLanguage=function(languageCode){this.locale.configuration.languageCode=languageCode;return this};LocaleConfig.prototype.DefineDefaultLocale=function(languageCode,countryCode,scriptCode,numberingSystem,calendar){this.locale.configuration.languageCode=languageCode;this.locale.configuration.countryCode=countryCode;this.locale.configuration.scriptCode=scriptCode;this.locale.configuration.numberingSystem=numberingSystem;this.locale.configuration.calendar=calendar;return this};LocaleConfig.prototype.DefineCurrency=function(currencyCode){this.locale.configuration.currencyCode=currencyCode;return this};return LocaleConfig}();var DefaultLocaleCodes=function(){function DefaultLocaleCodes(){}return DefaultLocaleCodes}();var __extends$1=undefined&&undefined.__extends||function(d,b){for(var p in b)if(b.hasOwnProperty(p))d[p]=b[p];function __(){this.constructor=d}d.prototype=b===null?Object.create(b):(__.prototype=b.prototype,new __)};var Codes=function(_super){__extends$1(Codes,_super);function Codes(){_super.apply(this,arguments)}return Codes}(DefaultLocaleCodes);var __extends=undefined&&undefined.__extends||function(d,b){for(var p in b)if(b.hasOwnProperty(p))d[p]=b[p];function __(){this.constructor=d}d.prototype=b===null?Object.create(b):(__.prototype=b.prototype,new __)};var Config=function(_super){__extends(Config,_super);function Config(){_super.apply(this,arguments);this.languageCodes=[];this.storageIsDisabled=false;this.localStorage=false}return Config}(Codes);var __extends$2=undefined&&undefined.__extends||function(d,b){for(var p in b)if(b.hasOwnProperty(p))d[p]=b[p];function __(){this.constructor=d}d.prototype=b===null?Object.create(b):(__.prototype=b.prototype,new __)};var DefaultLocale=function(_super){__extends$2(DefaultLocale,_super);function DefaultLocale(){_super.apply(this,arguments)}Object.defineProperty(DefaultLocale.prototype,"value",{get:function(){return this._value},set:function(defaultLocale){this._value=defaultLocale;this.parseValue()},enumerable:true,configurable:true});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;var index=value.search("-u");if(index!=-1){var extensions=value.substring(index+1).split("-");switch(extensions.length){case 3:if(extensions[1]=="nu"){this.numberingSystem=extensions[2]}else if(extensions[1]=="ca"){this.calendar=extensions[2]}break;default:this.numberingSystem=extensions[2];this.calendar=extensions[4];break}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];break}}};return DefaultLocale}(DefaultLocaleCodes);var Browser=function(){function Browser(locale){this.locale=locale;this.hasCookie=typeof navigator!=="undefined"&&typeof navigator.cookieEnabled!=="undefined"&&navigator.cookieEnabled;this.hasLocalStorage=typeof Storage!=="undefined"}Browser.prototype.readStorage=function(name){var value;if(!this.storageIsDisabled){if(this.locale.configuration.localStorage&&this.hasLocalStorage){value=this.getLocalStorage(name)}else if(this.hasCookie){value=this.getCookie(name)}}return value};Browser.prototype.writeStorage=function(name,value){if(!this.storageIsDisabled){if(this.locale.configuration.localStorage&&this.hasLocalStorage){this.setLocalStorage(name,value)}else if(this.hasCookie){this.setCookie(name,value)}}};Browser.prototype.getBrowserLanguage=function(){var browserLanguage;if(typeof navigator!=="undefined"&&typeof navigator.language!=="undefined"){browserLanguage=navigator.language}if(browserLanguage!=null){var index=browserLanguage.indexOf("-");if(index!=-1){browserLanguage=browserLanguage.substring(0,index)}}return browserLanguage};Browser.prototype.getLocalStorage=function(name){return localStorage.getItem(name)};Browser.prototype.getCookie=function(name){var result;if(typeof document!=="undefined"){result=new RegExp("(?:^|; )"+encodeURIComponent(name)+"=([^;]*)").exec(document.cookie)}return result?result[1]:null};Browser.prototype.setLocalStorage=function(name,value){localStorage.setItem(name,value)};Browser.prototype.setCookie=function(name,value){var expires="";if(this.locale.configuration.cookiesExpirationDays!=null){var expirationDate=new Date;expirationDate.setTime(expirationDate.getTime()+this.locale.configuration.cookiesExpirationDays*24*60*60*1e3);expires="; expires="+expirationDate.toUTCString()}if(typeof document!=="undefined"){document.cookie=name+"="+value+expires+"; path=/"}};return Browser}();var LocaleService=function(){function LocaleService(){this.languageCodeChanged=new _angular_core.EventEmitter(true);this.defaultLocaleChanged=new _angular_core.EventEmitter(true);this.currencyCodeChanged=new _angular_core.EventEmitter(true);this.loadTranslation=new _angular_core.EventEmitter(true);this._configuration=new Config;this.defaultLocale=new DefaultLocale;this.browser=new Browser(this)}Object.defineProperty(LocaleService.prototype,"configuration",{get:function(){return this._configuration},enumerable:true,configurable:true});LocaleService.prototype.AddConfiguration=function(){return new LocaleConfig(this)};LocaleService.prototype.init=function(){this.initStorage();if(!!this.configuration.languageCode&&!!this.configuration.countryCode){this.initDefaultLocale()}else if(!!this.configuration.languageCode){this.initLanguage()}if(!!this.configuration.currencyCode){this.initCurrency()}};LocaleService.prototype.getAvailableLanguages=function(){return this.configuration.languageCodes.map(function(language){return language.code})};LocaleService.prototype.getLanguageDirection=function(languageCode){if(languageCode===void 0){languageCode=this.defaultLocale.languageCode}var matchedLanguages=this.matchLanguage(languageCode);return matchedLanguages[0].direction};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.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.setCurrentLanguage=function(languageCode){if(this.defaultLocale.languageCode!=languageCode){this.defaultLocale.build(languageCode);this.browser.writeStorage("locale",this.defaultLocale.value);this.sendLanguageEvents();this.sendTranslationEvents()}};LocaleService.prototype.setDefaultLocale=function(languageCode,countryCode,scriptCode,numberingSystem,calendar){if(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.browser.writeStorage("locale",this.defaultLocale.value);this.sendDefaultLocaleEvents();this.sendTranslationEvents()}};LocaleService.prototype.setCurrentCurrency=function(currencyCode){if(this.currencyCode!=currencyCode){this.currencyCode=currencyCode;this.browser.writeStorage("currency",this.currencyCode);this.sendCurrencyEvents()}};LocaleService.prototype.initStorage=function(){this.browser.storageIsDisabled=this.configuration.storageIsDisabled;this.defaultLocale.value=this.browser.readStorage("locale");this.currencyCode=this.browser.readStorage("currency")};LocaleService.prototype.initLanguage=function(){if(this.defaultLocale.languageCode==null){var browserLanguage=this.browser.getBrowserLanguage();var matchedLanguages=this.matchLanguage(browserLanguage);if(matchedLanguages.length>0){this.defaultLocale.build(browserLanguage)}else{this.defaultLocale.build(this.configuration.languageCode)}this.browser.writeStorage("locale",this.defaultLocale.value)}this.sendLanguageEvents()};LocaleService.prototype.matchLanguage=function(languageCode){var matchedLanguages=this.configuration.languageCodes.filter(function(language){return language.code==languageCode});return matchedLanguages};LocaleService.prototype.initDefaultLocale=function(){if(this.defaultLocale.value==null){this.defaultLocale.build(this.configuration.languageCode,this.configuration.countryCode,this.configuration.scriptCode,this.configuration.numberingSystem,this.configuration.calendar);this.browser.writeStorage("locale",this.defaultLocale.value)}this.sendDefaultLocaleEvents()};LocaleService.prototype.initCurrency=function(){if(this.currencyCode==null){this.currencyCode=this.configuration.currencyCode;this.browser.writeStorage("currency",this.currencyCode)}this.sendCurrencyEvents()};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.emit(null)};LocaleService.decorators=[{type:_angular_core.Injectable}];LocaleService.ctorParameters=function(){return[]};LocaleService.propDecorators={languageCodeChanged:[{type:_angular_core.Output}],defaultLocaleChanged:[{type:_angular_core.Output}],currencyCodeChanged:[{type:_angular_core.Output}],loadTranslation:[{type:_angular_core.Output}]};return LocaleService}();var IntlAPI=function(){function IntlAPI(){}IntlAPI.HasDateTimeFormat=function(){var hasIntl=Intl&&typeof Intl==="object";return hasIntl&&Intl.hasOwnProperty("DateTimeFormat")};IntlAPI.HasNumberFormat=function(){var hasIntl=Intl&&typeof Intl==="object";return hasIntl&&Intl.hasOwnProperty("NumberFormat")};IntlAPI.HasCollator=function(){var hasIntl=Intl&&typeof Intl==="object";return hasIntl&&Intl.hasOwnProperty("Collator")};return IntlAPI}();var TranslationConfig=function(){function TranslationConfig(translation){this.translation=translation}TranslationConfig.prototype.AddTranslation=function(languageCode,translation){this.translation.addData(translation,languageCode);return this};TranslationConfig.prototype.AddProvider=function(prefix,dataFormat){if(dataFormat===void 0){dataFormat="json"}this.translation.configuration.providers.push({path:prefix,dataFormat:"json",webAPI:false});return this};TranslationConfig.prototype.AddWebAPIProvider=function(path,dataFormat){if(dataFormat===void 0){dataFormat="json"}this.translation.configuration.providers.push({path:path,dataFormat:dataFormat,webAPI:true});return this};TranslationConfig.prototype.UseLocaleAsLanguage=function(){this.translation.configuration.localeAsLanguage=true;return this};TranslationConfig.prototype.SetMissingValue=function(value){this.translation.configuration.missingValue=value;return this};TranslationConfig.prototype.SetMissingKey=function(key){this.translation.configuration.missingKey=key;return this};TranslationConfig.prototype.SetComposedKeySeparator=function(keySeparator){this.translation.configuration.keySeparator=keySeparator;return this};return TranslationConfig}();var Config$1=function(){function Config(){this.providers=[];this.localeAsLanguage=false;this.keySeparator="."}return Config}();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 TranslationService=function(){function TranslationService(locale,http){var _this=this;this.locale=locale;this.http=http;this.translationChanged=new _angular_core.EventEmitter(true);this.translationError=new _angular_core.EventEmitter(true);this._configuration=new Config$1;this.translationData={};this.serviceState=ServiceState.isWaiting;this.locale.loadTranslation.subscribe(function(){_this.loadTranslation()})}Object.defineProperty(TranslationService.prototype,"configuration",{get:function(){return this._configuration},enumerable:true,configurable:true});TranslationService.prototype.AddConfiguration=function(){return new TranslationConfig(this)};TranslationService.prototype.init=function(){if(this.configuration.providers.length>0){this.loadingMode=LoadingMode.Async}else{this.loadingMode=LoadingMode.Direct}this.loadTranslation()};TranslationService.prototype.getLanguage=function(){return this.language};TranslationService.prototype.translate=function(key,args,lang){if(args===void 0){args=null}if(lang===void 0){lang=this.language}if(key==null||key==""){return""}if(/^\d+\b/.exec(key)){return this.translateI18nPlural(key,args,lang)}return this.getValue(key,args,lang)};TranslationService.prototype.translateAsync=function(key,args,lang){var _this=this;if(lang===void 0){lang=this.language}return rxjs_Observable.Observable.create(function(observer){var value=_this.translate(key,args,lang);observer.next(value);observer.complete()})};TranslationService.prototype.addData=function(data,languageCode){this.translationData[languageCode]=typeof this.translationData[languageCode]!=="undefined"?this.extend(this.translationData[languageCode],data):data};TranslationService.prototype.translateI18nPlural=function(key,args,lang){var keyText=key.replace(/^\d+\b/,"");keyText=keyText.trim();var keyNumber=parseFloat(key);key=key.replace(/^\d+/,this.translateNumber(keyNumber));return key.replace(keyText,this.getValue(keyText,args,lang))};TranslationService.prototype.getValue=function(key,args,lang){var value;if(this.translationData[lang]){var translation=this.translationData[lang];var keys=key.split(this.configuration.keySeparator);do{key=keys.shift();if(translation[key]&&typeof translation[key]==="object"){translation=translation[key]}}while(keys.length>0);value=translation[key]}return this.parseValue(key,value,args,lang)};TranslationService.prototype.translateNumber=function(keyNumber){if(!isNaN(keyNumber)&&IntlAPI.HasNumberFormat()){var localeNumber=new Intl.NumberFormat(this.language).format(keyNumber);return localeNumber}return keyNumber.toString()};TranslationService.prototype.parseValue=function(key,value,args,lang){if(value==null){return this.handleMissingValue(key,args,lang)}else if(args){return this.handleArgs(value,args)}return value};TranslationService.prototype.handleMissingValue=function(key,args,lang){if(this.configuration.missingKey!=null){return this.translate(this.configuration.missingKey,args,lang)}else if(this.configuration.missingValue!=null){return this.configuration.missingValue}return key};TranslationService.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 typeof replacer!=="undefined"?replacer:substring})};TranslationService.prototype.loadTranslation=function(){var language=!this.configuration.localeAsLanguage?this.locale.getCurrentLanguage():this.locale.getCurrentLanguage()+"-"+this.locale.getCurrentCountry();if(language!=null&&language!=this.language){if(this.loadingMode==LoadingMode.Async){this.getTranslation(language)}else{this.releaseTranslation(language)}}};TranslationService.prototype.getTranslation=function(language){var _this=this;this.translationData={};this.serviceState=ServiceState.isLoading;var observableSequencesOfTranslationData=[];for(var _i=0,_a=this.configuration.providers;_i<_a.length;_i++){var provider=_a[_i];var url=provider.path;if(provider.webAPI){url+=language}else{url+=language+"."+provider.dataFormat}observableSequencesOfTranslationData.push(this.getTranslationByProvider(url))}rxjs_Observable.Observable.merge.apply(rxjs_Observable.Observable,observableSequencesOfTranslationData).subscribe(function(data){_this.addData(data,language)},function(error){_this.translationError.emit(error);_this.releaseTranslation(language)},function(){_this.releaseTranslation(language)})};TranslationService.prototype.getTranslationByProvider=function(url){return this.http.get(url).map(function(res){return res.json()})};TranslationService.prototype.extend=function(){var args=[];for(var _i=0;_i<arguments.length;_i++){args[_i-0]=arguments[_i]}var newObj={};for(var _a=0,args_1=args;_a<args_1.length;_a++){var obj=args_1[_a];for(var key in obj){newObj[key]=obj[key]}}return newObj};TranslationService.prototype.releaseTranslation=function(language){this.serviceState=ServiceState.isReady;this.language=language;this.translationChanged.emit(language)};TranslationService.decorators=[{type:_angular_core.Injectable}];TranslationService.ctorParameters=function(){return[{type:LocaleService},{type:_angular_http.Http}]};TranslationService.propDecorators={translationChanged:[{type:_angular_core.Output}],translationError:[{type:_angular_core.Output}]};return TranslationService}();var Translation=function(){function Translation(translation,changeDetectorRef){var _this=this;this.translation=translation;this.changeDetectorRef=changeDetectorRef;this.pipesSubscriptions=[];this.lang=this.translation.getLanguage();this.pipesSubscriptions.push(this.translation.translationChanged.subscribe(function(language){_this.lang=language;if(_this.changeDetectorRef){_this.changeDetectorRef.markForCheck()}}))}Translation.prototype.ngOnDestroy=function(){this.cancelPipesSubscriptions()};Translation.prototype.cancelPipesSubscriptions=function(){this.pipesSubscriptions.forEach(function(subscription){if(typeof subscription!=="undefined"){subscription.unsubscribe()}})};return Translation}();var __extends$3=undefined&&undefined.__extends||function(d,b){for(var p in b)if(b.hasOwnProperty(p))d[p]=b[p];function __(){this.constructor=d}d.prototype=b===null?Object.create(b):(__.prototype=b.prototype,new __)};var Localization=function(_super){__extends$3(Localization,_super);function Localization(locale,translation,changeDetectorRef){var _this=this;_super.call(this,translation,changeDetectorRef);this.locale=locale;this.translation=translation;this.changeDetectorRef=changeDetectorRef;this.defaultLocale=this.locale.getDefaultLocale();this.pipesSubscriptions.push(this.locale.defaultLocaleChanged.subscribe(function(defaultLocale){_this.defaultLocale=defaultLocale;if(_this.changeDetectorRef){_this.changeDetectorRef.markForCheck()}}));this.currency=this.locale.getCurrentCurrency();this.pipesSubscriptions.push(this.locale.currencyCodeChanged.subscribe(function(currency){_this.currency=currency;if(_this.changeDetectorRef){_this.changeDetectorRef.markForCheck()}}))}return Localization}(Translation);var NumberCode=function(){function NumberCode(defaultLocale){this.defaultLocale=defaultLocale;this.numbersCodes=[];for(var num=0;num<=9;num++){this.numbersCodes.push(this.Unicode(num.toString()))}if(IntlAPI.HasNumberFormat()){for(var num=0;num<=9;num++){this.numbersCodes[num]=this.Unicode(new Intl.NumberFormat(defaultLocale).format(num))}}}NumberCode.prototype.parse=function(s){};NumberCode.prototype.UnicodeToChar=function(pattern){return pattern.replace(/\\u[\dA-F]{4}/gi,function(match){return String.fromCharCode(parseInt(match.replace(/\\u/g,""),16))})};NumberCode.prototype.Unicode=function(c){return"\\u"+this.HexEncode(c.charCodeAt(0))};NumberCode.prototype.HexEncode=function(value){var hex=value.toString(16).toUpperCase();hex="0000".substr(0,4-hex.length)+hex;return hex};return NumberCode}();var __extends$4=undefined&&undefined.__extends||function(d,b){for(var p in b)if(b.hasOwnProperty(p))d[p]=b[p];function __(){this.constructor=d}d.prototype=b===null?Object.create(b):(__.prototype=b.prototype,new __)};var DecimalCode=function(_super){__extends$4(DecimalCode,_super);function DecimalCode(defaultLocale){_super.call(this,defaultLocale);this.defaultLocale=defaultLocale;this.minusSignCode=this.Unicode("-");this.decimalSeparatorCode=this.Unicode(".");if(IntlAPI.HasNumberFormat()){var value=-.9;var localeValue=new Intl.NumberFormat(defaultLocale).format(value);var unicodeChars=[];unicodeChars.push(this.Unicode(localeValue.charAt(0)));unicodeChars.push(this.Unicode(localeValue.charAt(1)));unicodeChars.push(this.Unicode(localeValue.charAt(2)));unicodeChars.push(this.Unicode(localeValue.charAt(3)));if(unicodeChars[0]=="\\u200F"||unicodeChars[0]=="\\u061C"){this.minusSignCode=unicodeChars[1];this.decimalSeparatorCode=unicodeChars[3]}else if(unicodeChars[0]==this.Unicode(new Intl.NumberFormat(defaultLocale).format(0))){this.minusSignCode=unicodeChars[3];this.decimalSeparatorCode=unicodeChars[1]}else{this.minusSignCode=unicodeChars[0];this.decimalSeparatorCode=unicodeChars[2]}}}DecimalCode.prototype.parse=function(s){var characters=s.split("");var value="";for(var _i=0,characters_1=characters;_i<characters_1.length;_i++){var char=characters_1[_i];var charCode=this.Unicode(char);var index=this.numbersCodes.indexOf(charCode);if(index!=-1){value+=index}else if(charCode==this.minusSignCode){value+="-"}else if(charCode==this.decimalSeparatorCode){value+="."}else{return NaN}}return parseFloat(value)};return DecimalCode}(NumberCode);var LocaleValidation=function(){function LocaleValidation(locale){this.locale=locale}LocaleValidation.prototype.parseNumber=function(s){if(s==""){return null}var decimalCode=new DecimalCode(this.locale.getDefaultLocale());return decimalCode.parse(s)};LocaleValidation.decorators=[{type:_angular_core.Injectable}];LocaleValidation.ctorParameters=function(){return[{type:LocaleService}]};return LocaleValidation}();var Collator=function(){function Collator(translation){this.translation=translation}Collator.prototype.compare=function(key1,key2,extension,options){if(options===void 0){options={usage:"sort",sensitivity:"variant"}}if(!IntlAPI.HasCollator()){return 0}var value1=this.translation.translate(key1);var value2=this.translation.translate(key2);var locale=this.addExtension(this.translation.getLanguage(),extension);return new Intl.Collator(locale,options).compare(value1,value2)};Collator.prototype.sort=function(list,keyName,order,extension,options){var _this=this;if(order===void 0){order="asc"}if(options===void 0){options={usage:"sort",sensitivity:"variant"}}if(!list||!keyName||!IntlAPI.HasCollator()){return list}list.sort(function(key1,key2){return _this.compare(key1[keyName],key2[keyName],extension,options)});if(order=="desc"){list.reverse()}return list};Collator.prototype.sortAsync=function(list,keyName,order,extension,options){var _this=this;if(options===void 0){options={usage:"sort",sensitivity:"variant"}}return 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(options===void 0){options={usage:"search"}}if(!list||!keyNames||s==""||s==null||!IntlAPI.HasCollator()){return list}var locale=this.translation.getLanguage();var collator=new Intl.Collator(locale,options);var matches=list.filter(function(key){var found=false;for(var i=0;i<keyNames.length;i++){if(_this.match(key[keyNames[i]],s,collator)){found=true;break}}return found});return matches};Collator.prototype.searchAsync=function(s,list,keyNames,options){var _this=this;if(options===void 0){options={usage:"search"}}return rxjs_Observable.Observable.create(function(observer){observer.next(_this.search(s,list,keyNames,options));observer.complete()})};Collator.prototype.addExtension=function(locale,extension){if(!!extension){locale=locale+"-u-"+extension}return locale};Collator.prototype.match=function(key,s,collator){var value=this.translation.translate(key);var valueLength=value.length;var sLength=s.length;if(sLength>valueLength){return false}if(sLength==valueLength){return collator.compare(value,s)==0}var found=false;for(var i=0;i<valueLength-(sLength-1);i++){var str=value.substr(i,sLength);if(collator.compare(str,s)==0){found=true;break}}return found};Collator.decorators=[{type:_angular_core.Injectable}];Collator.ctorParameters=function(){return[{type:TranslationService}]};return Collator}();var TranslatePipe=function(){function TranslatePipe(translation){this.translation=translation}TranslatePipe.prototype.transform=function(key,lang){var args=[];for(var _i=2;_i<arguments.length;_i++){args[_i-2]=arguments[_i]}if(this.translation.serviceState==ServiceState.isReady){return this.translation.translate(key,args[0],lang)}return""};TranslatePipe.decorators=[{type:_angular_core.Pipe,args:[{name:"translate",pure:true}]}];TranslatePipe.ctorParameters=function(){return[{type:TranslationService}]};return TranslatePipe}();var LocaleDatePipe=function(){function LocaleDatePipe(){}LocaleDatePipe.prototype.transform=function(value,defaultLocale,pattern){if(pattern===void 0){pattern="mediumDate"}if(IntlAPI.HasDateTimeFormat()){var localeDate=new _angular_common.DatePipe(defaultLocale);return localeDate.transform(value,pattern)}return value};LocaleDatePipe.decorators=[{type:_angular_core.Pipe,args:[{name:"localeDate",pure:true}]}];LocaleDatePipe.ctorParameters=function(){return[]};return LocaleDatePipe}();var LocaleDecimalPipe=function(){function LocaleDecimalPipe(){}LocaleDecimalPipe.prototype.transform=function(value,defaultLocale,digits){if(digits===void 0){digits=null}if(IntlAPI.HasNumberFormat()){var localeDecimal=new _angular_common.DecimalPipe(defaultLocale);return localeDecimal.transform(value,digits)}return value};LocaleDecimalPipe.decorators=[{type:_angular_core.Pipe,args:[{name:"localeDecimal",pure:true}]}];LocaleDecimalPipe.ctorParameters=function(){return[]};return LocaleDecimalPipe}();var LocalePercentPipe=function(){function LocalePercentPipe(){}LocalePercentPipe.prototype.transform=function(value,defaultLocale,digits){if(digits===void 0){digits=null}if(IntlAPI.HasNumberFormat()){var localePercent=new _angular_common.PercentPipe(defaultLocale);return localePercent.transform(value,digits)}return value};LocalePercentPipe.decorators=[{type:_angular_core.Pipe,args:[{name:"localePercent",pure:true}]}];LocalePercentPipe.ctorParameters=function(){return[]};return LocalePercentPipe}();var LocaleCurrencyPipe=function(){function LocaleCurrencyPipe(){}LocaleCurrencyPipe.prototype.transform=function(value,defaultLocale,currency,symbolDisplay,digits){if(symbolDisplay===void 0){symbolDisplay=false}if(digits===void 0){digits=null}if(IntlAPI.HasNumberFormat()){var localeCurrency=new _angular_common.CurrencyPipe(defaultLocale);return localeCurrency.transform(value,currency,symbolDisplay,digits)}return value+" "+currency};LocaleCurrencyPipe.decorators=[{type:_angular_core.Pipe,args:[{name:"localeCurrency",pure:true}]}];LocaleCurrencyPipe.ctorParameters=function(){return[]};return LocaleCurrencyPipe}();var BFS=function(){function BFS(){}BFS.getTargetNode=function(rootNode){return this.walk(rootNode)};BFS.walk=function(rootNode){var queue=[];var iNode;queue.push(rootNode);while(queue.length>0){iNode=queue.shift();if(this.isTargetNode(iNode)){return iNode}if(iNode.childNodes!=null){for(var _i=0,_a=iNode.childNodes;_i<_a.length;_i++){var child=_a[_i];queue.push(child)}}}return null};BFS.isTargetNode=function(node){return typeof node!=="undefined"&&node.nodeValue!=null&&node.nodeValue.trim()!=""&&node.nodeType==3};return BFS}();var BaseDirective=function(){function BaseDirective(el,renderer){this.el=el;this.renderer=renderer;this.subscriptions=[];this.MUTATION_CONFIG={subtree:true,characterData:true}}Object.defineProperty(BaseDirective.prototype,"value",{set:function(valueAttribute){this.valueAttribute=valueAttribute},enumerable:true,configurable:true});BaseDirective.prototype.ngAfterViewInit=function(){this.element=this.el.nativeElement;this.renderNode=BFS.getTargetNode(this.element);this.getKey();if(!!this.key){this.setup()}};BaseDirective.prototype.ngOnChanges=function(changes){if(!!this.key){if(this.element.childNodes.length==0&&!!this.valueAttribute){this.key=this.valueAttribute}this.replace()}};BaseDirective.prototype.ngOnDestroy=function(){this.removeTextListener();this.cancelSubscriptions()};BaseDirective.prototype.setup=function(){};BaseDirective.prototype.replace=function(){};BaseDirective.prototype.setText=function(value){if(!!this.nodeValue){this.removeTextListener();this.renderer.setText(this.renderNode,this.nodeValue.replace(this.key,value));this.addTextListener()}else if(!!this.valueAttribute){this.renderer.setElementAttribute(this.element,"value",value)}};BaseDirective.prototype.addTextListener=function(){var _this=this;if(typeof MutationObserver!=="undefined"){this.textObserver=new MutationObserver(function(mutations){_this.getKey();if(!!_this.key){_this.replace()}});this.textObserver.observe(this.renderNode,this.MUTATION_CONFIG)}};BaseDirective.prototype.removeTextListener=function(){if(typeof this.textObserver!=="undefined"){this.textObserver.disconnect()}};BaseDirective.prototype.getText=function(){this.nodeValue=this.renderNode!=null?this.renderNode.nodeValue:null;return this.nodeValue!=null?this.nodeValue.trim():null};BaseDirective.prototype.getKey=function(){if(this.element.childNodes.length>0){this.key=this.getText()}else if(!!this.valueAttribute){this.key=this.valueAttribute}};BaseDirective.prototype.cancelSubscriptions=function(){this.subscriptions.forEach(function(subscription){if(typeof subscription!=="undefined"){subscription.unsubscribe()}})};BaseDirective.propDecorators={ | ||
value:[{type:_angular_core.Input}]};return BaseDirective}();var __extends$5=undefined&&undefined.__extends||function(d,b){for(var p in b)if(b.hasOwnProperty(p))d[p]=b[p];function __(){this.constructor=d}d.prototype=b===null?Object.create(b):(__.prototype=b.prototype,new __)};var TranslateDirective=function(_super){__extends$5(TranslateDirective,_super);function TranslateDirective(translation,el,renderer){_super.call(this,el,renderer);this.translation=translation;this.el=el;this.renderer=renderer}TranslateDirective.prototype.setup=function(){var _this=this;this.replace();this.subscriptions.push(this.translation.translationChanged.subscribe(function(){_this.replace()}))};TranslateDirective.prototype.replace=function(){var _this=this;this.subscriptions.push(this.translation.translateAsync(this.key,this.params).subscribe(function(value){_this.setText(value)}))};TranslateDirective.decorators=[{type:_angular_core.Directive,args:[{selector:"[translate]"}]}];TranslateDirective.ctorParameters=function(){return[{type:TranslationService},{type:_angular_core.ElementRef},{type:_angular_core.Renderer}]};TranslateDirective.propDecorators={params:[{type:_angular_core.Input,args:["translate"]}]};return TranslateDirective}(BaseDirective);var __extends$6=undefined&&undefined.__extends||function(d,b){for(var p in b)if(b.hasOwnProperty(p))d[p]=b[p];function __(){this.constructor=d}d.prototype=b===null?Object.create(b):(__.prototype=b.prototype,new __)};var LocaleDateDirective=function(_super){__extends$6(LocaleDateDirective,_super);function LocaleDateDirective(locale,el,renderer){_super.call(this,el,renderer);this.locale=locale;this.el=el;this.renderer=renderer;this.defaultPattern="mediumDate"}LocaleDateDirective.prototype.setup=function(){var _this=this;this.replace();this.subscriptions.push(this.locale.defaultLocaleChanged.subscribe(function(){_this.replace()}))};LocaleDateDirective.prototype.replace=function(){if(IntlAPI.HasDateTimeFormat()){var localeDate=new _angular_common.DatePipe(this.locale.getDefaultLocale());var value=localeDate.transform(this.key,this.pattern||this.defaultPattern);this.setText(value)}};LocaleDateDirective.decorators=[{type:_angular_core.Directive,args:[{selector:"[localeDate]"}]}];LocaleDateDirective.ctorParameters=function(){return[{type:LocaleService},{type:_angular_core.ElementRef},{type:_angular_core.Renderer}]};LocaleDateDirective.propDecorators={pattern:[{type:_angular_core.Input,args:["localeDate"]}]};return LocaleDateDirective}(BaseDirective);var __extends$7=undefined&&undefined.__extends||function(d,b){for(var p in b)if(b.hasOwnProperty(p))d[p]=b[p];function __(){this.constructor=d}d.prototype=b===null?Object.create(b):(__.prototype=b.prototype,new __)};var LocaleDecimalDirective=function(_super){__extends$7(LocaleDecimalDirective,_super);function LocaleDecimalDirective(locale,el,renderer){_super.call(this,el,renderer);this.locale=locale;this.el=el;this.renderer=renderer;this.defaultDigits=null}LocaleDecimalDirective.prototype.setup=function(){var _this=this;this.replace();this.subscriptions.push(this.locale.defaultLocaleChanged.subscribe(function(){_this.replace()}))};LocaleDecimalDirective.prototype.replace=function(){if(IntlAPI.HasNumberFormat()){var localeDecimal=new _angular_common.DecimalPipe(this.locale.getDefaultLocale());var value=localeDecimal.transform(this.key,this.digits||this.defaultDigits);this.setText(value)}};LocaleDecimalDirective.decorators=[{type:_angular_core.Directive,args:[{selector:"[localeDecimal]"}]}];LocaleDecimalDirective.ctorParameters=function(){return[{type:LocaleService},{type:_angular_core.ElementRef},{type:_angular_core.Renderer}]};LocaleDecimalDirective.propDecorators={digits:[{type:_angular_core.Input,args:["localeDecimal"]}]};return LocaleDecimalDirective}(BaseDirective);var LocalePercentDirective=function(_super){__extends$7(LocalePercentDirective,_super);function LocalePercentDirective(locale,el,renderer){_super.call(this,el,renderer);this.locale=locale;this.el=el;this.renderer=renderer;this.defaultDigits=null}LocalePercentDirective.prototype.setup=function(){var _this=this;this.replace();this.subscriptions.push(this.locale.defaultLocaleChanged.subscribe(function(){_this.replace()}))};LocalePercentDirective.prototype.replace=function(){if(IntlAPI.HasNumberFormat()){var localePercent=new _angular_common.PercentPipe(this.locale.getDefaultLocale());var value=localePercent.transform(this.key,this.digits||this.defaultDigits);this.setText(value)}};LocalePercentDirective.decorators=[{type:_angular_core.Directive,args:[{selector:"[localePercent]"}]}];LocalePercentDirective.ctorParameters=function(){return[{type:LocaleService},{type:_angular_core.ElementRef},{type:_angular_core.Renderer}]};LocalePercentDirective.propDecorators={digits:[{type:_angular_core.Input,args:["localePercent"]}]};return LocalePercentDirective}(BaseDirective);var LocaleCurrencyDirective=function(_super){__extends$7(LocaleCurrencyDirective,_super);function LocaleCurrencyDirective(locale,el,renderer){_super.call(this,el,renderer);this.locale=locale;this.el=el;this.renderer=renderer;this.symbolDisplay=false;this.defaultDigits=null}Object.defineProperty(LocaleCurrencyDirective.prototype,"symbol",{set:function(symbolDisplay){this.symbolDisplay=symbolDisplay||this.symbolDisplay},enumerable:true,configurable:true});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(){if(IntlAPI.HasNumberFormat()){var localeCurrency=new _angular_common.CurrencyPipe(this.locale.getDefaultLocale());var value=localeCurrency.transform(this.key,this.locale.getCurrentCurrency(),this.symbolDisplay,this.digits||this.defaultDigits);this.setText(value)}};LocaleCurrencyDirective.decorators=[{type:_angular_core.Directive,args:[{selector:"[localeCurrency]"}]}];LocaleCurrencyDirective.ctorParameters=function(){return[{type:LocaleService},{type:_angular_core.ElementRef},{type:_angular_core.Renderer}]};LocaleCurrencyDirective.propDecorators={digits:[{type:_angular_core.Input,args:["localeCurrency"]}],symbol:[{type:_angular_core.Input}]};return LocaleCurrencyDirective}(BaseDirective);function isPresent(obj){return typeof obj!=="undefined"&&obj!=null}var RegExpFactory=function(){function RegExpFactory(){}RegExpFactory.prototype.number=function(defaultLocale,digits){var minInt=1;var minFraction=0;var maxFraction=3;if(isPresent(digits)){var NUMBER_FORMAT_REGEXP=/^(\d+)?\.((\d+)(\-(\d+))?)?$/;var parts=digits.match(NUMBER_FORMAT_REGEXP);if(isPresent(parts[1])){minInt=parseInt(parts[1])}if(isPresent(parts[3])){minFraction=parseInt(parts[3])}if(isPresent(parts[5])){maxFraction=parseInt(parts[5])}}var decimalCode=new DecimalCode(defaultLocale);var minusSign=decimalCode.minusSignCode;var zero=decimalCode.numbersCodes[0];var decimalSeparator=decimalCode.decimalSeparatorCode;var nine=decimalCode.numbersCodes[9];var pattern;if(minFraction>0&&maxFraction>0){pattern="^"+minusSign+"?["+zero+"-"+nine+"]{"+minInt+",}\\"+decimalSeparator+"["+zero+"-"+nine+"]{"+minFraction+","+maxFraction+"}$"}else if(minFraction==0&&maxFraction>0){pattern="^"+minusSign+"?["+zero+"-"+nine+"]{"+minInt+",}\\"+decimalSeparator+"?["+zero+"-"+nine+"]{"+minFraction+","+maxFraction+"}$"}else{pattern="^"+minusSign+"?["+zero+"-"+nine+"]{"+minInt+",}$"}pattern=decimalCode.UnicodeToChar(pattern);var regExp=new RegExp(pattern);return regExp};return RegExpFactory}();function validateLocaleNumber(locale,digits,MIN_VALUE,MAX_VALUE){if(MIN_VALUE===void 0){MIN_VALUE=Number.MIN_VALUE}if(MAX_VALUE===void 0){MAX_VALUE=Number.MAX_VALUE}var defaultLocale;var NUMBER_REGEXP;return function(formControl){if(formControl.value==null||formControl.value==""){return null}if(defaultLocale!=locale.getDefaultLocale()){var regExpFactory=new RegExpFactory;NUMBER_REGEXP=regExpFactory.number(locale.getDefaultLocale(),digits);defaultLocale=locale.getDefaultLocale()}if(NUMBER_REGEXP.test(formControl.value)){var parsedValue=void 0;var localeValidation=new LocaleValidation(locale);parsedValue=localeValidation.parseNumber(formControl.value);if(parsedValue<MIN_VALUE){return{minValue:{valid:false}}}else if(parsedValue>MAX_VALUE){return{maxValue:{valid:false}}}return null}else{return{format:{valid:false}}}}}var LocaleNumberValidatorDirective=function(){function LocaleNumberValidatorDirective(locale){this.locale=locale;this.MIN_VALUE=Number.MIN_VALUE;this.MAX_VALUE=Number.MAX_VALUE}Object.defineProperty(LocaleNumberValidatorDirective.prototype,"minValue",{set:function(value){this.MIN_VALUE=value||this.MIN_VALUE},enumerable:true,configurable:true});Object.defineProperty(LocaleNumberValidatorDirective.prototype,"maxValue",{set:function(value){this.MAX_VALUE=value||this.MAX_VALUE},enumerable:true,configurable:true});LocaleNumberValidatorDirective.prototype.ngOnInit=function(){this.validator=validateLocaleNumber(this.locale,this.digits,this.MIN_VALUE,this.MAX_VALUE)};LocaleNumberValidatorDirective.prototype.validate=function(formControl){return this.validator(formControl)};LocaleNumberValidatorDirective.decorators=[{type:_angular_core.Directive,args:[{selector:"[validateLocaleNumber][ngModel],[validateLocaleNumber][formControl]",providers:[{provide:_angular_forms.NG_VALIDATORS,useExisting:_angular_core.forwardRef(function(){return LocaleNumberValidatorDirective}),multi:true}]}]}];LocaleNumberValidatorDirective.ctorParameters=function(){return[{type:LocaleService}]};LocaleNumberValidatorDirective.propDecorators={digits:[{type:_angular_core.Input,args:["validateLocaleNumber"]}],minValue:[{type:_angular_core.Input}],maxValue:[{type:_angular_core.Input}]};return LocaleNumberValidatorDirective}();var TranslationModule=function(){function TranslationModule(){}TranslationModule.forRoot=function(){return{ngModule:TranslationModule,providers:[LocaleService,TranslationService]}};TranslationModule.forChild=function(){return{ngModule:TranslationModule,providers:[TranslationService]}};TranslationModule.decorators=[{type:_angular_core.NgModule,args:[{declarations:[TranslatePipe,TranslateDirective],exports:[TranslatePipe,TranslateDirective]}]}];TranslationModule.ctorParameters=function(){return[]};return TranslationModule}();var LocalizationModule=function(){function LocalizationModule(){}LocalizationModule.forRoot=function(){return{ngModule:LocalizationModule,providers:[LocaleService,TranslationService]}};LocalizationModule.forChild=function(){return{ngModule:LocalizationModule,providers:[TranslationService]}};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[]};return LocalizationModule}();var LocaleValidationModule=function(){function LocaleValidationModule(){}LocaleValidationModule.forRoot=function(){return{ngModule:LocaleValidationModule,providers:[LocaleValidation]}};LocaleValidationModule.decorators=[{type:_angular_core.NgModule,args:[{declarations:[LocaleNumberValidatorDirective],exports:[LocaleNumberValidatorDirective]}]}];LocaleValidationModule.ctorParameters=function(){return[]};return LocaleValidationModule}();exports.LocaleService=LocaleService;exports.TranslationService=TranslationService;exports.Translation=Translation;exports.Localization=Localization;exports.LocaleValidation=LocaleValidation;exports.Collator=Collator;exports.IntlAPI=IntlAPI;exports.ServiceState=ServiceState;exports.TranslatePipe=TranslatePipe;exports.LocaleDatePipe=LocaleDatePipe;exports.LocaleDecimalPipe=LocaleDecimalPipe;exports.LocalePercentPipe=LocalePercentPipe;exports.LocaleCurrencyPipe=LocaleCurrencyPipe;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:true})}); |
{ | ||
"name": "angular-l10n", | ||
"version": "2.0.9", | ||
"version": "2.0.10", | ||
"description": "An Angular library to translate messages, dates and numbers", | ||
@@ -5,0 +5,0 @@ "main": "bundles/angular-l10n.umd.js", |
# Angular localization | ||
[![Build Status](https://travis-ci.org/robisim74/angular-l10n.svg?branch=master)](https://travis-ci.org/robisim74/angular-l10n) [![npm version](https://badge.fury.io/js/angular-l10n.svg)](https://badge.fury.io/js/angular-l10n) | ||
[![Build Status](https://travis-ci.org/robisim74/angular-l10n.svg?branch=angular_v2)](https://travis-ci.org/robisim74/angular-l10n) [![npm version](https://badge.fury.io/js/angular-l10n.svg)](https://badge.fury.io/js/angular-l10n) | ||
> An Angular library to translate messages, dates and numbers. | ||
@@ -13,3 +13,3 @@ | ||
## Angular i18n solutions | ||
| _Feature_ | [Angular](https://angular.io/docs/ts/latest/cookbook/i18n.html) _Native_ | [ngx-translate](https://github.com/ngx-translate/core) _External library_ | [angular-l10n](https://github.com/robisim74/angular-l10n/blob/master/doc/spec.md) _External library_ | | ||
| _Feature_ | [Angular](https://angular.io/docs/ts/latest/cookbook/i18n.html) _Native_ | [ngx-translate](https://github.com/ngx-translate/core) _External library_ | [angular-l10n](https://github.com/robisim74/angular-l10n/blob/angular_v2/doc/spec.md) _External library_ | | ||
| --------- | ------------------------------------------------------------------------ | --------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | | ||
@@ -54,3 +54,3 @@ _Messages_ | Html attribute, message ID | directive, impure pipe | directive, pure pipe | ||
## Usage | ||
See [quick start](https://github.com/robisim74/angular-l10n/blob/master/doc/quick-start.md) and [library specification](https://github.com/robisim74/angular-l10n/blob/master/doc/spec.md). | ||
See [quick start](https://github.com/robisim74/angular-l10n/blob/angular_v2/doc/quick-start.md) and [library specification](https://github.com/robisim74/angular-l10n/blob/angular_v2/doc/spec.md). | ||
@@ -57,0 +57,0 @@ ## Related projects |
@@ -8,7 +8,12 @@ import { Directive, forwardRef, Input } from '@angular/core'; | ||
* Function that takes a control and returns either null when it’s valid, or an error object if it’s not. | ||
* @param {?} locale The reference to LocaleService | ||
* @param {?} digits The format of the number | ||
* @param {?=} MIN_VALUE The minimum value for the number | ||
* @param {?=} MAX_VALUE The maximum value for the number | ||
* @return {?} An error object: 'format', 'minValue' or 'maxValue'; null in case the value is valid | ||
\@param locale The reference to LocaleService | ||
\@param digits The format of the number | ||
\@param MIN_VALUE The minimum value for the number | ||
\@param MAX_VALUE The maximum value for the number | ||
\@return An error object: 'format', 'minValue' or 'maxValue'; null in case the value is valid | ||
* @param {?} locale | ||
* @param {?} digits | ||
* @param {?=} MIN_VALUE | ||
* @param {?=} MAX_VALUE | ||
* @return {?} | ||
*/ | ||
@@ -15,0 +20,0 @@ export function validateLocaleNumber(locale, digits, MIN_VALUE, MAX_VALUE) { |
@@ -25,17 +25,22 @@ var __extends = (this && this.__extends) || function (d, b) { | ||
var localeValue = new Intl.NumberFormat(defaultLocale).format(value); | ||
// Checks Unicode character 'RIGHT-TO-LEFT MARK' (U+200F). | ||
if (this.Unicode(localeValue.charAt(0)) == "\\u200F") { | ||
var unicodeChars = []; | ||
unicodeChars.push(this.Unicode(localeValue.charAt(0))); | ||
unicodeChars.push(this.Unicode(localeValue.charAt(1))); | ||
unicodeChars.push(this.Unicode(localeValue.charAt(2))); | ||
unicodeChars.push(this.Unicode(localeValue.charAt(3))); | ||
// Checks Unicode characters 'RIGHT-TO-LEFT MARK' (U+200F) & 'Arabic Letter Mark (U+061C)'. | ||
if (unicodeChars[0] == "\\u200F" || unicodeChars[0] == "\\u061C") { | ||
// Right to left. | ||
this.minusSignCode = this.Unicode(localeValue.charAt(1)); | ||
this.decimalSeparatorCode = this.Unicode(localeValue.charAt(3)); | ||
this.minusSignCode = unicodeChars[1]; | ||
this.decimalSeparatorCode = unicodeChars[3]; | ||
} | ||
else if (this.Unicode(localeValue.charAt(0)) == this.Unicode(new Intl.NumberFormat(defaultLocale).format(0))) { | ||
// IE & Edge reverse the order. | ||
this.minusSignCode = this.Unicode(localeValue.charAt(3)); | ||
this.decimalSeparatorCode = this.Unicode(localeValue.charAt(1)); | ||
else if (unicodeChars[0] == this.Unicode(new Intl.NumberFormat(defaultLocale).format(0))) { | ||
// Some IE & Edge versions reverse the order. | ||
this.minusSignCode = unicodeChars[3]; | ||
this.decimalSeparatorCode = unicodeChars[1]; | ||
} | ||
else { | ||
// Left to right. | ||
this.minusSignCode = this.Unicode(localeValue.charAt(0)); | ||
this.decimalSeparatorCode = this.Unicode(localeValue.charAt(2)); | ||
this.minusSignCode = unicodeChars[0]; | ||
this.decimalSeparatorCode = unicodeChars[2]; | ||
} | ||
@@ -42,0 +47,0 @@ } |
@@ -17,10 +17,14 @@ import { Injectable } from '@angular/core'; | ||
* Compares two keys by the value of translation according to the current language. | ||
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator | ||
\@param key1, key2 The keys of the values to compare | ||
\@param extension Unicode extension key, e.g. 'co-phonebk' | ||
\@param options Default is { usage: 'sort', sensitivity: 'variant' } | ||
\@return A negative value if the value of translation of key1 comes before the value of translation of key2; | ||
a positive value if key1 comes after key2; | ||
0 if they are considered equal or Intl.Collator is not supported | ||
\@see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator | ||
* @param {?} key1 | ||
* @param {?} key2 | ||
* @param {?=} extension Unicode extension key, e.g. 'co-phonebk' | ||
* @param {?=} options Default is { usage: 'sort', sensitivity: 'variant' } | ||
* @return {?} A negative value if the value of translation of key1 comes before the value of translation of key2; | ||
* a positive value if key1 comes after key2; | ||
* 0 if they are considered equal or Intl.Collator is not supported | ||
* @param {?=} extension | ||
* @param {?=} options | ||
* @return {?} | ||
*/ | ||
@@ -39,9 +43,15 @@ Collator.prototype.compare = function (key1, key2, extension, options) { | ||
* Sorts an array of objects or an array of arrays according to the current language. | ||
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator | ||
* @param {?} list The array to be sorted | ||
* @param {?} keyName The column that contains the keys of the values to be ordered | ||
* @param {?=} order 'asc' or 'desc'. The default value is 'asc' | ||
* @param {?=} extension Unicode extension key, e.g. 'co-phonebk' | ||
* @param {?=} options Default is { usage: 'sort', sensitivity: 'variant' } | ||
* @return {?} The same sorted list or the same list if Intl.Collator is not supported | ||
\@param list The array to be sorted | ||
\@param keyName The column that contains the keys of the values to be ordered | ||
\@param order 'asc' or 'desc'. The default value is 'asc' | ||
\@param extension Unicode extension key, e.g. 'co-phonebk' | ||
\@param options Default is { usage: 'sort', sensitivity: 'variant' } | ||
\@return The same sorted list or the same list if Intl.Collator is not supported | ||
\@see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator | ||
* @param {?} list | ||
* @param {?} keyName | ||
* @param {?=} order | ||
* @param {?=} extension | ||
* @param {?=} options | ||
* @return {?} | ||
*/ | ||
@@ -65,9 +75,15 @@ Collator.prototype.sort = function (list, keyName, order, extension, options) { | ||
* Sorts asynchronously an array of objects or an array of arrays according to the current language. | ||
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator | ||
* @param {?} list The array to be sorted | ||
* @param {?} keyName The column that contains the keys of the values to be ordered | ||
* @param {?=} order 'asc' or 'desc'. The default value is 'asc' | ||
* @param {?=} extension Unicode extension key, e.g. 'co-phonebk' | ||
* @param {?=} options Default is { usage: 'sort', sensitivity: 'variant' } | ||
* @return {?} An observable of the sorted list or of the same list if Intl.Collator is not supported | ||
\@param list The array to be sorted | ||
\@param keyName The column that contains the keys of the values to be ordered | ||
\@param order 'asc' or 'desc'. The default value is 'asc' | ||
\@param extension Unicode extension key, e.g. 'co-phonebk' | ||
\@param options Default is { usage: 'sort', sensitivity: 'variant' } | ||
\@return An observable of the sorted list or of the same list if Intl.Collator is not supported | ||
\@see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator | ||
* @param {?} list | ||
* @param {?} keyName | ||
* @param {?=} order | ||
* @param {?=} extension | ||
* @param {?=} options | ||
* @return {?} | ||
*/ | ||
@@ -84,9 +100,14 @@ Collator.prototype.sortAsync = function (list, keyName, order, extension, options) { | ||
* Matches a string into an array of objects or an array of arrays | ||
* according to the current language. | ||
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator | ||
* @param {?} s The string to search | ||
* @param {?} list The array in which to search | ||
* @param {?} keyNames An array that contains the columns to look for | ||
* @param {?=} options Default is { usage: 'search' } | ||
* @return {?} A filtered list or the same list if Intl.Collator is not supported | ||
according to the current language. | ||
\@param s The string to search | ||
\@param list The array in which to search | ||
\@param keyNames An array that contains the columns to look for | ||
\@param options Default is { usage: 'search' } | ||
\@return A filtered list or the same list if Intl.Collator is not supported | ||
\@see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator | ||
* @param {?} s | ||
* @param {?} list | ||
* @param {?} keyNames | ||
* @param {?=} options | ||
* @return {?} | ||
*/ | ||
@@ -115,9 +136,14 @@ Collator.prototype.search = function (s, list, keyNames, options) { | ||
* Matches asynchronously a string into an array of objects or an array of arrays | ||
* according to the current language. | ||
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator | ||
* @param {?} s The string to search | ||
* @param {?} list The array in which to search | ||
* @param {?} keyNames An array that contains the columns to look for | ||
* @param {?=} options Default is { usage: 'search' } | ||
* @return {?} An observable of the filtered list or the same list if Intl.Collator is not supported | ||
according to the current language. | ||
\@param s The string to search | ||
\@param list The array in which to search | ||
\@param keyNames An array that contains the columns to look for | ||
\@param options Default is { usage: 'search' } | ||
\@return An observable of the filtered list or the same list if Intl.Collator is not supported | ||
\@see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator | ||
* @param {?} s | ||
* @param {?} list | ||
* @param {?} keyNames | ||
* @param {?=} options | ||
* @return {?} | ||
*/ | ||
@@ -124,0 +150,0 @@ Collator.prototype.searchAsync = function (s, list, keyNames, options) { |
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 not supported yet
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 not supported yet
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
486060
6068