META-INF.resources.bower_components.globalize.dist.globalize-runtime.unit.min.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jwebmp-globalize Show documentation
Show all versions of jwebmp-globalize Show documentation
The JWebSwing implementation for a full Globalization
(function(root,factory){if(typeof define==="function"&&define.amd){define(["../globalize-runtime","./number","./plural"],factory)}else if(typeof exports==="object"){module.exports=factory(require("../globalize-runtime"),require("./number"),require("./plural"))}else{factory(root.Globalize)}})(this,function(Globalize){var formatMessage=Globalize._formatMessage,runtimeKey=Globalize._runtimeKey,validateParameterPresence=Globalize._validateParameterPresence,validateParameterTypeNumber=Globalize._validateParameterTypeNumber;var unitFormat=function(value,numberFormatter,pluralGenerator,unitProperties){var compoundUnitPattern=unitProperties.compoundUnitPattern,dividend,dividendProperties,formattedValue,divisor,divisorProperties,message,pluralValue;unitProperties=unitProperties.unitProperties;formattedValue=numberFormatter(value);pluralValue=pluralGenerator(value);if(unitProperties instanceof Array){dividendProperties=unitProperties[0];divisorProperties=unitProperties[1];dividend=formatMessage(dividendProperties[pluralValue],[value]);divisor=formatMessage(divisorProperties.one,[""]).trim();return formatMessage(compoundUnitPattern,[dividend,divisor])}message=unitProperties[pluralValue];return formatMessage(message,[formattedValue])};var unitFormatterFn=function(numberFormatter,pluralGenerator,unitProperties){return function unitFormatter(value){validateParameterPresence(value,"value");validateParameterTypeNumber(value,"value");return unitFormat(value,numberFormatter,pluralGenerator,unitProperties)}};Globalize._unitFormatterFn=unitFormatterFn;Globalize.formatUnit=Globalize.prototype.formatUnit=function(value,unit,options){return this.unitFormatter(unit,options)(value)};Globalize.unitFormatter=Globalize.prototype.unitFormatter=function(unit,options){options=options||{};return Globalize[runtimeKey("unitFormatter",this._locale,[unit,options])]};return Globalize});