META-INF.resources.bower_components.cldrjs.src.bundle.lookup.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jwebmp-globalize Show documentation
Show all versions of jwebmp-globalize Show documentation
The JWebSwing implementation for a full Globalization
define([
"../core/likely_subtags",
"../core/remove_likely_subtags",
"../core/subtags",
"../util/array/for_each"
], function (coreLikelySubtags, coreRemoveLikelySubtags, coreSubtags, arrayForEach) {
/**
* bundleLookup( minLanguageId )
*
* @Cldr [Cldr class]
*
* @cldr [Cldr instance]
*
* @minLanguageId [String] requested languageId after applied remove likely subtags.
*/
return function (Cldr, cldr, minLanguageId) {
var availableBundleMap = Cldr._availableBundleMap,
availableBundleMapQueue = Cldr._availableBundleMapQueue;
if (availableBundleMapQueue.length) {
arrayForEach(availableBundleMapQueue, function (bundle) {
var existing, maxBundle, minBundle, subtags;
subtags = coreSubtags(bundle);
maxBundle = coreLikelySubtags(Cldr, cldr, subtags);
minBundle = coreRemoveLikelySubtags(Cldr, cldr, maxBundle);
minBundle = minBundle.join(Cldr.localeSep);
existing = availableBundleMapQueue[minBundle];
if (existing && existing.length < bundle.length) {
return;
}
availableBundleMap[minBundle] = bundle;
});
Cldr._availableBundleMapQueue = [];
}
return availableBundleMap[minLanguageId] || null;
};
});