packages/searchive-app/static/pdfjs/web/l10n.js
function loadLocale(lang, callback) {
        // RFC 4646, section 2.1 states that language tags have to be treated as
        // case-insensitive. Convert to lowercase for case-insensitive comparisons.
        if (lang) {
            lang = lang.toLowerCase();
        }

        callback = callback || function _callback() {};

        clear();
        gLanguage = lang;

        // check all <link type="application/l10n" href="..." /> nodes
        // and load the resource files
        var langLinks = getL10nResourceLinks();
        var langCount = langLinks.length;
        if (langCount === 0) {
            // we might have a pre-compiled dictionary instead
            var dict = getL10nDictionary();
            if (dict && dict.locales && dict.default_locale) {
                console.log("using the embedded JSON directory, early way out");
                gL10nData = dict.locales[lang];
                if (!gL10nData) {
                    var defaultLocale = dict.default_locale.toLowerCase();
                    for (var anyCaseLang in dict.locales) {
                        anyCaseLang = anyCaseLang.toLowerCase();
                        if (anyCaseLang === lang) {
                            gL10nData = dict.locales[lang];
                            break;
                        } else if (anyCaseLang === defaultLocale) {
                            gL10nData = dict.locales[defaultLocale];
                        }
                    }
                }
                callback();
            } else {
                console.log("no resource to load, early way out");
            }
            // early way out
            fireL10nReadyEvent(lang);
            gReadyState = "complete";
            return;
        }

        // start the callback when all resources are loaded
        var onResourceLoaded = null;
        var gResourceCount = 0;
        onResourceLoaded = function() {
            gResourceCount++;
            if (gResourceCount >= langCount) {
                callback();
                fireL10nReadyEvent(lang);
                gReadyState = "complete";
            }
        };

        // load all resource files
        function L10nResourceLink(link) {
            var href = link.href;
            // Note: If |gAsyncResourceLoading| is false, then the following callbacks
            // are synchronously called.
            this.load = function(lang, callback) {
                parseResource(href, lang, callback, function() {
                    console.warn(href + " not found.");
                    // lang not found, used default resource instead
                    console.warn('"' + lang + '" resource not found');
                    gLanguage = "";
                    // Resource not loaded, but we still need to call the callback.
                    callback();
                });
            };
        }

        for (var i = 0; i < langCount; i++) {
            var resource = new L10nResourceLink(langLinks[i]);
            resource.load(lang, onResourceLoaded);
        }
    }
function loadLocale(lang, callback) {
        // RFC 4646, section 2.1 states that language tags have to be treated as
        // case-insensitive. Convert to lowercase for case-insensitive comparisons.
        if (lang) {
            lang = lang.toLowerCase();
        }

        callback = callback || function _callback() {};

        clear();
        gLanguage = lang;

        // check all <link type="application/l10n" href="..." /> nodes
        // and load the resource files
        var langLinks = getL10nResourceLinks();
        var langCount = langLinks.length;
        if (langCount === 0) {
            // we might have a pre-compiled dictionary instead
            var dict = getL10nDictionary();
            if (dict && dict.locales && dict.default_locale) {
                console.log("using the embedded JSON directory, early way out");
                gL10nData = dict.locales[lang];
                if (!gL10nData) {
                    var defaultLocale = dict.default_locale.toLowerCase();
                    for (var anyCaseLang in dict.locales) {
                        anyCaseLang = anyCaseLang.toLowerCase();
                        if (anyCaseLang === lang) {
                            gL10nData = dict.locales[lang];
                            break;
                        } else if (anyCaseLang === defaultLocale) {
                            gL10nData = dict.locales[defaultLocale];
                        }
                    }
                }
                callback();
            } else {
                console.log("no resource to load, early way out");
            }
            // early way out
            fireL10nReadyEvent(lang);
            gReadyState = "complete";
            return;
        }

        // start the callback when all resources are loaded
        var onResourceLoaded = null;
        var gResourceCount = 0;
        onResourceLoaded = function() {
            gResourceCount++;
            if (gResourceCount >= langCount) {
                callback();
                fireL10nReadyEvent(lang);
                gReadyState = "complete";
            }
        };

        // load all resource files
        function L10nResourceLink(link) {
            var href = link.href;
            // Note: If |gAsyncResourceLoading| is false, then the following callbacks
            // are synchronously called.
            this.load = function(lang, callback) {
                parseResource(href, lang, callback, function() {
                    console.warn(href + " not found.");
                    // lang not found, used default resource instead
                    console.warn('"' + lang + '" resource not found');
                    gLanguage = "";
                    // Resource not loaded, but we still need to call the callback.
                    callback();
                });
            };
        }

        for (var i = 0; i < langCount; i++) {
            var resource = new L10nResourceLink(langLinks[i]);
            resource.load(lang, onResourceLoaded);
        }
    }
function loadLocale ( lang , callback ) { // RFC 4646, section 2.1 states that language tags have to be treated as // case-insensitive. Convert to lowercase for case-insensitive comparisons. if ( lang ) { lang = lang . toLowerCase ( ) ; } callback = callback || function _callback ( ) { } ; clear ( ) ; gLanguage = lang ; // check all <link type="application/l10n" href="..." /> nodes // and load the resource files var langLinks = getL10nResourceLinks ( ) ; var langCount = langLinks . length ; if ( langCount === 0 ) { // we might have a pre-compiled dictionary instead var dict = getL10nDictionary ( ) ; if ( dict && dict . locales && dict . default_locale ) { console . log ( "using the embedded JSON directory, early way out" ) ; gL10nData = dict . locales [ lang ] ; if ( ! gL10nData ) { var defaultLocale = dict . default_locale . toLowerCase ( ) ; for ( var anyCaseLang in dict . locales ) { anyCaseLang = anyCaseLang . toLowerCase ( ) ; if ( anyCaseLang === lang ) { gL10nData = dict . locales [ lang ] ; break ; } else if ( anyCaseLang === defaultLocale ) { gL10nData = dict . locales [ defaultLocale ] ; } } } callback ( ) ; } else { console . log ( "no resource to load, early way out" ) ; } // early way out fireL10nReadyEvent ( lang ) ; gReadyState = "complete" ; return ; } // start the callback when all resources are loaded var onResourceLoaded = null ; var gResourceCount = 0 ; onResourceLoaded = function ( ) { gResourceCount ++ ; if ( gResourceCount >= langCount ) { callback ( ) ; fireL10nReadyEvent ( lang ) ; gReadyState = "complete" ; } } ; // load all resource files function L10nResourceLink ( link ) { var href = link . href ; // Note: If |gAsyncResourceLoading| is false, then the following callbacks // are synchronously called. this . load = function ( lang , callback ) { parseResource ( href , lang , callback , function ( ) { console . warn ( href + " not found." ) ; // lang not found, used default resource instead console . warn ( '"' + lang + '" resource not found' ) ; gLanguage = "" ; // Resource not loaded, but we still need to call the callback. callback ( ) ; } ) ; } ; } for ( var i = 0 ; i < langCount ; i ++ ) { var resource = new L10nResourceLink ( langLinks [ i ] ) ; resource . load ( lang , onResourceLoaded ) ; } }
load and parse all resources for the specified locale
load and parse all resources for the specified locale