All Downloads are FREE. Search and download functionalities are using the official Maven repository.

META-INF.resources.bower_components.cldrjs.src.bundle.lookup.js Maven / Gradle / Ivy

There is a newer version: 0.66.0.1
Show newest version
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;
    };

});




© 2015 - 2024 Weber Informatics LLC | Privacy Policy