/** * 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 ) { arrayForEach( availableBundleMapQueue, function( bundle, i ) { var existing, maxBundle, minBundle, subtags; subtags = coreSubtags( bundle ); maxBundle = coreLikelySubtags( Cldr, cldr, subtags ); if ( maxBundle === undefined ) { availableBundleMapQueue.splice( i, 1 ); 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; }); Cldr._availableBundleMapQueue = []; } return availableBundleMap[ minLanguageId ] || null; };