Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cldrjs

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cldrjs - npm Package Compare versions

Comparing version 0.5.2 to 0.5.3

dist/.build/.dist_jshintrc

689

dist/cldr.js

@@ -0,5 +1,690 @@

/**
* CLDR JavaScript Library v0.5.1
* http://jquery.com/
*
* Copyright 2013 Rafael Xavier de Souza
* Released under the MIT license
* http://jquery.org/license
*
* Date: 2020-08-05T21:05Z
*/
/*!
* CLDR JavaScript Library v0.5.2 2020-08-05T12:51Z MIT license © Rafael Xavier
* CLDR JavaScript Library v0.5.1 2020-08-05T21:05Z MIT license © Rafael Xavier
* http://git.io/h4lmVg
*/
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Cldr=t():e.Cldr=t()}("undefined"!=typeof self?self:this,(function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t,n){"use strict";n.r(t);var r=function(e,t){var n,r;if(e.some)return e.some(t);for(n=0,r=e.length;n<r;n++)if(t(e[n],n,e))return!0;return!1},o=function(e,t,n,o){var i,u=n[0],a=n[1],l=e.localeSep,c=n[2],f=n.slice(3,4);return o=o||{},"und"!==u&&"Zzzz"!==a&&"ZZ"!==c?[u,a,c].concat(f):void 0!==t.get("supplemental/likelySubtags")?r([[u,a,c],[u,c],[u,a],[u],["und",a]],(function(e){return i=!/\b(Zzzz|ZZ)\b/.test(e.join(l))&&t.get(["supplemental/likelySubtags",e.join(l)])}))?(i=i.split(l),["und"!==u?u:i[0],"Zzzz"!==a?a:i[1],"ZZ"!==c?c:i[2]].concat(f)):o.force?t.get("supplemental/likelySubtags/und").split(l):void 0:void 0},i=function(e,t,n){var i,u=n[0],a=n[1],l=n[2],c=n[3];return r([[[u,"Zzzz","ZZ"],[u]],[[u,"Zzzz",l],[u,l]],[[u,a,"ZZ"],[u,a]]],(function(r){var u=o(e,t,r[0]);return i=r[1],u&&u[0]===n[0]&&u[1]===n[1]&&u[2]===n[2]}))?(c&&i.push(c),i):n},u=function(e){var t,n=[];return(t=(e=e.replace(/_/,"-")).split("-u-"))[1]&&(t[1]=t[1].split("-t-"),e=t[0]+(t[1][1]?"-t-"+t[1][1]:""),n[4]=t[1][0]),null===(t=e.split("-t-")[0].match(/^(([a-z]{2,3})(-([A-Z][a-z]{3}))?(-([A-Z]{2}|[0-9]{3}))?)((-([a-zA-Z0-9]{5,8}|[0-9][a-zA-Z0-9]{3}))*)$|^(root)$/))?["und","Zzzz","ZZ"]:(n[0]=t[10]||t[2]||"und",n[1]=t[4]||"Zzzz",n[2]=t[6]||"ZZ",t[7]&&t[7].length&&(n[3]=t[7].slice(1)),n)},a=function(e,t,n){var r=e._availableBundleMap,a=e._availableBundleMapQueue;if(a.length)for(;a.length>0;){const n=a.shift();if(!n)break;var l,c,f,p;if(p=u(n),void 0===(c=o(e,t,p)))throw new Error("Could not find likelySubtags for "+n);if((l=r[f=(f=i(e,t,c)).join(e.localeSep)])&&l.length<n.length)return;r[f]=n}return r[n]||null},l=function(e,t){var n,r;if(e.forEach)return e.forEach(t);for(n=0,r=e.length;n<r;n++)t(e[n],n,e)},c=function(e,t){var n,r;return r=e+(t&&JSON?": "+JSON.stringify(t):""),(n=new Error(r)).code=e,l(function(e){var t,n=[];if(Object.keys)return Object.keys(e);for(t in e)n.push(t);return n}(t),(function(e){n[e]=t[e]})),n},f=function(e,t,n){if(!t)throw c(e,n)},p=function(e,t){f("E_MISSING_PARAMETER",void 0!==e,{name:t})},s=function(e,t,n,r){f("E_INVALID_PAR_TYPE",n,{expected:r,name:t,value:e})},d=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)},v=function(e,t){s(e,t,"string"==typeof e||d(e),"String or Array")},b=function(e,t){var n;s(e,t,void 0===e||null!==(n=e)&&""+n=="[object Object]","Plain Object")},g=function(e,t){var n,r=e,o=t.length;for(n=0;n<o-1;n++)if(!(r=r[t[n]]))return;return r[t[n]]},y=function(e,t){var n,r=e._availableBundleMapQueue,o=g(t,["main"]);if(o)for(n in o)o.hasOwnProperty(n)&&"root"!==n&&-1===r.indexOf(n)&&r.push(n)},h=function(e){return d(e)?e:[e]},_=function(){var e={},t=[].slice.call(arguments,0);return l(t,(function(t){var n;for(n in t)n in e&&"object"==typeof e[n]&&!d(e[n])?e[n]=_(e[n],t[n]):e[n]=t[n]})),e},z=_,j=function(e,t,n){var r,o,i;for(p(n[0],"json"),r=0;r<n.length;r++)for(i=h(n[r]),o=0;o<i.length;o++)b(i[o],"json"),t=z(t,i[o]),y(e,i[o]);return t},Z=function(e,t){if(d(e)&&(e=e.join("/")),"string"!=typeof e)throw new Error('invalid path "'+e+'"');return(e=(e=e.replace(/^\//,"").replace(/^cldr\//,"")).replace(/{[a-zA-Z]+}/g,(function(e){return e=e.replace(/^{([^}]*)}$/,"$1"),t[e]}))).split("/")},m=function(e,t,n){var r=Z(t,n);return g(e._resolved,r)},S=function(e){this.init(e)};S._alwaysArray=h,S._coreLoad=j,S._createError=c,S._itemGetResolved=m,S._jsonMerge=z,S._pathNormalize=Z,S._resourceGet=g,S._validatePresence=p,S._validateType=s,S._validateTypePath=v,S._validateTypePlainObject=b,S._availableBundleMap={},S._availableBundleMapQueue=[],S._resolved={},S.localeSep="-",S.load=function(){S._resolved=j(S,S._resolved,arguments)},S.prototype.init=function(e){var t,n,r,l,c,f,d,v,b,g,y=S.localeSep,h="";p(e,"locale"),s(g=e,"locale","string"==typeof g,"a string"),5===(f=u(e)).length&&(h=y+"u"+y+(v=f.pop()),f[3]||f.pop()),b=f[3],n=(r=o(S,this,f,{force:!0})||f)[0],c=r[1],d=r[2],l=i(S,this,r).join(y),this.attributes=t={bundle:a(S,this,l),minLanguageId:l+h,maxLanguageId:r.join(y)+h,language:n,script:c,territory:d,region:d,variant:b},v&&("-"+v).replace(/-[a-z]{3,8}|(-[a-z]{2})-([a-z]{3,8})/g,(function(e,n,r){n?t["u"+n]=r:t["u"+e]=!0})),this.locale=e},S.prototype.get=function(e){return p(e,"path"),v(e,"path"),m(S,e,this.attributes)},S.prototype.main=function(e){return p(e,"path"),v(e,"path"),f("E_MISSING_BUNDLE",null!==this.attributes.bundle,{locale:this.locale}),e=h(e),this.get(["main/{bundle}"].concat(e))};t.default=S}]).default}));
(function( root, factory ) {
if ( typeof define === "function" && define.amd ) {
// AMD.
define( factory );
} else if ( typeof module === "object" && typeof module.exports === "object" ) {
// Node. CommonJS.
module.exports = factory();
} else {
// Global
root.Cldr = factory();
}
}( this, function() {
var arrayIsArray = Array.isArray || function( obj ) {
return Object.prototype.toString.call( obj ) === "[object Array]";
};
var pathNormalize = function( path, attributes ) {
if ( arrayIsArray( path ) ) {
path = path.join( "/" );
}
if ( typeof path !== "string" ) {
throw new Error( "invalid path \"" + path + "\"" );
}
// 1: Ignore leading slash `/`
// 2: Ignore leading `cldr/`
path = path
.replace( /^\// , "" ) /* 1 */
.replace( /^cldr\// , "" ); /* 2 */
// Replace {attribute}'s
path = path.replace( /{[a-zA-Z]+}/g, function( name ) {
name = name.replace( /^{([^}]*)}$/, "$1" );
return attributes[ name ];
});
return path.split( "/" );
};
var arraySome = function( array, callback ) {
var i, length;
if ( array.some ) {
return array.some( callback );
}
for ( i = 0, length = array.length; i < length; i++ ) {
if ( callback( array[ i ], i, array ) ) {
return true;
}
}
return false;
};
/**
* Return the maximized language id as defined in
* http://www.unicode.org/reports/tr35/#Likely_Subtags
* 1. Canonicalize.
* 1.1 Make sure the input locale is in canonical form: uses the right
* separator, and has the right casing.
* TODO Right casing? What df? It seems languages are lowercase, scripts are
* Capitalized, territory is uppercase. I am leaving this as an exercise to
* the user.
*
* 1.2 Replace any deprecated subtags with their canonical values using the
* <alias> data in supplemental metadata. Use the first value in the
* replacement list, if it exists. Language tag replacements may have multiple
* parts, such as "sh" ➞ "sr_Latn" or mo" ➞ "ro_MD". In such a case, the
* original script and/or region are retained if there is one. Thus
* "sh_Arab_AQ" ➞ "sr_Arab_AQ", not "sr_Latn_AQ".
* TODO What <alias> data?
*
* 1.3 If the tag is grandfathered (see <variable id="$grandfathered"
* type="choice"> in the supplemental data), then return it.
* TODO grandfathered?
*
* 1.4 Remove the script code 'Zzzz' and the region code 'ZZ' if they occur.
* 1.5 Get the components of the cleaned-up source tag (languages, scripts,
* and regions), plus any variants and extensions.
* 2. Lookup. Lookup each of the following in order, and stop on the first
* match:
* 2.1 languages_scripts_regions
* 2.2 languages_regions
* 2.3 languages_scripts
* 2.4 languages
* 2.5 und_scripts
* 3. Return
* 3.1 If there is no match, either return an error value, or the match for
* "und" (in APIs where a valid language tag is required).
* 3.2 Otherwise there is a match = languagem_scriptm_regionm
* 3.3 Let xr = xs if xs is not empty, and xm otherwise.
* 3.4 Return the language tag composed of languager _ scriptr _ regionr +
* variants + extensions.
*
* @subtags [Array] normalized language id subtags tuple (see init.js).
*/
var coreLikelySubtags = function( Cldr, cldr, subtags, options ) {
var match, matchFound,
language = subtags[ 0 ],
script = subtags[ 1 ],
sep = Cldr.localeSep,
territory = subtags[ 2 ],
variants = subtags.slice( 3, 4 );
options = options || {};
// Skip if (language, script, territory) is not empty [3.3]
if ( language !== "und" && script !== "Zzzz" && territory !== "ZZ" ) {
return [ language, script, territory ].concat( variants );
}
// Skip if no supplemental likelySubtags data is present
if ( typeof cldr.get( "supplemental/likelySubtags" ) === "undefined" ) {
return;
}
// [2]
matchFound = arraySome([
[ language, script, territory ],
[ language, territory ],
[ language, script ],
[ language ],
[ "und", script ]
], function( test ) {
return match = !(/\b(Zzzz|ZZ)\b/).test( test.join( sep ) ) /* [1.4] */ && cldr.get( [ "supplemental/likelySubtags", test.join( sep ) ] );
});
// [3]
if ( matchFound ) {
// [3.2 .. 3.4]
match = match.split( sep );
return [
language !== "und" ? language : match[ 0 ],
script !== "Zzzz" ? script : match[ 1 ],
territory !== "ZZ" ? territory : match[ 2 ]
].concat( variants );
} else if ( options.force ) {
// [3.1.2]
return cldr.get( "supplemental/likelySubtags/und" ).split( sep );
} else {
// [3.1.1]
return;
}
};
/**
* Given a locale, remove any fields that Add Likely Subtags would add.
* http://www.unicode.org/reports/tr35/#Likely_Subtags
* 1. First get max = AddLikelySubtags(inputLocale). If an error is signaled,
* return it.
* 2. Remove the variants from max.
* 3. Then for trial in {language, language _ region, language _ script}. If
* AddLikelySubtags(trial) = max, then return trial + variants.
* 4. If you do not get a match, return max + variants.
*
* @maxLanguageId [Array] maxLanguageId tuple (see init.js).
*/
var coreRemoveLikelySubtags = function( Cldr, cldr, maxLanguageId ) {
var match, matchFound,
language = maxLanguageId[ 0 ],
script = maxLanguageId[ 1 ],
territory = maxLanguageId[ 2 ],
variants = maxLanguageId[ 3 ];
// [3]
matchFound = arraySome([
[ [ language, "Zzzz", "ZZ" ], [ language ] ],
[ [ language, "Zzzz", territory ], [ language, territory ] ],
[ [ language, script, "ZZ" ], [ language, script ] ]
], function( test ) {
var result = coreLikelySubtags( Cldr, cldr, test[ 0 ] );
match = test[ 1 ];
return result && result[ 0 ] === maxLanguageId[ 0 ] &&
result[ 1 ] === maxLanguageId[ 1 ] &&
result[ 2 ] === maxLanguageId[ 2 ];
});
if ( matchFound ) {
if ( variants ) {
match.push( variants );
}
return match;
}
// [4]
return maxLanguageId;
};
/**
* subtags( locale )
*
* @locale [String]
*/
var coreSubtags = function( locale ) {
var aux, unicodeLanguageId,
subtags = [];
locale = locale.replace( /_/, "-" );
// Unicode locale extensions.
aux = locale.split( "-u-" );
if ( aux[ 1 ] ) {
aux[ 1 ] = aux[ 1 ].split( "-t-" );
locale = aux[ 0 ] + ( aux[ 1 ][ 1 ] ? "-t-" + aux[ 1 ][ 1 ] : "");
subtags[ 4 /* unicodeLocaleExtensions */ ] = aux[ 1 ][ 0 ];
}
// TODO normalize transformed extensions. Currently, skipped.
// subtags[ x ] = locale.split( "-t-" )[ 1 ];
unicodeLanguageId = locale.split( "-t-" )[ 0 ];
// unicode_language_id = "root"
// | unicode_language_subtag
// (sep unicode_script_subtag)?
// (sep unicode_region_subtag)?
// (sep unicode_variant_subtag)* ;
//
// Although unicode_language_subtag = alpha{2,8}, I'm using alpha{2,3}. Because, there's no language on CLDR lengthier than 3.
aux = unicodeLanguageId.match( /^(([a-z]{2,3})(-([A-Z][a-z]{3}))?(-([A-Z]{2}|[0-9]{3}))?)((-([a-zA-Z0-9]{5,8}|[0-9][a-zA-Z0-9]{3}))*)$|^(root)$/ );
if ( aux === null ) {
return [ "und", "Zzzz", "ZZ" ];
}
subtags[ 0 /* language */ ] = aux[ 10 ] /* root */ || aux[ 2 ] || "und";
subtags[ 1 /* script */ ] = aux[ 4 ] || "Zzzz";
subtags[ 2 /* territory */ ] = aux[ 6 ] || "ZZ";
if ( aux[ 7 ] && aux[ 7 ].length ) {
subtags[ 3 /* variant */ ] = aux[ 7 ].slice( 1 ) /* remove leading "-" */;
}
// 0: language
// 1: script
// 2: territory (aka region)
// 3: variant
// 4: unicodeLocaleExtensions
return subtags;
};
/**
* bundleLookup( minLanguageId )
*
* @Cldr [Cldr class]
*
* @cldr [Cldr instance]
*
* @minLanguageId [String] requested languageId after applied remove likely subtags.
*/
var bundleLookup = function( Cldr, cldr, minLanguageId ) {
var availableBundleMap = Cldr._availableBundleMap,
availableBundleMapQueue = Cldr._availableBundleMapQueue;
if (availableBundleMapQueue.length) {
while (availableBundleMapQueue.length > 0) {
const bundle = availableBundleMapQueue.shift();
if (!bundle) {
break;
}
var existing, maxBundle, minBundle, subtags;
subtags = coreSubtags(bundle);
maxBundle = coreLikelySubtags(Cldr, cldr, subtags);
if (typeof maxBundle === "undefined") {
throw new Error(`Could not find likelySubtags for ${bundle}`);
}
minBundle = coreRemoveLikelySubtags(Cldr, cldr, maxBundle);
minBundle = minBundle.join(Cldr.localeSep);
existing = availableBundleMap[minBundle];
if (existing && existing.length < bundle.length) {
return;
}
availableBundleMap[minBundle] = bundle;
}
}
return availableBundleMap[ minLanguageId ] || null;
};
var arrayForEach = function( array, callback ) {
var i, length;
if ( array.forEach ) {
return array.forEach( callback );
}
for ( i = 0, length = array.length; i < length; i++ ) {
callback( array[ i ], i, array );
}
};
var objectKeys = function( object ) {
var i,
result = [];
if ( Object.keys ) {
return Object.keys( object );
}
for ( i in object ) {
result.push( i );
}
return result;
};
var createError = function( code, attributes ) {
var error, message;
message = code + ( attributes && JSON ? ": " + JSON.stringify( attributes ) : "" );
error = new Error( message );
error.code = code;
// extend( error, attributes );
arrayForEach( objectKeys( attributes ), function( attribute ) {
error[ attribute ] = attributes[ attribute ];
});
return error;
};
var validate = function( code, check, attributes ) {
if ( !check ) {
throw createError( code, attributes );
}
};
var validatePresence = function( value, name ) {
validate( "E_MISSING_PARAMETER", typeof value !== "undefined", {
name: name
});
};
var validateType = function( value, name, check, expected ) {
validate( "E_INVALID_PAR_TYPE", check, {
expected: expected,
name: name,
value: value
});
};
var validateTypePath = function( value, name ) {
validateType( value, name, typeof value === "string" || arrayIsArray( value ), "String or Array" );
};
/**
* Function inspired by jQuery Core, but reduced to our use case.
*/
var isPlainObject = function( obj ) {
return obj !== null && "" + obj === "[object Object]";
};
var validateTypePlainObject = function( value, name ) {
validateType( value, name, typeof value === "undefined" || isPlainObject( value ), "Plain Object" );
};
var validateTypeString = function( value, name ) {
validateType( value, name, typeof value === "string", "a string" );
};
// @path: normalized path
var resourceGet = function( data, path ) {
var i,
node = data,
length = path.length;
for ( i = 0; i < length - 1; i++ ) {
node = node[ path[ i ] ];
if ( !node ) {
return undefined;
}
}
return node[ path[ i ] ];
};
/**
* setAvailableBundles( Cldr, json )
*
* @Cldr [Cldr class]
*
* @json resolved/unresolved cldr data.
*
* Set available bundles queue based on passed json CLDR data. Considers a bundle as any String at /main/{bundle}.
*/
var coreSetAvailableBundles = function( Cldr, json ) {
var bundle,
availableBundleMapQueue = Cldr._availableBundleMapQueue,
main = resourceGet( json, [ "main" ] );
if ( main ) {
for ( bundle in main ) {
if ( main.hasOwnProperty( bundle ) && bundle !== "root" &&
availableBundleMapQueue.indexOf( bundle ) === -1 ) {
availableBundleMapQueue.push( bundle );
}
}
}
};
var alwaysArray = function( somethingOrArray ) {
return arrayIsArray( somethingOrArray ) ? somethingOrArray : [ somethingOrArray ];
};
var jsonMerge = (function() {
// Returns new deeply merged JSON.
//
// Eg.
// merge( { a: { b: 1, c: 2 } }, { a: { b: 3, d: 4 } } )
// -> { a: { b: 3, c: 2, d: 4 } }
//
// @arguments JSON's
//
var merge = function() {
var destination = {},
sources = [].slice.call( arguments, 0 );
arrayForEach( sources, function( source ) {
var prop;
for ( prop in source ) {
if ( prop in destination && typeof destination[ prop ] === "object" && !arrayIsArray( destination[ prop ] ) ) {
// Merge Objects
destination[ prop ] = merge( destination[ prop ], source[ prop ] );
} else {
// Set new values
destination[ prop ] = source[ prop ];
}
}
});
return destination;
};
return merge;
}());
/**
* load( Cldr, source, jsons )
*
* @Cldr [Cldr class]
*
* @source [Object]
*
* @jsons [arguments]
*/
var coreLoad = function( Cldr, source, jsons ) {
var i, j, json;
validatePresence( jsons[ 0 ], "json" );
// Support arbitrary parameters, e.g., `Cldr.load({...}, {...})`.
for ( i = 0; i < jsons.length; i++ ) {
// Support array parameters, e.g., `Cldr.load([{...}, {...}])`.
json = alwaysArray( jsons[ i ] );
for ( j = 0; j < json.length; j++ ) {
validateTypePlainObject( json[ j ], "json" );
source = jsonMerge( source, json[ j ] );
coreSetAvailableBundles( Cldr, json[ j ] );
}
}
return source;
};
var itemGetResolved = function( Cldr, path, attributes ) {
// Resolve path
var normalizedPath = pathNormalize( path, attributes );
return resourceGet( Cldr._resolved, normalizedPath );
};
/**
* new Cldr()
*/
var Cldr = function( locale ) {
this.init( locale );
};
// Build optimization hack to avoid duplicating functions across modules.
Cldr._alwaysArray = alwaysArray;
Cldr._coreLoad = coreLoad;
Cldr._createError = createError;
Cldr._itemGetResolved = itemGetResolved;
Cldr._jsonMerge = jsonMerge;
Cldr._pathNormalize = pathNormalize;
Cldr._resourceGet = resourceGet;
Cldr._validatePresence = validatePresence;
Cldr._validateType = validateType;
Cldr._validateTypePath = validateTypePath;
Cldr._validateTypePlainObject = validateTypePlainObject;
Cldr._availableBundleMap = {};
Cldr._availableBundleMapQueue = [];
Cldr._resolved = {};
// Allow user to override locale separator "-" (default) | "_". According to http://www.unicode.org/reports/tr35/#Unicode_language_identifier, both "-" and "_" are valid locale separators (eg. "en_GB", "en-GB"). According to http://unicode.org/cldr/trac/ticket/6786 its usage must be consistent throughout the data set.
Cldr.localeSep = "-";
/**
* Cldr.load( json [, json, ...] )
*
* @json [JSON] CLDR data or [Array] Array of @json's.
*
* Load resolved cldr data.
*/
Cldr.load = function() {
Cldr._resolved = coreLoad( Cldr, Cldr._resolved, arguments );
};
/**
* .init() automatically run on instantiation/construction.
*/
Cldr.prototype.init = function( locale ) {
var attributes, language, maxLanguageId, minLanguageId, script, subtags, territory, unicodeLocaleExtensions, variant,
sep = Cldr.localeSep,
unicodeLocaleExtensionsRaw = "";
validatePresence( locale, "locale" );
validateTypeString( locale, "locale" );
subtags = coreSubtags( locale );
if ( subtags.length === 5 ) {
unicodeLocaleExtensions = subtags.pop();
unicodeLocaleExtensionsRaw = sep + "u" + sep + unicodeLocaleExtensions;
// Remove trailing null when there is unicodeLocaleExtensions but no variants.
if ( !subtags[ 3 ] ) {
subtags.pop();
}
}
variant = subtags[ 3 ];
// Normalize locale code.
// Get (or deduce) the "triple subtags": language, territory (also aliased as region), and script subtags.
// Get the variant subtags (calendar, collation, currency, etc).
// refs:
// - http://www.unicode.org/reports/tr35/#Field_Definitions
// - http://www.unicode.org/reports/tr35/#Language_and_Locale_IDs
// - http://www.unicode.org/reports/tr35/#Unicode_locale_identifier
// When a locale id does not specify a language, or territory (region), or script, they are obtained by Likely Subtags.
maxLanguageId = coreLikelySubtags( Cldr, this, subtags, { force: true } ) || subtags;
language = maxLanguageId[ 0 ];
script = maxLanguageId[ 1 ];
territory = maxLanguageId[ 2 ];
minLanguageId = coreRemoveLikelySubtags( Cldr, this, maxLanguageId ).join( sep );
// Set attributes
this.attributes = attributes = {
bundle: bundleLookup( Cldr, this, minLanguageId ),
// Unicode Language Id
minLanguageId: minLanguageId + unicodeLocaleExtensionsRaw,
maxLanguageId: maxLanguageId.join( sep ) + unicodeLocaleExtensionsRaw,
// Unicode Language Id Subtabs
language: language,
script: script,
territory: territory,
region: territory, /* alias */
variant: variant
};
// Unicode locale extensions.
unicodeLocaleExtensions && ( "-" + unicodeLocaleExtensions ).replace( /-[a-z]{3,8}|(-[a-z]{2})-([a-z]{3,8})/g, function( attribute, key, type ) {
if ( key ) {
// Extension is in the `keyword` form.
attributes[ "u" + key ] = type;
} else {
// Extension is in the `attribute` form.
attributes[ "u" + attribute ] = true;
}
});
this.locale = locale;
};
/**
* .get()
*/
Cldr.prototype.get = function( path ) {
validatePresence( path, "path" );
validateTypePath( path, "path" );
return itemGetResolved( Cldr, path, this.attributes );
};
/**
* .main()
*/
Cldr.prototype.main = function( path ) {
validatePresence( path, "path" );
validateTypePath( path, "path" );
validate( "E_MISSING_BUNDLE", this.attributes.bundle !== null, {
locale: this.locale
});
path = alwaysArray( path );
return this.get( [ "main/{bundle}" ].concat( path ) );
};
return Cldr;
}));

@@ -0,11 +1,585 @@

/**
* CLDR JavaScript Library v0.5.1
* http://jquery.com/
*
* Copyright 2013 Rafael Xavier de Souza
* Released under the MIT license
* http://jquery.org/license
*
* Date: 2020-08-05T21:05Z
*/
/*!
* CLDR JavaScript Library v0.5.2 2020-08-05T12:51Z MIT license © Rafael Xavier
* CLDR JavaScript Library v0.5.1 2020-08-05T21:05Z MIT license © Rafael Xavier
* http://git.io/h4lmVg
*/
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("../cldr")):"function"==typeof define&&define.amd?define(["../cldr"],t):"object"==typeof exports?exports.Cldr=t(require("../cldr")):e.Cldr=t(e.Cldr)}("undefined"!=typeof self?self:this,(function(e){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=2)}([function(t,n){t.exports=e},function(e,t,n){var r;
(function( factory ) {
if ( typeof define === "function" && define.amd ) {
// AMD.
define( [ "../cldr" ], factory );
} else if ( typeof module === "object" && typeof module.exports === "object" ) {
// Node. CommonJS.
module.exports = factory( require( "../cldr" ) );
} else {
// Global
factory( Cldr );
}
}(function( Cldr ) {
// Build optimization hack to avoid duplicating functions across modules.
var pathNormalize = Cldr._pathNormalize,
validatePresence = Cldr._validatePresence,
validateType = Cldr._validateType;
/*!
* EventEmitter v5.2.9 - git.io/ee
* Unlicense - http://unlicense.org/
* Oliver Caldwell - https://oli.me.uk/
* EventEmitter v4.2.7 - git.io/ee
* Oliver Caldwell
* MIT license
* @preserve
*/!function(t){"use strict";function i(){}var o=i.prototype,s=t.EventEmitter;function u(e,t){for(var n=e.length;n--;)if(e[n].listener===t)return n;return-1}function f(e){return function(){return this[e].apply(this,arguments)}}o.getListeners=function(e){var t,n,r=this._getEvents();if(e instanceof RegExp)for(n in t={},r)r.hasOwnProperty(n)&&e.test(n)&&(t[n]=r[n]);else t=r[e]||(r[e]=[]);return t},o.flattenListeners=function(e){var t,n=[];for(t=0;t<e.length;t+=1)n.push(e[t].listener);return n},o.getListenersAsObject=function(e){var t,n=this.getListeners(e);return n instanceof Array&&((t={})[e]=n),t||n},o.addListener=function(e,t){if(!function e(t){return"function"==typeof t||t instanceof RegExp||!(!t||"object"!=typeof t)&&e(t.listener)}(t))throw new TypeError("listener must be a function");var n,r=this.getListenersAsObject(e),i="object"==typeof t;for(n in r)r.hasOwnProperty(n)&&-1===u(r[n],t)&&r[n].push(i?t:{listener:t,once:!1});return this},o.on=f("addListener"),o.addOnceListener=function(e,t){return this.addListener(e,{listener:t,once:!0})},o.once=f("addOnceListener"),o.defineEvent=function(e){return this.getListeners(e),this},o.defineEvents=function(e){for(var t=0;t<e.length;t+=1)this.defineEvent(e[t]);return this},o.removeListener=function(e,t){var n,r,i=this.getListenersAsObject(e);for(r in i)i.hasOwnProperty(r)&&-1!==(n=u(i[r],t))&&i[r].splice(n,1);return this},o.off=f("removeListener"),o.addListeners=function(e,t){return this.manipulateListeners(!1,e,t)},o.removeListeners=function(e,t){return this.manipulateListeners(!0,e,t)},o.manipulateListeners=function(e,t,n){var r,i,o=e?this.removeListener:this.addListener,s=e?this.removeListeners:this.addListeners;if("object"!=typeof t||t instanceof RegExp)for(r=n.length;r--;)o.call(this,t,n[r]);else for(r in t)t.hasOwnProperty(r)&&(i=t[r])&&("function"==typeof i?o.call(this,r,i):s.call(this,r,i));return this},o.removeEvent=function(e){var t,n=typeof e,r=this._getEvents();if("string"===n)delete r[e];else if(e instanceof RegExp)for(t in r)r.hasOwnProperty(t)&&e.test(t)&&delete r[t];else delete this._events;return this},o.removeAllListeners=f("removeEvent"),o.emitEvent=function(e,t){var n,r,i,o,s=this.getListenersAsObject(e);for(o in s)if(s.hasOwnProperty(o))for(n=s[o].slice(0),i=0;i<n.length;i++)!0===(r=n[i]).once&&this.removeListener(e,r.listener),r.listener.apply(this,t||[])===this._getOnceReturnValue()&&this.removeListener(e,r.listener);return this},o.trigger=f("emitEvent"),o.emit=function(e){var t=Array.prototype.slice.call(arguments,1);return this.emitEvent(e,t)},o.setOnceReturnValue=function(e){return this._onceReturnValue=e,this},o._getOnceReturnValue=function(){return!this.hasOwnProperty("_onceReturnValue")||this._onceReturnValue},o._getEvents=function(){return this._events||(this._events={})},i.noConflict=function(){return t.EventEmitter=s,i},void 0===(r=function(){return i}.call(t,n,t,e))||(e.exports=r)}("undefined"!=typeof window?window:this||{})},function(e,t,n){"use strict";n.r(t);var r=n(1),i=n.n(r),o=n(0),s=n.n(o);const u=s.a._validateType;var f=function(e,t){u(e,t,void 0===e||"function"==typeof e,"Function")};const c=s.a._validatePresence,a=s.a._validateType,l=s.a._pathNormalize;var p,h,d=new i.a;function v(e,t){a(e,t,"string"==typeof e||e instanceof RegExp,"String or RegExp")}function y(e,t){return function(n,r){return c(n,"event"),v(n,"event"),c(r,"listener"),f(r,"listener"),t[e].apply(t,arguments)}}function g(e){return y("off",e)}function m(e){return y("on",e)}function L(e){return y("once",e)}function b(){p=s.a.prototype.get,s.a.prototype.get=function(e){var t=p.apply(this,arguments);return e=l(e,this.attributes).join("/"),d.trigger("get",[e,t]),this.ee.trigger("get",[e,t]),t}}s.a.off=g(d),s.a.on=m(d),s.a.once=L(d),h=s.a.prototype.init,s.a.prototype.init=function(){var e;this.ee=e=new i.a,this.off=g(e),this.on=m(e),this.once=L(e),h.apply(this,arguments)},s.a._eventInit=b,b();t.default=s.a}]).default}));
*/
var EventEmitter;
/* jshint ignore:start */
EventEmitter = (function () {
/**
* Class for managing events.
* Can be extended to provide event functionality in other classes.
*
* @class EventEmitter Manages event registering and emitting.
*/
function EventEmitter() {}
// Shortcuts to improve speed and size
var proto = EventEmitter.prototype;
var exports = {};
/**
* Finds the index of the listener for the event in it's storage array.
*
* @param {Function[]} listeners Array of listeners to search through.
* @param {Function} listener Method to look for.
* @return {Number} Index of the specified listener, -1 if not found
* @api private
*/
function indexOfListener(listeners, listener) {
var i = listeners.length;
while (i--) {
if (listeners[i].listener === listener) {
return i;
}
}
return -1;
}
/**
* Alias a method while keeping the context correct, to allow for overwriting of target method.
*
* @param {String} name The name of the target method.
* @return {Function} The aliased method
* @api private
*/
function alias(name) {
return function aliasClosure() {
return this[name].apply(this, arguments);
};
}
/**
* Returns the listener array for the specified event.
* Will initialise the event object and listener arrays if required.
* Will return an object if you use a regex search. The object contains keys for each matched event. So /ba[rz]/ might return an object containing bar and baz. But only if you have either defined them with defineEvent or added some listeners to them.
* Each property in the object response is an array of listener functions.
*
* @param {String|RegExp} evt Name of the event to return the listeners from.
* @return {Function[]|Object} All listener functions for the event.
*/
proto.getListeners = function getListeners(evt) {
var events = this._getEvents();
var response;
var key;
// Return a concatenated array of all matching events if
// the selector is a regular expression.
if (evt instanceof RegExp) {
response = {};
for (key in events) {
if (events.hasOwnProperty(key) && evt.test(key)) {
response[key] = events[key];
}
}
}
else {
response = events[evt] || (events[evt] = []);
}
return response;
};
/**
* Takes a list of listener objects and flattens it into a list of listener functions.
*
* @param {Object[]} listeners Raw listener objects.
* @return {Function[]} Just the listener functions.
*/
proto.flattenListeners = function flattenListeners(listeners) {
var flatListeners = [];
var i;
for (i = 0; i < listeners.length; i += 1) {
flatListeners.push(listeners[i].listener);
}
return flatListeners;
};
/**
* Fetches the requested listeners via getListeners but will always return the results inside an object. This is mainly for internal use but others may find it useful.
*
* @param {String|RegExp} evt Name of the event to return the listeners from.
* @return {Object} All listener functions for an event in an object.
*/
proto.getListenersAsObject = function getListenersAsObject(evt) {
var listeners = this.getListeners(evt);
var response;
if (listeners instanceof Array) {
response = {};
response[evt] = listeners;
}
return response || listeners;
};
/**
* Adds a listener function to the specified event.
* The listener will not be added if it is a duplicate.
* If the listener returns true then it will be removed after it is called.
* If you pass a regular expression as the event name then the listener will be added to all events that match it.
*
* @param {String|RegExp} evt Name of the event to attach the listener to.
* @param {Function} listener Method to be called when the event is emitted. If the function returns true then it will be removed after calling.
* @return {Object} Current instance of EventEmitter for chaining.
*/
proto.addListener = function addListener(evt, listener) {
var listeners = this.getListenersAsObject(evt);
var listenerIsWrapped = typeof listener === 'object';
var key;
for (key in listeners) {
if (listeners.hasOwnProperty(key) && indexOfListener(listeners[key], listener) === -1) {
listeners[key].push(listenerIsWrapped ? listener : {
listener: listener,
once: false
});
}
}
return this;
};
/**
* Alias of addListener
*/
proto.on = alias('addListener');
/**
* Semi-alias of addListener. It will add a listener that will be
* automatically removed after it's first execution.
*
* @param {String|RegExp} evt Name of the event to attach the listener to.
* @param {Function} listener Method to be called when the event is emitted. If the function returns true then it will be removed after calling.
* @return {Object} Current instance of EventEmitter for chaining.
*/
proto.addOnceListener = function addOnceListener(evt, listener) {
return this.addListener(evt, {
listener: listener,
once: true
});
};
/**
* Alias of addOnceListener.
*/
proto.once = alias('addOnceListener');
/**
* Defines an event name. This is required if you want to use a regex to add a listener to multiple events at once. If you don't do this then how do you expect it to know what event to add to? Should it just add to every possible match for a regex? No. That is scary and bad.
* You need to tell it what event names should be matched by a regex.
*
* @param {String} evt Name of the event to create.
* @return {Object} Current instance of EventEmitter for chaining.
*/
proto.defineEvent = function defineEvent(evt) {
this.getListeners(evt);
return this;
};
/**
* Uses defineEvent to define multiple events.
*
* @param {String[]} evts An array of event names to define.
* @return {Object} Current instance of EventEmitter for chaining.
*/
proto.defineEvents = function defineEvents(evts) {
for (var i = 0; i < evts.length; i += 1) {
this.defineEvent(evts[i]);
}
return this;
};
/**
* Removes a listener function from the specified event.
* When passed a regular expression as the event name, it will remove the listener from all events that match it.
*
* @param {String|RegExp} evt Name of the event to remove the listener from.
* @param {Function} listener Method to remove from the event.
* @return {Object} Current instance of EventEmitter for chaining.
*/
proto.removeListener = function removeListener(evt, listener) {
var listeners = this.getListenersAsObject(evt);
var index;
var key;
for (key in listeners) {
if (listeners.hasOwnProperty(key)) {
index = indexOfListener(listeners[key], listener);
if (index !== -1) {
listeners[key].splice(index, 1);
}
}
}
return this;
};
/**
* Alias of removeListener
*/
proto.off = alias('removeListener');
/**
* Adds listeners in bulk using the manipulateListeners method.
* If you pass an object as the second argument you can add to multiple events at once. The object should contain key value pairs of events and listeners or listener arrays. You can also pass it an event name and an array of listeners to be added.
* You can also pass it a regular expression to add the array of listeners to all events that match it.
* Yeah, this function does quite a bit. That's probably a bad thing.
*
* @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to add to multiple events at once.
* @param {Function[]} [listeners] An optional array of listener functions to add.
* @return {Object} Current instance of EventEmitter for chaining.
*/
proto.addListeners = function addListeners(evt, listeners) {
// Pass through to manipulateListeners
return this.manipulateListeners(false, evt, listeners);
};
/**
* Removes listeners in bulk using the manipulateListeners method.
* If you pass an object as the second argument you can remove from multiple events at once. The object should contain key value pairs of events and listeners or listener arrays.
* You can also pass it an event name and an array of listeners to be removed.
* You can also pass it a regular expression to remove the listeners from all events that match it.
*
* @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to remove from multiple events at once.
* @param {Function[]} [listeners] An optional array of listener functions to remove.
* @return {Object} Current instance of EventEmitter for chaining.
*/
proto.removeListeners = function removeListeners(evt, listeners) {
// Pass through to manipulateListeners
return this.manipulateListeners(true, evt, listeners);
};
/**
* Edits listeners in bulk. The addListeners and removeListeners methods both use this to do their job. You should really use those instead, this is a little lower level.
* The first argument will determine if the listeners are removed (true) or added (false).
* If you pass an object as the second argument you can add/remove from multiple events at once. The object should contain key value pairs of events and listeners or listener arrays.
* You can also pass it an event name and an array of listeners to be added/removed.
* You can also pass it a regular expression to manipulate the listeners of all events that match it.
*
* @param {Boolean} remove True if you want to remove listeners, false if you want to add.
* @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to add/remove from multiple events at once.
* @param {Function[]} [listeners] An optional array of listener functions to add/remove.
* @return {Object} Current instance of EventEmitter for chaining.
*/
proto.manipulateListeners = function manipulateListeners(remove, evt, listeners) {
var i;
var value;
var single = remove ? this.removeListener : this.addListener;
var multiple = remove ? this.removeListeners : this.addListeners;
// If evt is an object then pass each of it's properties to this method
if (typeof evt === 'object' && !(evt instanceof RegExp)) {
for (i in evt) {
if (evt.hasOwnProperty(i) && (value = evt[i])) {
// Pass the single listener straight through to the singular method
if (typeof value === 'function') {
single.call(this, i, value);
}
else {
// Otherwise pass back to the multiple function
multiple.call(this, i, value);
}
}
}
}
else {
// So evt must be a string
// And listeners must be an array of listeners
// Loop over it and pass each one to the multiple method
i = listeners.length;
while (i--) {
single.call(this, evt, listeners[i]);
}
}
return this;
};
/**
* Removes all listeners from a specified event.
* If you do not specify an event then all listeners will be removed.
* That means every event will be emptied.
* You can also pass a regex to remove all events that match it.
*
* @param {String|RegExp} [evt] Optional name of the event to remove all listeners for. Will remove from every event if not passed.
* @return {Object} Current instance of EventEmitter for chaining.
*/
proto.removeEvent = function removeEvent(evt) {
var type = typeof evt;
var events = this._getEvents();
var key;
// Remove different things depending on the state of evt
if (type === 'string') {
// Remove all listeners for the specified event
delete events[evt];
}
else if (evt instanceof RegExp) {
// Remove all events matching the regex.
for (key in events) {
if (events.hasOwnProperty(key) && evt.test(key)) {
delete events[key];
}
}
}
else {
// Remove all listeners in all events
delete this._events;
}
return this;
};
/**
* Alias of removeEvent.
*
* Added to mirror the node API.
*/
proto.removeAllListeners = alias('removeEvent');
/**
* Emits an event of your choice.
* When emitted, every listener attached to that event will be executed.
* If you pass the optional argument array then those arguments will be passed to every listener upon execution.
* Because it uses `apply`, your array of arguments will be passed as if you wrote them out separately.
* So they will not arrive within the array on the other side, they will be separate.
* You can also pass a regular expression to emit to all events that match it.
*
* @param {String|RegExp} evt Name of the event to emit and execute listeners for.
* @param {Array} [args] Optional array of arguments to be passed to each listener.
* @return {Object} Current instance of EventEmitter for chaining.
*/
proto.emitEvent = function emitEvent(evt, args) {
var listeners = this.getListenersAsObject(evt);
var listener;
var i;
var key;
var response;
for (key in listeners) {
if (listeners.hasOwnProperty(key)) {
i = listeners[key].length;
while (i--) {
// If the listener returns true then it shall be removed from the event
// The function is executed either with a basic call or an apply if there is an args array
listener = listeners[key][i];
if (listener.once === true) {
this.removeListener(evt, listener.listener);
}
response = listener.listener.apply(this, args || []);
if (response === this._getOnceReturnValue()) {
this.removeListener(evt, listener.listener);
}
}
}
}
return this;
};
/**
* Alias of emitEvent
*/
proto.trigger = alias('emitEvent');
/**
* Subtly different from emitEvent in that it will pass its arguments on to the listeners, as opposed to taking a single array of arguments to pass on.
* As with emitEvent, you can pass a regex in place of the event name to emit to all events that match it.
*
* @param {String|RegExp} evt Name of the event to emit and execute listeners for.
* @param {...*} Optional additional arguments to be passed to each listener.
* @return {Object} Current instance of EventEmitter for chaining.
*/
proto.emit = function emit(evt) {
var args = Array.prototype.slice.call(arguments, 1);
return this.emitEvent(evt, args);
};
/**
* Sets the current value to check against when executing listeners. If a
* listeners return value matches the one set here then it will be removed
* after execution. This value defaults to true.
*
* @param {*} value The new value to check for when executing listeners.
* @return {Object} Current instance of EventEmitter for chaining.
*/
proto.setOnceReturnValue = function setOnceReturnValue(value) {
this._onceReturnValue = value;
return this;
};
/**
* Fetches the current value to check against when executing listeners. If
* the listeners return value matches this one then it should be removed
* automatically. It will return true by default.
*
* @return {*|Boolean} The current value to check for or the default, true.
* @api private
*/
proto._getOnceReturnValue = function _getOnceReturnValue() {
if (this.hasOwnProperty('_onceReturnValue')) {
return this._onceReturnValue;
}
else {
return true;
}
};
/**
* Fetches the events object and creates one if required.
*
* @return {Object} The events storage object.
* @api private
*/
proto._getEvents = function _getEvents() {
return this._events || (this._events = {});
};
/**
* Reverts the global {@link EventEmitter} to its previous value and returns a reference to this version.
*
* @return {Function} Non conflicting EventEmitter class.
*/
EventEmitter.noConflict = function noConflict() {
exports.EventEmitter = originalGlobalValue;
return EventEmitter;
};
return EventEmitter;
}());
/* jshint ignore:end */
var validateTypeFunction = function( value, name ) {
validateType( value, name, typeof value === "undefined" || typeof value === "function", "Function" );
};
var superGet, superInit,
globalEe = new EventEmitter();
function validateTypeEvent( value, name ) {
validateType( value, name, typeof value === "string" || value instanceof RegExp, "String or RegExp" );
}
function validateThenCall( method, self ) {
return function( event, listener ) {
validatePresence( event, "event" );
validateTypeEvent( event, "event" );
validatePresence( listener, "listener" );
validateTypeFunction( listener, "listener" );
return self[ method ].apply( self, arguments );
};
}
function off( self ) {
return validateThenCall( "off", self );
}
function on( self ) {
return validateThenCall( "on", self );
}
function once( self ) {
return validateThenCall( "once", self );
}
Cldr.off = off( globalEe );
Cldr.on = on( globalEe );
Cldr.once = once( globalEe );
/**
* Overload Cldr.prototype.init().
*/
superInit = Cldr.prototype.init;
Cldr.prototype.init = function() {
var ee;
this.ee = ee = new EventEmitter();
this.off = off( ee );
this.on = on( ee );
this.once = once( ee );
superInit.apply( this, arguments );
};
/**
* getOverload is encapsulated, because of cldr/unresolved. If it's loaded
* after cldr/event (and note it overwrites .get), it can trigger this
* overload again.
*/
function getOverload() {
/**
* Overload Cldr.prototype.get().
*/
superGet = Cldr.prototype.get;
Cldr.prototype.get = function( path ) {
var value = superGet.apply( this, arguments );
path = pathNormalize( path, this.attributes ).join( "/" );
globalEe.trigger( "get", [ path, value ] );
this.ee.trigger( "get", [ path, value ] );
return value;
};
}
Cldr._eventInit = getOverload;
getOverload();
return Cldr;
}));

@@ -0,5 +1,101 @@

/**
* CLDR JavaScript Library v0.5.1
* http://jquery.com/
*
* Copyright 2013 Rafael Xavier de Souza
* Released under the MIT license
* http://jquery.org/license
*
* Date: 2020-08-05T21:05Z
*/
/*!
* CLDR JavaScript Library v0.5.2 2020-08-05T12:51Z MIT license © Rafael Xavier
* CLDR JavaScript Library v0.5.1 2020-08-05T21:05Z MIT license © Rafael Xavier
* http://git.io/h4lmVg
*/
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("../cldr")):"function"==typeof define&&define.amd?define(["../cldr"],t):"object"==typeof exports?exports.Cldr=t(require("../cldr")):e.Cldr=t(e.Cldr)}("undefined"!=typeof self?self:this,(function(e){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var a=t[n]={i:n,l:!1,exports:{}};return e[n].call(a.exports,a,a.exports,r),a.l=!0,a.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)r.d(n,a,function(t){return e[t]}.bind(null,a));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=1)}([function(t,r){t.exports=e},function(e,t,r){"use strict";r.r(t);var n=r(0),a=r.n(n);const o=a.a._alwaysArray;var u=function(e){var t,r;return(r=(t=function(t){return function(r){return r=o(r),e.get([t].concat(r))}})("supplemental")).weekData=t("supplemental/weekData"),r.weekData.firstDay=function(){return e.get("supplemental/weekData/firstDay/{territory}")||e.get("supplemental/weekData/firstDay/001")},r.weekData.minDays=function(){var t=e.get("supplemental/weekData/minDays/{territory}")||e.get("supplemental/weekData/minDays/001");return parseInt(t,10)},r.timeData=t("supplemental/timeData"),r.timeData.allowed=function(){return e.get("supplemental/timeData/{territory}/_allowed")||e.get("supplemental/timeData/001/_allowed")},r.timeData.preferred=function(){return e.get("supplemental/timeData/{territory}/_preferred")||e.get("supplemental/timeData/001/_preferred")},r},i=a.a.prototype.init;a.a.prototype.init=function(){i.apply(this,arguments),this.supplemental=u(this)};t.default=a.a}]).default}));
(function( factory ) {
if ( typeof define === "function" && define.amd ) {
// AMD.
define( [ "../cldr" ], factory );
} else if ( typeof module === "object" && typeof module.exports === "object" ) {
// Node. CommonJS.
module.exports = factory( require( "../cldr" ) );
} else {
// Global
factory( Cldr );
}
}(function( Cldr ) {
// Build optimization hack to avoid duplicating functions across modules.
var alwaysArray = Cldr._alwaysArray;
var supplementalMain = function( cldr ) {
var prepend, supplemental;
prepend = function( prepend ) {
return function( path ) {
path = alwaysArray( path );
return cldr.get( [ prepend ].concat( path ) );
};
};
supplemental = prepend( "supplemental" );
// Week Data
// http://www.unicode.org/reports/tr35/tr35-dates.html#Week_Data
supplemental.weekData = prepend( "supplemental/weekData" );
supplemental.weekData.firstDay = function() {
return cldr.get( "supplemental/weekData/firstDay/{territory}" ) ||
cldr.get( "supplemental/weekData/firstDay/001" );
};
supplemental.weekData.minDays = function() {
var minDays = cldr.get( "supplemental/weekData/minDays/{territory}" ) ||
cldr.get( "supplemental/weekData/minDays/001" );
return parseInt( minDays, 10 );
};
// Time Data
// http://www.unicode.org/reports/tr35/tr35-dates.html#Time_Data
supplemental.timeData = prepend( "supplemental/timeData" );
supplemental.timeData.allowed = function() {
return cldr.get( "supplemental/timeData/{territory}/_allowed" ) ||
cldr.get( "supplemental/timeData/001/_allowed" );
};
supplemental.timeData.preferred = function() {
return cldr.get( "supplemental/timeData/{territory}/_preferred" ) ||
cldr.get( "supplemental/timeData/001/_preferred" );
};
return supplemental;
};
var initSuper = Cldr.prototype.init;
/**
* .init() automatically ran on construction.
*
* Overload .init().
*/
Cldr.prototype.init = function() {
initSuper.apply( this, arguments );
this.supplemental = supplementalMain( this );
};
return Cldr;
}));

@@ -0,5 +1,164 @@

/**
* CLDR JavaScript Library v0.5.1
* http://jquery.com/
*
* Copyright 2013 Rafael Xavier de Souza
* Released under the MIT license
* http://jquery.org/license
*
* Date: 2020-08-05T21:05Z
*/
/*!
* CLDR JavaScript Library v0.5.2 2020-08-05T12:51Z MIT license © Rafael Xavier
* CLDR JavaScript Library v0.5.1 2020-08-05T21:05Z MIT license © Rafael Xavier
* http://git.io/h4lmVg
*/
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("../cldr")):"function"==typeof define&&define.amd?define(["../cldr"],t):"object"==typeof exports?exports.Cldr=t(require("../cldr")):e.Cldr=t(e.Cldr)}("undefined"!=typeof self?self:this,(function(e){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=1)}([function(t,r){t.exports=e},function(e,t,r){"use strict";r.r(t);var n=function(e,t){var r,n;return n=e+(t&&JSON?": "+JSON.stringify(t):""),(r=new Error(n)).code=e,function(e,t){var r,n;if(e.forEach)return e.forEach(t);for(r=0,n=e.length;r<n;r++)t(e[r],r,e)}(function(e){var t,r=[];if(Object.keys)return Object.keys(e);for(t in e)r.push(t);return r}(t),(function(e){r[e]=t[e]})),r},o=function(e,t){!function(e,t,r){if(!t)throw n(e,r)}("E_MISSING_PARAMETER",void 0!==e,{name:t})},u=r(0),a=r.n(u);const i=a.a._resourceGet,f=a.a._pathNormalize;const c=a.a._pathNormalize,l=a.a._resourceGet,d=a.a._jsonMerge;var s,p=s=function(e,t,r,n,o){var u,a,p;if(void 0!==t&&t!==o)return u=c(r,n),void 0!==(p=l(e._resolved,u))&&"object"!=typeof p||(void 0===(p=l(e._raw,u))&&(a=function(e,t){var r,n;if("root"!==t)return r=f(["supplemental/parentLocales/parentLocale",t]),(n=i(e._resolved,r)||i(e._raw,r))?n:(n=t.substr(0,t.lastIndexOf(e.localeSep)))||"root"}(e,t),p=s(e,a,r,d(n,{bundle:a}),t)),void 0!==p&&function(e,t,r){var n,o=e,u=t.length;for(n=0;n<u-1;n++)o[t[n]]||(o[t[n]]={}),o=o[t[n]];o[t[n]]=r}(e._resolved,u,p)),p};const v=a.a._validateTypePath,b=a.a._coreLoad;a.a._raw={},a.a.load=function(){a.a._raw=b(a.a,a.a._raw,arguments)},a.a.prototype.get=function(e){return o(e,"path"),v(e,"path"),p(a.a,this.attributes&&this.attributes.bundle||"",e,this.attributes)},a.a._eventInit&&a.a._eventInit();t.default=a.a}]).default}));
(function( factory ) {
if ( typeof define === "function" && define.amd ) {
// AMD.
define( [ "../cldr" ], factory );
} else if ( typeof module === "object" && typeof module.exports === "object" ) {
// Node. CommonJS.
module.exports = factory( require( "../cldr" ) );
} else {
// Global
factory( Cldr );
}
}(function( Cldr ) {
// Build optimization hack to avoid duplicating functions across modules.
var coreLoad = Cldr._coreLoad;
var jsonMerge = Cldr._jsonMerge;
var pathNormalize = Cldr._pathNormalize;
var resourceGet = Cldr._resourceGet;
var validatePresence = Cldr._validatePresence;
var validateTypePath = Cldr._validateTypePath;
var bundleParentLookup = function( Cldr, locale ) {
var normalizedPath, parent;
if ( locale === "root" ) {
return;
}
// First, try to find parent on supplemental data.
normalizedPath = pathNormalize( [ "supplemental/parentLocales/parentLocale", locale ] );
parent = resourceGet( Cldr._resolved, normalizedPath ) || resourceGet( Cldr._raw, normalizedPath );
if ( parent ) {
return parent;
}
// Or truncate locale.
parent = locale.substr( 0, locale.lastIndexOf( Cldr.localeSep ) );
if ( !parent ) {
return "root";
}
return parent;
};
// @path: normalized path
var resourceSet = function( data, path, value ) {
var i,
node = data,
length = path.length;
for ( i = 0; i < length - 1; i++ ) {
if ( !node[ path[ i ] ] ) {
node[ path[ i ] ] = {};
}
node = node[ path[ i ] ];
}
node[ path[ i ] ] = value;
};
var itemLookup = (function() {
var lookup;
lookup = function( Cldr, locale, path, attributes, childLocale ) {
var normalizedPath, parent, value;
// 1: Finish recursion
// 2: Avoid infinite loop
if ( typeof locale === "undefined" /* 1 */ || locale === childLocale /* 2 */ ) {
return;
}
// Resolve path
normalizedPath = pathNormalize( path, attributes );
// Check resolved (cached) data first
// 1: Due to #16, never use the cached resolved non-leaf nodes. It may not
// represent its leafs in its entirety.
value = resourceGet( Cldr._resolved, normalizedPath );
if ( value !== undefined && typeof value !== "object" /* 1 */ ) {
return value;
}
// Check raw data
value = resourceGet( Cldr._raw, normalizedPath );
if ( value === undefined ) {
// Or, lookup at parent locale
parent = bundleParentLookup( Cldr, locale );
value = lookup( Cldr, parent, path, jsonMerge( attributes, { bundle: parent }), locale );
}
if ( value !== undefined ) {
// Set resolved (cached)
resourceSet( Cldr._resolved, normalizedPath, value );
}
return value;
};
return lookup;
}());
Cldr._raw = {};
/**
* Cldr.load( json [, json, ...] )
*
* @json [JSON] CLDR data or [Array] Array of @json's.
*
* Load resolved or unresolved cldr data.
* Overwrite Cldr.load().
*/
Cldr.load = function() {
Cldr._raw = coreLoad( Cldr, Cldr._raw, arguments );
};
/**
* Overwrite Cldr.prototype.get().
*/
Cldr.prototype.get = function( path ) {
validatePresence( path, "path" );
validateTypePath( path, "path" );
// 1: use bundle as locale on item lookup for simplification purposes, because no other extended subtag is used anyway on bundle parent lookup.
// 2: during init(), this method is called, but bundle is yet not defined. Use "" as a workaround in this very specific scenario.
return itemLookup( Cldr, this.attributes && this.attributes.bundle /* 1 */ || "" /* 2 */, path, this.attributes );
};
// In case cldr/unresolved is loaded after cldr/event, we trigger its overloads again. Because, .get is overwritten in here.
if ( Cldr._eventInit ) {
Cldr._eventInit();
}
return Cldr;
}));

21

dist/node_main.js

@@ -0,11 +1,22 @@

/**
* CLDR JavaScript Library v0.5.1
* http://jquery.com/
*
* Copyright 2013 Rafael Xavier de Souza
* Released under the MIT license
* http://jquery.org/license
*
* Date: 2020-08-05T21:05Z
*/
/*!
* CLDR JavaScript Library v0.5.2 2020-08-05T12:51Z MIT license © Rafael Xavier
* CLDR JavaScript Library v0.5.1 2020-08-05T21:05Z MIT license © Rafael Xavier
* http://git.io/h4lmVg
*/
// Cldr
module.exports = require("./cldr");
module.exports = require( "./cldr" );
// Extent Cldr with the following modules
require("./cldr/event");
require("./cldr/supplemental");
require("./cldr/unresolved");
require( "./cldr/event" );
require( "./cldr/supplemental" );
require( "./cldr/unresolved" );
{
"name": "cldrjs",
"version": "0.5.2",
"version": "0.5.3",
"description": "Simple CLDR traverser",

@@ -23,3 +23,2 @@ "keywords": [

"main": "dist/node_main.js",
"browser": "dist-esm/index.js",
"files": [

@@ -30,2 +29,3 @@ "CHANGELOG.md",

"doc/",
"LICENSE-MIT",
"README.md"

@@ -43,22 +43,2 @@ ],

},
"scripts": {
"build": "npm run lint && npm run test:unit && npm run build:all && npm run test:functional && npm run validate",
"build:all": "npm run build:dist && npm run build:esm",
"validate": "npm run compare_size && npm run dco",
"lint": "eslint src test build",
"lint:fix": "eslint --fix src test build",
"prettier": "prettier --write '{src,test,build}/**/*.js'",
"compare_size": "node build/compare-size.js",
"dco": "node build/dco.js",
"test:unit": "export NODE_ENV=test && mocha --require @babel/register --require chai/register-expect './test/unit/**/*.js'",
"test:functional": "export NODE_ENV=test && mocha --require @babel/register --require chai/register-expect './test/functional/*.js'",
"build:dist": "webpack --mode production --config webpack.config.js",
"build:esm": "export NODE_ENV=production && babel src --out-dir dist-esm --delete-dir-on-start --ignore src/build/node_main.js --plugins $PWD/wrap-validate-with-env-check.js"
},
"cldr-data-urls-filter": "(cldr-core|cldr-numbers-modern|cldr-dates-modern)",
"dco": {
"exceptionalAuthors": {
"rxaviers@gmail.com": "Rafael Xavier de Souza"
}
},
"licenses": [

@@ -71,29 +51,15 @@ {

"devDependencies": {
"@babel/cli": "^7.0.0-rc.1",
"@babel/core": "^7.0.0-rc.1",
"@babel/register": "^7.0.0-rc.1",
"@swissquote/babel-preset-swissquote": "^1.2.1",
"babel-core": "7.0.0-bridge.0",
"babel-eslint": "^9.0.0",
"chai": "^4.1.2",
"chalk": "^2.4.1",
"cldr-data": "^33.0.0",
"copy-webpack-plugin": "^4.5.2",
"debug": "^4.0.0",
"eslint": "^5.3.0",
"eslint-config-prettier": "^3.0.1",
"eslint-plugin-prettier": "^2.6.2",
"gzip-size": "^5.0.0",
"mocha": "^5.2.0",
"prettier": "^1.14.2",
"stats-webpack-plugin": "^0.7.0",
"string-replace-webpack-plugin": "^0.1.3",
"text-table": "^0.2.0",
"webpack": "^4.16.3",
"webpack-cli": "^3.1.0"
},
"dependencies": {
"dco": "^1.1.0",
"wolfy87-eventemitter": "^5.2.5"
"cldr-data-downloader": "0.2.x",
"grunt": "0.4.x",
"grunt-compare-size": "0.4.0",
"grunt-contrib-connect": "0.3.x",
"grunt-contrib-copy": "0.4.x",
"grunt-contrib-jshint": "0.12.x",
"grunt-contrib-requirejs": "0.4.x",
"grunt-contrib-uglify": "0.2.x",
"grunt-dco": "0.0.3",
"gzip-js": "0.3.2",
"grunt-mocha": "0.3.x",
"matchdep": "*"
}
}

@@ -535,15 +535,14 @@ # cldr.js - Simple CLDR traverser

To run the tests and build, you can run npm scripts. You will need to install all dependencies before:
Install grunt and tests external dependencies. First, install the [grunt-cli](http://gruntjs.com/getting-started#installing-the-cli) and [bower](http://bower.io/) packages if you haven't before. These should be done as global installs. Then:
```bash
npm install
npm install && bower install
```
Run tests
```bash
npm run test:unit
npm run test:functional
grunt test
```
Build distribution file.
```bash
npm run build
grunt
```

@@ -550,0 +549,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc