| @@ -0,0 +1,116 @@ | ||
| /** | ||
| * Globalize Runtime v1.2.2 | ||
| * | ||
| * http://github.com/jquery/globalize | ||
| * | ||
| * Copyright jQuery Foundation and other contributors | ||
| * Released under the MIT license | ||
| * http://jquery.org/license | ||
| * | ||
| * Date: 2016-12-31T15:52Z | ||
| */ | ||
| /*! | ||
| * Globalize Runtime v1.2.2 2016-12-31T15:52Z Released under the MIT license | ||
| * http://git.io/TrdQbw | ||
| */ | ||
| (function( root, factory ) { | ||
|
|
||
| // UMD returnExports | ||
| if ( typeof define === "function" && define.amd ) { | ||
|
|
||
| // AMD | ||
| define([ | ||
| "../globalize-runtime" | ||
| ], factory ); | ||
| } else if ( typeof exports === "object" ) { | ||
|
|
||
| // Node, CommonJS | ||
| module.exports = factory( require( "../globalize-runtime" ) ); | ||
| } else { | ||
|
|
||
| // Extend global | ||
| factory( root.Globalize ); | ||
| } | ||
| }(this, function( Globalize ) { | ||
|
|
||
| var runtimeKey = Globalize._runtimeKey, | ||
| validateParameterType = Globalize._validateParameterType; | ||
|
|
||
|
|
||
| /** | ||
| * Function inspired by jQuery Core, but reduced to our use case. | ||
| */ | ||
| var isPlainObject = function( obj ) { | ||
| return obj !== null && "" + obj === "[object Object]"; | ||
| }; | ||
|
|
||
|
|
||
|
|
||
|
|
||
| var validateParameterTypeMessageVariables = function( value, name ) { | ||
| validateParameterType( | ||
| value, | ||
| name, | ||
| value === undefined || isPlainObject( value ) || Array.isArray( value ), | ||
| "Array or Plain Object" | ||
| ); | ||
| }; | ||
|
|
||
|
|
||
|
|
||
|
|
||
| var messageFormatterFn = function( formatter ) { | ||
| return function messageFormatter( variables ) { | ||
| if ( typeof variables === "number" || typeof variables === "string" ) { | ||
| variables = [].slice.call( arguments, 0 ); | ||
| } | ||
| validateParameterTypeMessageVariables( variables, "variables" ); | ||
| return formatter( variables ); | ||
| }; | ||
| }; | ||
|
|
||
|
|
||
|
|
||
|
|
||
| Globalize._messageFormatterFn = messageFormatterFn; | ||
| /* jshint ignore:start */ | ||
| Globalize._messageFormat = (function() { | ||
| var number = function (value, offset) { | ||
| if (isNaN(value)) throw new Error("'" + value + "' isn't a number."); | ||
| return value - (offset || 0); | ||
| }; | ||
| var plural = function (value, offset, lcfunc, data, isOrdinal) { | ||
| if ({}.hasOwnProperty.call(data, value)) return data[value](); | ||
| if (offset) value -= offset; | ||
| var key = lcfunc(value, isOrdinal); | ||
| if (key in data) return data[key](); | ||
| return data.other(); | ||
| }; | ||
| var select = function (value, data) { | ||
| if ({}.hasOwnProperty.call(data, value)) return data[value](); | ||
| return data.other() | ||
| }; | ||
|
|
||
| return {number: number, plural: plural, select: select}; | ||
| }()); | ||
| /* jshint ignore:end */ | ||
| Globalize._validateParameterTypeMessageVariables = validateParameterTypeMessageVariables; | ||
|
|
||
| Globalize.messageFormatter = | ||
| Globalize.prototype.messageFormatter = function( /* path */ ) { | ||
| return Globalize[ | ||
| runtimeKey( "messageFormatter", this._locale, [].slice.call( arguments, 0 ) ) | ||
| ]; | ||
| }; | ||
|
|
||
| Globalize.formatMessage = | ||
| Globalize.prototype.formatMessage = function( path /* , variables */ ) { | ||
| return this.messageFormatter( path ).apply( {}, [].slice.call( arguments, 1 ) ); | ||
| }; | ||
|
|
||
| return Globalize; | ||
|
|
||
|
|
||
|
|
||
|
|
||
| })); |
| @@ -0,0 +1,86 @@ | ||
| /** | ||
| * Globalize Runtime v1.2.2 | ||
| * | ||
| * http://github.com/jquery/globalize | ||
| * | ||
| * Copyright jQuery Foundation and other contributors | ||
| * Released under the MIT license | ||
| * http://jquery.org/license | ||
| * | ||
| * Date: 2016-12-31T15:52Z | ||
| */ | ||
| /*! | ||
| * Globalize Runtime v1.2.2 2016-12-31T15:52Z Released under the MIT license | ||
| * http://git.io/TrdQbw | ||
| */ | ||
| (function( root, factory ) { | ||
|
|
||
| // UMD returnExports | ||
| if ( typeof define === "function" && define.amd ) { | ||
|
|
||
| // AMD | ||
| define([ | ||
| "../globalize-runtime" | ||
| ], factory ); | ||
| } else if ( typeof exports === "object" ) { | ||
|
|
||
| // Node, CommonJS | ||
| module.exports = factory( require( "../globalize-runtime" ) ); | ||
| } else { | ||
|
|
||
| // Extend global | ||
| factory( root.Globalize ); | ||
| } | ||
| }(this, function( Globalize ) { | ||
|
|
||
| var runtimeKey = Globalize._runtimeKey, | ||
| validateParameterPresence = Globalize._validateParameterPresence, | ||
| validateParameterType = Globalize._validateParameterType; | ||
|
|
||
|
|
||
| var validateParameterTypeNumber = function( value, name ) { | ||
| validateParameterType( | ||
| value, | ||
| name, | ||
| value === undefined || typeof value === "number", | ||
| "Number" | ||
| ); | ||
| }; | ||
|
|
||
|
|
||
|
|
||
|
|
||
| var pluralGeneratorFn = function( plural ) { | ||
| return function pluralGenerator( value ) { | ||
| validateParameterPresence( value, "value" ); | ||
| validateParameterTypeNumber( value, "value" ); | ||
|
|
||
| return plural( value ); | ||
| }; | ||
| }; | ||
|
|
||
|
|
||
|
|
||
|
|
||
| Globalize._pluralGeneratorFn = pluralGeneratorFn; | ||
| Globalize._validateParameterTypeNumber = validateParameterTypeNumber; | ||
|
|
||
| Globalize.plural = | ||
| Globalize.prototype.plural = function( value, options ) { | ||
| validateParameterPresence( value, "value" ); | ||
| validateParameterTypeNumber( value, "value" ); | ||
| return this.pluralGenerator( options )( value ); | ||
| }; | ||
|
|
||
| Globalize.pluralGenerator = | ||
| Globalize.prototype.pluralGenerator = function( options ) { | ||
| options = options || {}; | ||
| return Globalize[ runtimeKey( "pluralGenerator", this._locale, [ options ] ) ]; | ||
| }; | ||
|
|
||
| return Globalize; | ||
|
|
||
|
|
||
|
|
||
|
|
||
| })); |
| @@ -0,0 +1,116 @@ | ||
| /** | ||
| * Globalize Runtime v1.2.2 | ||
| * | ||
| * http://github.com/jquery/globalize | ||
| * | ||
| * Copyright jQuery Foundation and other contributors | ||
| * Released under the MIT license | ||
| * http://jquery.org/license | ||
| * | ||
| * Date: 2016-12-31T15:52Z | ||
| */ | ||
| /*! | ||
| * Globalize Runtime v1.2.2 2016-12-31T15:52Z Released under the MIT license | ||
| * http://git.io/TrdQbw | ||
| */ | ||
| (function( root, factory ) { | ||
|
|
||
| // UMD returnExports | ||
| if ( typeof define === "function" && define.amd ) { | ||
|
|
||
| // AMD | ||
| define([ | ||
| "../globalize-runtime", | ||
| "./number", | ||
| "./plural" | ||
| ], factory ); | ||
| } else if ( typeof exports === "object" ) { | ||
|
|
||
| // Node, CommonJS | ||
| module.exports = factory( | ||
| require( "../globalize-runtime" ), | ||
| require( "./number" ), | ||
| require( "./plural" ) | ||
| ); | ||
| } else { | ||
|
|
||
| // Extend global | ||
| factory( root.Globalize ); | ||
| } | ||
| }(this, function( Globalize ) { | ||
|
|
||
| var formatMessage = Globalize._formatMessage, | ||
| runtimeKey = Globalize._runtimeKey, | ||
| validateParameterPresence = Globalize._validateParameterPresence, | ||
| validateParameterTypeNumber = Globalize._validateParameterTypeNumber; | ||
|
|
||
|
|
||
| /** | ||
| * format( value, numberFormatter, pluralGenerator, properties ) | ||
| * | ||
| * @value [Number] The number to format | ||
| * | ||
| * @numberFormatter [String] A numberFormatter from Globalize.numberFormatter | ||
| * | ||
| * @pluralGenerator [String] A pluralGenerator from Globalize.pluralGenerator | ||
| * | ||
| * @properties [Object] containing relative time plural message. | ||
| * | ||
| * Format relative time. | ||
| */ | ||
| var relativeTimeFormat = function( value, numberFormatter, pluralGenerator, properties ) { | ||
|
|
||
| var relativeTime, | ||
| message = properties[ "relative-type-" + value ]; | ||
|
|
||
| if ( message ) { | ||
| return message; | ||
| } | ||
|
|
||
| relativeTime = value <= 0 ? properties[ "relativeTime-type-past" ] | ||
| : properties[ "relativeTime-type-future" ]; | ||
|
|
||
| value = Math.abs( value ); | ||
|
|
||
| message = relativeTime[ "relativeTimePattern-count-" + pluralGenerator( value ) ]; | ||
| return formatMessage( message, [ numberFormatter( value ) ] ); | ||
| }; | ||
|
|
||
|
|
||
|
|
||
|
|
||
| var relativeTimeFormatterFn = function( numberFormatter, pluralGenerator, properties ) { | ||
| return function relativeTimeFormatter( value ) { | ||
| validateParameterPresence( value, "value" ); | ||
| validateParameterTypeNumber( value, "value" ); | ||
|
|
||
| return relativeTimeFormat( value, numberFormatter, pluralGenerator, properties ); | ||
| }; | ||
|
|
||
| }; | ||
|
|
||
|
|
||
|
|
||
|
|
||
| Globalize._relativeTimeFormatterFn = relativeTimeFormatterFn; | ||
|
|
||
| Globalize.formatRelativeTime = | ||
| Globalize.prototype.formatRelativeTime = function( value, unit, options ) { | ||
| validateParameterPresence( value, "value" ); | ||
| validateParameterTypeNumber( value, "value" ); | ||
|
|
||
| return this.relativeTimeFormatter( unit, options )( value ); | ||
| }; | ||
|
|
||
| Globalize.relativeTimeFormatter = | ||
| Globalize.prototype.relativeTimeFormatter = function( unit, options ) { | ||
| options = options || {}; | ||
| return Globalize[ runtimeKey( "relativeTimeFormatter", this._locale, [ unit, options ] ) ]; | ||
| }; | ||
|
|
||
| return Globalize; | ||
|
|
||
|
|
||
|
|
||
|
|
||
| })); |
| @@ -0,0 +1,127 @@ | ||
| /** | ||
| * Globalize Runtime v1.2.2 | ||
| * | ||
| * http://github.com/jquery/globalize | ||
| * | ||
| * Copyright jQuery Foundation and other contributors | ||
| * Released under the MIT license | ||
| * http://jquery.org/license | ||
| * | ||
| * Date: 2016-12-31T15:52Z | ||
| */ | ||
| /*! | ||
| * Globalize Runtime v1.2.2 2016-12-31T15:52Z Released under the MIT license | ||
| * http://git.io/TrdQbw | ||
| */ | ||
| (function( root, factory ) { | ||
|
|
||
| // UMD returnExports | ||
| if ( typeof define === "function" && define.amd ) { | ||
|
|
||
| // AMD | ||
| define([ | ||
| "../globalize-runtime", | ||
| "./number", | ||
| "./plural" | ||
| ], factory ); | ||
| } else if ( typeof exports === "object" ) { | ||
|
|
||
| // Node, CommonJS | ||
| module.exports = factory( | ||
| require( "../globalize-runtime" ), | ||
| require( "./number" ), | ||
| require( "./plural" ) | ||
| ); | ||
| } else { | ||
|
|
||
| // Extend global | ||
| factory( root.Globalize ); | ||
| } | ||
| }(this, function( Globalize ) { | ||
|
|
||
| var formatMessage = Globalize._formatMessage, | ||
| runtimeKey = Globalize._runtimeKey, | ||
| validateParameterPresence = Globalize._validateParameterPresence, | ||
| validateParameterTypeNumber = Globalize._validateParameterTypeNumber; | ||
|
|
||
|
|
||
| /** | ||
| * format( value, numberFormatter, pluralGenerator, unitProperies ) | ||
| * | ||
| * @value [Number] | ||
| * | ||
| * @numberFormatter [Object]: A numberFormatter from Globalize.numberFormatter. | ||
| * | ||
| * @pluralGenerator [Object]: A pluralGenerator from Globalize.pluralGenerator. | ||
| * | ||
| * @unitProperies [Object]: localized unit data from cldr. | ||
| * | ||
| * Format units such as seconds, minutes, days, weeks, etc. | ||
| * | ||
| * OBS: | ||
| * | ||
| * Unit Sequences are not implemented. | ||
| * http://www.unicode.org/reports/tr35/tr35-35/tr35-general.html#Unit_Sequences | ||
| * | ||
| * Duration Unit (for composed time unit durations) is not implemented. | ||
| * http://www.unicode.org/reports/tr35/tr35-35/tr35-general.html#durationUnit | ||
| */ | ||
| 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 ); | ||
|
|
||
| // computed compound unit, eg. "megabyte-per-second". | ||
| 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; | ||
|
|
||
|
|
||
|
|
||
|
|
||
| })); |
| @@ -0,0 +1,373 @@ | ||
| /** | ||
| * Globalize v1.2.2 | ||
| * | ||
| * http://github.com/jquery/globalize | ||
| * | ||
| * Copyright jQuery Foundation and other contributors | ||
| * Released under the MIT license | ||
| * http://jquery.org/license | ||
| * | ||
| * Date: 2016-12-31T15:52Z | ||
| */ | ||
| /*! | ||
| * Globalize v1.2.2 2016-12-31T15:52Z Released under the MIT license | ||
| * http://git.io/TrdQbw | ||
| */ | ||
| (function( root, factory ) { | ||
|
|
||
| // UMD returnExports | ||
| if ( typeof define === "function" && define.amd ) { | ||
|
|
||
| // AMD | ||
| define([ | ||
| "cldr", | ||
| "../globalize", | ||
| "cldr/event", | ||
| "cldr/supplemental" | ||
| ], factory ); | ||
| } else if ( typeof exports === "object" ) { | ||
|
|
||
| // Node, CommonJS | ||
| module.exports = factory( require( "cldrjs" ), require( "../globalize" ) ); | ||
| } else { | ||
|
|
||
| // Global | ||
| factory( root.Cldr, root.Globalize ); | ||
| } | ||
| }(this, function( Cldr, Globalize ) { | ||
|
|
||
| var runtimeBind = Globalize._runtimeBind, | ||
| validateCldr = Globalize._validateCldr, | ||
| validateDefaultLocale = Globalize._validateDefaultLocale, | ||
| validateParameterPresence = Globalize._validateParameterPresence, | ||
| validateParameterType = Globalize._validateParameterType, | ||
| validateParameterTypePlainObject = Globalize._validateParameterTypePlainObject; | ||
| var MakePlural; | ||
| /* jshint ignore:start */ | ||
| MakePlural = (function() { | ||
| 'use strict'; | ||
|
|
||
| var _toArray = function (arr) { return Array.isArray(arr) ? arr : Array.from(arr); }; | ||
|
|
||
| var _toConsumableArray = function (arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; return arr2; } else { return Array.from(arr); } }; | ||
|
|
||
| var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }; | ||
|
|
||
| var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); | ||
|
|
||
|
|
||
| /** | ||
| * make-plural.js -- https://github.com/eemeli/make-plural.js/ | ||
| * Copyright (c) 2014-2015 by Eemeli Aro <eemeli@gmail.com> | ||
| * | ||
| * Permission to use, copy, modify, and/or distribute this software for any | ||
| * purpose with or without fee is hereby granted, provided that the above | ||
| * copyright notice and this permission notice appear in all copies. | ||
| * | ||
| * The software is provided "as is" and the author disclaims all warranties | ||
| * with regard to this software including all implied warranties of | ||
| * merchantability and fitness. In no event shall the author be liable for | ||
| * any special, direct, indirect, or consequential damages or any damages | ||
| * whatsoever resulting from loss of use, data or profits, whether in an | ||
| * action of contract, negligence or other tortious action, arising out of | ||
| * or in connection with the use or performance of this software. | ||
| */ | ||
|
|
||
| var Parser = (function () { | ||
| function Parser() { | ||
| _classCallCheck(this, Parser); | ||
| } | ||
|
|
||
| _createClass(Parser, [{ | ||
| key: 'parse', | ||
| value: function parse(cond) { | ||
| var _this = this; | ||
|
|
||
| if (cond === 'i = 0 or n = 1') { | ||
| return 'n >= 0 && n <= 1'; | ||
| }if (cond === 'i = 0,1') { | ||
| return 'n >= 0 && n < 2'; | ||
| }if (cond === 'i = 1 and v = 0') { | ||
| this.v0 = 1; | ||
| return 'n == 1 && v0'; | ||
| } | ||
| return cond.replace(/([tv]) (!?)= 0/g, function (m, sym, noteq) { | ||
| var sn = sym + '0'; | ||
| _this[sn] = 1; | ||
| return noteq ? '!' + sn : sn; | ||
| }).replace(/\b[fintv]\b/g, function (m) { | ||
| _this[m] = 1; | ||
| return m; | ||
| }).replace(/([fin]) % (10+)/g, function (m, sym, num) { | ||
| var sn = sym + num; | ||
| _this[sn] = 1; | ||
| return sn; | ||
| }).replace(/n10+ = 0/g, 't0 && $&').replace(/(\w+ (!?)= )([0-9.]+,[0-9.,]+)/g, function (m, se, noteq, x) { | ||
| if (m === 'n = 0,1') return '(n == 0 || n == 1)'; | ||
| if (noteq) return se + x.split(',').join(' && ' + se); | ||
| return '(' + se + x.split(',').join(' || ' + se) + ')'; | ||
| }).replace(/(\w+) (!?)= ([0-9]+)\.\.([0-9]+)/g, function (m, sym, noteq, x0, x1) { | ||
| if (Number(x0) + 1 === Number(x1)) { | ||
| if (noteq) return '' + sym + ' != ' + x0 + ' && ' + sym + ' != ' + x1; | ||
| return '(' + sym + ' == ' + x0 + ' || ' + sym + ' == ' + x1 + ')'; | ||
| } | ||
| if (noteq) return '(' + sym + ' < ' + x0 + ' || ' + sym + ' > ' + x1 + ')'; | ||
| if (sym === 'n') { | ||
| _this.t0 = 1;return '(t0 && n >= ' + x0 + ' && n <= ' + x1 + ')'; | ||
| } | ||
| return '(' + sym + ' >= ' + x0 + ' && ' + sym + ' <= ' + x1 + ')'; | ||
| }).replace(/ and /g, ' && ').replace(/ or /g, ' || ').replace(/ = /g, ' == '); | ||
| } | ||
| }, { | ||
| key: 'vars', | ||
| value: (function (_vars) { | ||
| function vars() { | ||
| return _vars.apply(this, arguments); | ||
| } | ||
|
|
||
| vars.toString = function () { | ||
| return _vars.toString(); | ||
| }; | ||
|
|
||
| return vars; | ||
| })(function () { | ||
| var vars = []; | ||
| if (this.i) vars.push('i = s[0]'); | ||
| if (this.f || this.v) vars.push('f = s[1] || \'\''); | ||
| if (this.t) vars.push('t = (s[1] || \'\').replace(/0+$/, \'\')'); | ||
| if (this.v) vars.push('v = f.length'); | ||
| if (this.v0) vars.push('v0 = !s[1]'); | ||
| if (this.t0 || this.n10 || this.n100) vars.push('t0 = Number(s[0]) == n'); | ||
| for (var k in this) { | ||
| if (/^.10+$/.test(k)) { | ||
| var k0 = k[0] === 'n' ? 't0 && s[0]' : k[0]; | ||
| vars.push('' + k + ' = ' + k0 + '.slice(-' + k.substr(2).length + ')'); | ||
| } | ||
| }if (!vars.length) return ''; | ||
| return 'var ' + ['s = String(n).split(\'.\')'].concat(vars).join(', '); | ||
| }) | ||
| }]); | ||
|
|
||
| return Parser; | ||
| })(); | ||
|
|
||
|
|
||
|
|
||
| var MakePlural = (function () { | ||
| function MakePlural(lc) { | ||
| var _ref = arguments[1] === undefined ? MakePlural : arguments[1]; | ||
|
|
||
| var cardinals = _ref.cardinals; | ||
| var ordinals = _ref.ordinals; | ||
|
|
||
| _classCallCheck(this, MakePlural); | ||
|
|
||
| if (!cardinals && !ordinals) throw new Error('At least one type of plural is required'); | ||
| this.lc = lc; | ||
| this.categories = { cardinal: [], ordinal: [] }; | ||
| this.parser = new Parser(); | ||
|
|
||
| this.fn = this.buildFunction(cardinals, ordinals); | ||
| this.fn._obj = this; | ||
| this.fn.categories = this.categories; | ||
|
|
||
| this.fn.toString = this.fnToString.bind(this); | ||
| return this.fn; | ||
| } | ||
|
|
||
| _createClass(MakePlural, [{ | ||
| key: 'compile', | ||
| value: function compile(type, req) { | ||
| var cases = []; | ||
| var rules = MakePlural.rules[type][this.lc]; | ||
| if (!rules) { | ||
| if (req) throw new Error('Locale "' + this.lc + '" ' + type + ' rules not found'); | ||
| this.categories[type] = ['other']; | ||
| return '\'other\''; | ||
| } | ||
| for (var r in rules) { | ||
| var _rules$r$trim$split = rules[r].trim().split(/\s*@\w*/); | ||
|
|
||
| var _rules$r$trim$split2 = _toArray(_rules$r$trim$split); | ||
|
|
||
| var cond = _rules$r$trim$split2[0]; | ||
| var examples = _rules$r$trim$split2.slice(1); | ||
| var cat = r.replace('pluralRule-count-', ''); | ||
| if (cond) cases.push([this.parser.parse(cond), cat]); | ||
|
|
||
| } | ||
| this.categories[type] = cases.map(function (c) { | ||
| return c[1]; | ||
| }).concat('other'); | ||
| if (cases.length === 1) { | ||
| return '(' + cases[0][0] + ') ? \'' + cases[0][1] + '\' : \'other\''; | ||
| } else { | ||
| return [].concat(_toConsumableArray(cases.map(function (c) { | ||
| return '(' + c[0] + ') ? \'' + c[1] + '\''; | ||
| })), ['\'other\'']).join('\n : '); | ||
| } | ||
| } | ||
| }, { | ||
| key: 'buildFunction', | ||
| value: function buildFunction(cardinals, ordinals) { | ||
| var _this3 = this; | ||
|
|
||
| var compile = function compile(c) { | ||
| return c ? (c[1] ? 'return ' : 'if (ord) return ') + _this3.compile.apply(_this3, _toConsumableArray(c)) : ''; | ||
| }, | ||
| fold = { vars: function vars(str) { | ||
| return (' ' + str + ';').replace(/(.{1,78})(,|$) ?/g, '$1$2\n '); | ||
| }, | ||
| cond: function cond(str) { | ||
| return (' ' + str + ';').replace(/(.{1,78}) (\|\| |$) ?/gm, '$1\n $2'); | ||
| } }, | ||
| cond = [ordinals && ['ordinal', !cardinals], cardinals && ['cardinal', true]].map(compile).map(fold.cond), | ||
| body = [fold.vars(this.parser.vars())].concat(_toConsumableArray(cond)).join('\n').replace(/\s+$/gm, '').replace(/^[\s;]*[\r\n]+/gm, ''), | ||
| args = ordinals && cardinals ? 'n, ord' : 'n'; | ||
| return new Function(args, body); | ||
| } | ||
| }, { | ||
| key: 'fnToString', | ||
| value: function fnToString(name) { | ||
| return Function.prototype.toString.call(this.fn).replace(/^function( \w+)?/, name ? 'function ' + name : 'function').replace('\n/**/', ''); | ||
| } | ||
| }], [{ | ||
| key: 'load', | ||
| value: function load() { | ||
| for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
| args[_key] = arguments[_key]; | ||
| } | ||
|
|
||
| args.forEach(function (cldr) { | ||
| var data = cldr && cldr.supplemental || null; | ||
| if (!data) throw new Error('Data does not appear to be CLDR data'); | ||
| MakePlural.rules = { | ||
| cardinal: data['plurals-type-cardinal'] || MakePlural.rules.cardinal, | ||
| ordinal: data['plurals-type-ordinal'] || MakePlural.rules.ordinal | ||
| }; | ||
| }); | ||
| return MakePlural; | ||
| } | ||
| }]); | ||
|
|
||
| return MakePlural; | ||
| })(); | ||
|
|
||
|
|
||
|
|
||
| MakePlural.cardinals = true; | ||
| MakePlural.ordinals = false; | ||
| MakePlural.rules = { cardinal: {}, ordinal: {} }; | ||
|
|
||
|
|
||
| return MakePlural; | ||
| }()); | ||
| /* jshint ignore:end */ | ||
|
|
||
|
|
||
| var validateParameterTypeNumber = function( value, name ) { | ||
| validateParameterType( | ||
| value, | ||
| name, | ||
| value === undefined || typeof value === "number", | ||
| "Number" | ||
| ); | ||
| }; | ||
|
|
||
|
|
||
|
|
||
|
|
||
| var validateParameterTypePluralType = function( value, name ) { | ||
| validateParameterType( | ||
| value, | ||
| name, | ||
| value === undefined || value === "cardinal" || value === "ordinal", | ||
| "String \"cardinal\" or \"ordinal\"" | ||
| ); | ||
| }; | ||
|
|
||
|
|
||
|
|
||
|
|
||
| var pluralGeneratorFn = function( plural ) { | ||
| return function pluralGenerator( value ) { | ||
| validateParameterPresence( value, "value" ); | ||
| validateParameterTypeNumber( value, "value" ); | ||
|
|
||
| return plural( value ); | ||
| }; | ||
| }; | ||
|
|
||
|
|
||
|
|
||
|
|
||
| /** | ||
| * .plural( value ) | ||
| * | ||
| * @value [Number] | ||
| * | ||
| * Return the corresponding form (zero | one | two | few | many | other) of a | ||
| * value given locale. | ||
| */ | ||
| Globalize.plural = | ||
| Globalize.prototype.plural = function( value, options ) { | ||
| validateParameterPresence( value, "value" ); | ||
| validateParameterTypeNumber( value, "value" ); | ||
| return this.pluralGenerator( options )( value ); | ||
| }; | ||
|
|
||
| /** | ||
| * .pluralGenerator( [options] ) | ||
| * | ||
| * Return a plural function (of the form below). | ||
| * | ||
| * fn( value ) | ||
| * | ||
| * @value [Number] | ||
| * | ||
| * Return the corresponding form (zero | one | two | few | many | other) of a value given the | ||
| * default/instance locale. | ||
| */ | ||
| Globalize.pluralGenerator = | ||
| Globalize.prototype.pluralGenerator = function( options ) { | ||
| var args, cldr, isOrdinal, plural, returnFn, type; | ||
|
|
||
| validateParameterTypePlainObject( options, "options" ); | ||
|
|
||
| options = options || {}; | ||
| cldr = this.cldr; | ||
|
|
||
| args = [ options ]; | ||
| type = options.type || "cardinal"; | ||
|
|
||
| validateParameterTypePluralType( options.type, "options.type" ); | ||
|
|
||
| validateDefaultLocale( cldr ); | ||
|
|
||
| isOrdinal = type === "ordinal"; | ||
|
|
||
| cldr.on( "get", validateCldr ); | ||
| cldr.supplemental([ "plurals-type-" + type, "{language}" ]); | ||
| cldr.off( "get", validateCldr ); | ||
|
|
||
| MakePlural.rules = {}; | ||
| MakePlural.rules[ type ] = cldr.supplemental( "plurals-type-" + type ); | ||
|
|
||
| plural = new MakePlural( cldr.attributes.language, { | ||
| "ordinals": isOrdinal, | ||
| "cardinals": !isOrdinal | ||
| }); | ||
|
|
||
| returnFn = pluralGeneratorFn( plural ); | ||
|
|
||
| runtimeBind( args, cldr, returnFn, [ plural ] ); | ||
|
|
||
| return returnFn; | ||
| }; | ||
|
|
||
| return Globalize; | ||
|
|
||
|
|
||
|
|
||
|
|
||
| })); |
| @@ -0,0 +1,201 @@ | ||
| /** | ||
| * Globalize v1.2.2 | ||
| * | ||
| * http://github.com/jquery/globalize | ||
| * | ||
| * Copyright 2010, 2014 jQuery Foundation, Inc. and other contributors | ||
| * Released under the MIT license | ||
| * http://jquery.org/license | ||
| * | ||
| * Date: 2016-12-31T15:52Z | ||
| */ | ||
| /*! | ||
| * Globalize v1.2.2 2016-12-31T15:52Z Released under the MIT license | ||
| * http://git.io/TrdQbw | ||
| */ | ||
| (function( root, factory ) { | ||
|
|
||
| // UMD returnExports | ||
| if ( typeof define === "function" && define.amd ) { | ||
|
|
||
| // AMD | ||
| define([ | ||
| "cldr", | ||
| "../globalize", | ||
| "./number", | ||
| "./plural", | ||
| "cldr/event", | ||
| "cldr/supplemental" | ||
| ], factory ); | ||
| } else if ( typeof exports === "object" ) { | ||
|
|
||
| // Node, CommonJS | ||
| module.exports = factory( require( "cldrjs" ), require( "../globalize" ) ); | ||
| } else { | ||
|
|
||
| // Extend global | ||
| factory( root.Cldr, root.Globalize ); | ||
| } | ||
| }(this, function( Cldr, Globalize ) { | ||
|
|
||
| var formatMessage = Globalize._formatMessage, | ||
| runtimeBind = Globalize._runtimeBind, | ||
| validateCldr = Globalize._validateCldr, | ||
| validateDefaultLocale = Globalize._validateDefaultLocale, | ||
| validateParameterPresence = Globalize._validateParameterPresence, | ||
| validateParameterTypeString = Globalize._validateParameterTypeString, | ||
| validateParameterTypeNumber = Globalize._validateParameterTypeNumber; | ||
|
|
||
|
|
||
| /** | ||
| * format( value, numberFormatter, pluralGenerator, properties ) | ||
| * | ||
| * @value [Number] The number to format | ||
| * | ||
| * @numberFormatter [String] A numberFormatter from Globalize.numberFormatter | ||
| * | ||
| * @pluralGenerator [String] A pluralGenerator from Globalize.pluralGenerator | ||
| * | ||
| * @properties [Object] containing relative time plural message. | ||
| * | ||
| * Format relative time. | ||
| */ | ||
| var relativeTimeFormat = function( value, numberFormatter, pluralGenerator, properties ) { | ||
|
|
||
| var relativeTime, | ||
| message = properties[ "relative-type-" + value ]; | ||
|
|
||
| if ( message ) { | ||
| return message; | ||
| } | ||
|
|
||
| relativeTime = value <= 0 ? properties[ "relativeTime-type-past" ] | ||
| : properties[ "relativeTime-type-future" ]; | ||
|
|
||
| value = Math.abs( value ); | ||
|
|
||
| message = relativeTime[ "relativeTimePattern-count-" + pluralGenerator( value ) ]; | ||
| return formatMessage( message, [ numberFormatter( value ) ] ); | ||
| }; | ||
|
|
||
|
|
||
|
|
||
|
|
||
| var relativeTimeFormatterFn = function( numberFormatter, pluralGenerator, properties ) { | ||
| return function relativeTimeFormatter( value ) { | ||
| validateParameterPresence( value, "value" ); | ||
| validateParameterTypeNumber( value, "value" ); | ||
|
|
||
| return relativeTimeFormat( value, numberFormatter, pluralGenerator, properties ); | ||
| }; | ||
|
|
||
| }; | ||
|
|
||
|
|
||
|
|
||
|
|
||
| /** | ||
| * properties( unit, cldr, options ) | ||
| * | ||
| * @unit [String] eg. "day", "week", "month", etc. | ||
| * | ||
| * @cldr [Cldr instance]. | ||
| * | ||
| * @options [Object] | ||
| * - form: [String] eg. "short" or "narrow". Or falsy for default long form. | ||
| * | ||
| * Return relative time properties. | ||
| */ | ||
| var relativeTimeProperties = function( unit, cldr, options ) { | ||
|
|
||
| var form = options.form, | ||
| raw, properties, key, match; | ||
|
|
||
| if ( form ) { | ||
| unit = unit + "-" + form; | ||
| } | ||
|
|
||
| raw = cldr.main( [ "dates", "fields", unit ] ); | ||
| properties = { | ||
| "relativeTime-type-future": raw[ "relativeTime-type-future" ], | ||
| "relativeTime-type-past": raw[ "relativeTime-type-past" ] | ||
| }; | ||
| for ( key in raw ) { | ||
| if ( raw.hasOwnProperty( key ) ) { | ||
| match = /relative-type-(-?[0-9]+)/.exec( key ); | ||
| if ( match ) { | ||
| properties[ key ] = raw[ key ]; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| return properties; | ||
| }; | ||
|
|
||
|
|
||
|
|
||
|
|
||
| /** | ||
| * .formatRelativeTime( value, unit [, options] ) | ||
| * | ||
| * @value [Number] The number of unit to format. | ||
| * | ||
| * @unit [String] see .relativeTimeFormatter() for details. | ||
| * | ||
| * @options [Object] see .relativeTimeFormatter() for details. | ||
| * | ||
| * Formats a relative time according to the given unit, options, and the default/instance locale. | ||
| */ | ||
| Globalize.formatRelativeTime = | ||
| Globalize.prototype.formatRelativeTime = function( value, unit, options ) { | ||
| validateParameterPresence( value, "value" ); | ||
| validateParameterTypeNumber( value, "value" ); | ||
|
|
||
| return this.relativeTimeFormatter( unit, options )( value ); | ||
| }; | ||
|
|
||
| /** | ||
| * .relativeTimeFormatter( unit [, options ]) | ||
| * | ||
| * @unit [String] String value indicating the unit to be formatted. eg. "day", "week", "month", etc. | ||
| * | ||
| * @options [Object] | ||
| * - form: [String] eg. "short" or "narrow". Or falsy for default long form. | ||
| * | ||
| * Returns a function that formats a relative time according to the given unit, options, and the | ||
| * default/instance locale. | ||
| */ | ||
| Globalize.relativeTimeFormatter = | ||
| Globalize.prototype.relativeTimeFormatter = function( unit, options ) { | ||
| var args, cldr, numberFormatter, pluralGenerator, properties, returnFn; | ||
|
|
||
| validateParameterPresence( unit, "unit" ); | ||
| validateParameterTypeString( unit, "unit" ); | ||
|
|
||
| cldr = this.cldr; | ||
| options = options || {}; | ||
|
|
||
| args = [ unit, options ]; | ||
|
|
||
| validateDefaultLocale( cldr ); | ||
|
|
||
| cldr.on( "get", validateCldr ); | ||
| properties = relativeTimeProperties( unit, cldr, options ); | ||
| cldr.off( "get", validateCldr ); | ||
|
|
||
| numberFormatter = this.numberFormatter( options ); | ||
| pluralGenerator = this.pluralGenerator(); | ||
|
|
||
| returnFn = relativeTimeFormatterFn( numberFormatter, pluralGenerator, properties ); | ||
|
|
||
| runtimeBind( args, cldr, returnFn, [ numberFormatter, pluralGenerator, properties ] ); | ||
|
|
||
| return returnFn; | ||
| }; | ||
|
|
||
| return Globalize; | ||
|
|
||
|
|
||
|
|
||
|
|
||
| })); |
| @@ -0,0 +1,300 @@ | ||
| /** | ||
| * Globalize v1.2.2 | ||
| * | ||
| * http://github.com/jquery/globalize | ||
| * | ||
| * Copyright 2010, 2014 jQuery Foundation, Inc. and other contributors | ||
| * Released under the MIT license | ||
| * http://jquery.org/license | ||
| * | ||
| * Date: 2016-12-31T15:52Z | ||
| */ | ||
| /*! | ||
| * Globalize v1.2.2 2016-12-31T15:52Z Released under the MIT license | ||
| * http://git.io/TrdQbw | ||
| */ | ||
| (function( root, factory ) { | ||
|
|
||
| // UMD returnExports | ||
| if ( typeof define === "function" && define.amd ) { | ||
|
|
||
| // AMD | ||
| define([ | ||
| "cldr", | ||
| "../globalize", | ||
| "./number", | ||
| "./plural" | ||
| ], factory ); | ||
| } else if ( typeof exports === "object" ) { | ||
|
|
||
| // Node, CommonJS | ||
| module.exports = factory( require( "cldrjs" ), require( "../globalize" ) ); | ||
| } else { | ||
|
|
||
| // Extend global | ||
| factory( root.Cldr, root.Globalize ); | ||
| } | ||
| }(this, function( Cldr, Globalize ) { | ||
|
|
||
| var formatMessage = Globalize._formatMessage, | ||
| runtimeBind = Globalize._runtimeBind, | ||
| validateParameterPresence = Globalize._validateParameterPresence, | ||
| validateParameterTypePlainObject = Globalize._validateParameterTypePlainObject, | ||
| validateParameterTypeNumber = Globalize._validateParameterTypeNumber, | ||
| validateParameterTypeString = Globalize._validateParameterTypeString; | ||
|
|
||
|
|
||
| /** | ||
| * format( value, numberFormatter, pluralGenerator, unitProperies ) | ||
| * | ||
| * @value [Number] | ||
| * | ||
| * @numberFormatter [Object]: A numberFormatter from Globalize.numberFormatter. | ||
| * | ||
| * @pluralGenerator [Object]: A pluralGenerator from Globalize.pluralGenerator. | ||
| * | ||
| * @unitProperies [Object]: localized unit data from cldr. | ||
| * | ||
| * Format units such as seconds, minutes, days, weeks, etc. | ||
| * | ||
| * OBS: | ||
| * | ||
| * Unit Sequences are not implemented. | ||
| * http://www.unicode.org/reports/tr35/tr35-35/tr35-general.html#Unit_Sequences | ||
| * | ||
| * Duration Unit (for composed time unit durations) is not implemented. | ||
| * http://www.unicode.org/reports/tr35/tr35-35/tr35-general.html#durationUnit | ||
| */ | ||
| 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 ); | ||
|
|
||
| // computed compound unit, eg. "megabyte-per-second". | ||
| 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 ); | ||
| }; | ||
|
|
||
| }; | ||
|
|
||
|
|
||
|
|
||
|
|
||
| /** | ||
| * categories() | ||
| * | ||
| * Return all unit categories. | ||
| */ | ||
| var unitCategories = [ "acceleration", "angle", "area", "digital", "duration", "length", "mass", "power", | ||
| "pressure", "speed", "temperature", "volume" ]; | ||
|
|
||
|
|
||
|
|
||
|
|
||
| function stripPluralGarbage( data ) { | ||
| var aux, pluralCount; | ||
|
|
||
| if ( data ) { | ||
| aux = {}; | ||
| for ( pluralCount in data ) { | ||
| aux[ pluralCount.replace( /unitPattern-count-/, "" ) ] = data[ pluralCount ]; | ||
| } | ||
| } | ||
|
|
||
| return aux; | ||
| } | ||
|
|
||
| /** | ||
| * get( unit, form, cldr ) | ||
| * | ||
| * @unit [String] The full type-unit name (eg. duration-second), or the short unit name | ||
| * (eg. second). | ||
| * | ||
| * @form [String] A string describing the form of the unit representation (eg. long, | ||
| * short, narrow). | ||
| * | ||
| * @cldr [Cldr instance]. | ||
| * | ||
| * Return the plural map of a unit, eg: "second" | ||
| * { "one": "{0} second", | ||
| * "other": "{0} seconds" } | ||
| * } | ||
| * | ||
| * Or the Array of plural maps of a compound-unit, eg: "foot-per-second" | ||
| * [ { "one": "{0} foot", | ||
| * "other": "{0} feet" }, | ||
| * { "one": "{0} second", | ||
| * "other": "{0} seconds" } ] | ||
| * | ||
| * Uses the precomputed form of a compound-unit if available, eg: "mile-per-hour" | ||
| * { "displayName": "miles per hour", | ||
| * "unitPattern-count-one": "{0} mile per hour", | ||
| * "unitPattern-count-other": "{0} miles per hour" | ||
| * }, | ||
| * | ||
| * Also supports "/" instead of "-per-", eg. "foot/second", using the precomputed form if | ||
| * available. | ||
| * | ||
| * Or the Array of plural maps of a compound-unit, eg: "foot-per-second" | ||
| * [ { "one": "{0} foot", | ||
| * "other": "{0} feet" }, | ||
| * { "one": "{0} second", | ||
| * "other": "{0} seconds" } ] | ||
| * | ||
| * Or undefined in case the unit (or a unit of the compound-unit) doesn't exist. | ||
| */ | ||
| var get = function( unit, form, cldr ) { | ||
| var ret; | ||
|
|
||
| // Ensure that we get the 'precomputed' form, if present. | ||
| unit = unit.replace( /\//, "-per-" ); | ||
|
|
||
| // Get unit or <category>-unit (eg. "duration-second"). | ||
| [ "" ].concat( unitCategories ).some(function( category ) { | ||
| return ret = cldr.main([ | ||
| "units", | ||
| form, | ||
| category.length ? category + "-" + unit : unit | ||
| ]); | ||
| }); | ||
|
|
||
| // Rename keys s/unitPattern-count-//g. | ||
| ret = stripPluralGarbage( ret ); | ||
|
|
||
| // Compound Unit, eg. "foot-per-second" or "foot/second". | ||
| if ( !ret && ( /-per-/ ).test( unit ) ) { | ||
|
|
||
| // "Some units already have 'precomputed' forms, such as kilometer-per-hour; | ||
| // where such units exist, they should be used in preference" UTS#35. | ||
| // Note that precomputed form has already been handled above (!ret). | ||
|
|
||
| // Get both recursively. | ||
| unit = unit.split( "-per-" ); | ||
| ret = unit.map(function( unit ) { | ||
| return get( unit, form, cldr ); | ||
| }); | ||
| if ( !ret[ 0 ] || !ret[ 1 ] ) { | ||
| return; | ||
| } | ||
| } | ||
|
|
||
| return ret; | ||
| }; | ||
|
|
||
| var unitGet = get; | ||
|
|
||
|
|
||
|
|
||
|
|
||
| /** | ||
| * properties( unit, form, cldr ) | ||
| * | ||
| * @unit [String] The full type-unit name (eg. duration-second), or the short unit name | ||
| * (eg. second). | ||
| * | ||
| * @form [String] A string describing the form of the unit representation (eg. long, | ||
| * short, narrow). | ||
| * | ||
| * @cldr [Cldr instance]. | ||
| */ | ||
| var unitProperties = function( unit, form, cldr ) { | ||
| var compoundUnitPattern, unitProperties; | ||
|
|
||
| compoundUnitPattern = cldr.main( [ "units", form, "per/compoundUnitPattern" ] ); | ||
| unitProperties = unitGet( unit, form, cldr ); | ||
|
|
||
| return { | ||
| compoundUnitPattern: compoundUnitPattern, | ||
| unitProperties: unitProperties | ||
| }; | ||
| }; | ||
|
|
||
|
|
||
|
|
||
|
|
||
| /** | ||
| * Globalize.formatUnit( value, unit, options ) | ||
| * | ||
| * @value [Number] | ||
| * | ||
| * @unit [String]: The unit (e.g "second", "day", "year") | ||
| * | ||
| * @options [Object] | ||
| * - form: [String] "long", "short" (default), or "narrow". | ||
| * | ||
| * Format units such as seconds, minutes, days, weeks, etc. | ||
| */ | ||
| Globalize.formatUnit = | ||
| Globalize.prototype.formatUnit = function( value, unit, options ) { | ||
| validateParameterPresence( value, "value" ); | ||
| validateParameterTypeNumber( value, "value" ); | ||
|
|
||
| return this.unitFormatter( unit, options )( value ); | ||
| }; | ||
|
|
||
| /** | ||
| * Globalize.unitFormatter( unit, options ) | ||
| * | ||
| * @unit [String]: The unit (e.g "second", "day", "year") | ||
| * | ||
| * @options [Object] | ||
| * - form: [String] "long", "short" (default), or "narrow". | ||
| * | ||
| * - numberFormatter: [Function] a number formatter function. Defaults to Globalize | ||
| * `.numberFormatter()` for the current locale using the default options. | ||
| */ | ||
| Globalize.unitFormatter = | ||
| Globalize.prototype.unitFormatter = function( unit, options ) { | ||
| var args, form, numberFormatter, pluralGenerator, returnFn, properties; | ||
|
|
||
| validateParameterPresence( unit, "unit" ); | ||
| validateParameterTypeString( unit, "unit" ); | ||
|
|
||
| validateParameterTypePlainObject( options, "options" ); | ||
|
|
||
| options = options || {}; | ||
|
|
||
| args = [ unit, options ]; | ||
| form = options.form || "long"; | ||
| properties = unitProperties( unit, form, this.cldr ); | ||
|
|
||
| numberFormatter = options.numberFormatter || this.numberFormatter(); | ||
| pluralGenerator = this.pluralGenerator(); | ||
| returnFn = unitFormatterFn( numberFormatter, pluralGenerator, properties ); | ||
|
|
||
| runtimeBind( args, this.cldr, returnFn, [ numberFormatter, pluralGenerator, properties ] ); | ||
|
|
||
| return returnFn; | ||
| }; | ||
|
|
||
| return Globalize; | ||
|
|
||
|
|
||
|
|
||
|
|
||
| })); |
| @@ -0,0 +1,27 @@ | ||
| /*! | ||
| * Globalize v1.2.2 | ||
| * | ||
| * http://github.com/jquery/globalize | ||
| * | ||
| * Copyright jQuery Foundation and other contributors | ||
| * Released under the MIT license | ||
| * http://jquery.org/license | ||
| * | ||
| * Date: 2016-12-31T15:52Z | ||
| */ | ||
|
|
||
| // Core | ||
| module.exports = require( "./globalize" ); | ||
|
|
||
| // Extent core with the following modules | ||
| require( "./globalize/message" ); | ||
| require( "./globalize/number" ); | ||
| require( "./globalize/plural" ); | ||
|
|
||
| // Load after globalize/number | ||
| require( "./globalize/currency" ); | ||
| require( "./globalize/date" ); | ||
|
|
||
| // Load after globalize/number and globalize/plural | ||
| require( "./globalize/relative-time" ); | ||
| require( "./globalize/unit" ); |