]> git.wh0rd.org - tt-rss.git/blobdiff - lib/dojo/i18n.js
lib: Upgrade Dojo and Dijit from 1.8.3 to 1.12.1
[tt-rss.git] / lib / dojo / i18n.js
index 893490fe07e17057ad982bee539e4102736948e6..0bd4c2fe999ad61c60a573830dc612fe2a9209d0 100644 (file)
@@ -1,262 +1,8 @@
 /*
-       Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
+       Copyright (c) 2004-2016, The JS Foundation All Rights Reserved.
        Available via Academic Free License >= 2.1 OR the modified BSD license.
        see: http://dojotoolkit.org/license for details
 */
 
-
-if(!dojo._hasResource["dojo.i18n"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
-dojo._hasResource["dojo.i18n"] = true;
-dojo.provide("dojo.i18n");
-
-dojo.getObject("i18n", true, dojo);
-
-/*=====
-dojo.i18n = {
-       // summary: Utility classes to enable loading of resources for internationalization (i18n)
-};
-=====*/
-
-// when using a real AMD loader, dojo.i18n.getLocalization is already defined by dojo/lib/backCompat
-dojo.i18n.getLocalization = dojo.i18n.getLocalization || function(/*String*/packageName, /*String*/bundleName, /*String?*/locale){
-       //      summary:
-       //              Returns an Object containing the localization for a given resource
-       //              bundle in a package, matching the specified locale.
-       //      description:
-       //              Returns a hash containing name/value pairs in its prototypesuch
-       //              that values can be easily overridden.  Throws an exception if the
-       //              bundle is not found.  Bundle must have already been loaded by
-       //              `dojo.requireLocalization()` or by a build optimization step.  NOTE:
-       //              try not to call this method as part of an object property
-       //              definition (`var foo = { bar: dojo.i18n.getLocalization() }`).  In
-       //              some loading situations, the bundle may not be available in time
-       //              for the object definition.  Instead, call this method inside a
-       //              function that is run after all modules load or the page loads (like
-       //              in `dojo.addOnLoad()`), or in a widget lifecycle method.
-       //      packageName:
-       //              package which is associated with this resource
-       //      bundleName:
-       //              the base filename of the resource bundle (without the ".js" suffix)
-       //      locale:
-       //              the variant to load (optional).  By default, the locale defined by
-       //              the host environment: dojo.locale
-
-       locale = dojo.i18n.normalizeLocale(locale);
-
-       // look for nearest locale match
-       var elements = locale.split('-');
-       var module = [packageName,"nls",bundleName].join('.');
-               var bundle = dojo._loadedModules[module];
-       if(bundle){
-               var localization;
-               for(var i = elements.length; i > 0; i--){
-                       var loc = elements.slice(0, i).join('_');
-                       if(bundle[loc]){
-                               localization = bundle[loc];
-                               break;
-                       }
-               }
-               if(!localization){
-                       localization = bundle.ROOT;
-               }
-
-               // make a singleton prototype so that the caller won't accidentally change the values globally
-               if(localization){
-                       var clazz = function(){};
-                       clazz.prototype = localization;
-                       return new clazz(); // Object
-               }
-       }
-
-       throw new Error("Bundle not found: " + bundleName + " in " + packageName+" , locale=" + locale);
-};
-
-dojo.i18n.normalizeLocale = function(/*String?*/locale){
-       //      summary:
-       //              Returns canonical form of locale, as used by Dojo.
-       //
-       //  description:
-       //              All variants are case-insensitive and are separated by '-' as specified in [RFC 3066](http://www.ietf.org/rfc/rfc3066.txt).
-       //              If no locale is specified, the dojo.locale is returned.  dojo.locale is defined by
-       //              the user agent's locale unless overridden by djConfig.
-
-       var result = locale ? locale.toLowerCase() : dojo.locale;
-       if(result == "root"){
-               result = "ROOT";
-       }
-       return result; // String
-};
-
-dojo.i18n._requireLocalization = function(/*String*/moduleName, /*String*/bundleName, /*String?*/locale, /*String?*/availableFlatLocales){
-       //      summary:
-       //              See dojo.requireLocalization()
-       //      description:
-       //              Called by the bootstrap, but factored out so that it is only
-       //              included in the build when needed.
-
-       var targetLocale = dojo.i18n.normalizeLocale(locale);
-       var bundlePackage = [moduleName, "nls", bundleName].join(".");
-       // NOTE:
-       //              When loading these resources, the packaging does not match what is
-       //              on disk.  This is an implementation detail, as this is just a
-       //              private data structure to hold the loaded resources.  e.g.
-       //              `tests/hello/nls/en-us/salutations.js` is loaded as the object
-       //              `tests.hello.nls.salutations.en_us={...}` The structure on disk is
-       //              intended to be most convenient for developers and translators, but
-       //              in memory it is more logical and efficient to store in a different
-       //              order.  Locales cannot use dashes, since the resulting path will
-       //              not evaluate as valid JS, so we translate them to underscores.
-
-       //Find the best-match locale to load if we have available flat locales.
-       var bestLocale = "";
-       if(availableFlatLocales){
-               var flatLocales = availableFlatLocales.split(",");
-               for(var i = 0; i < flatLocales.length; i++){
-                       //Locale must match from start of string.
-                       //Using ["indexOf"] so customBase builds do not see
-                       //this as a dojo._base.array dependency.
-                       if(targetLocale["indexOf"](flatLocales[i]) == 0){
-                               if(flatLocales[i].length > bestLocale.length){
-                                       bestLocale = flatLocales[i];
-                               }
-                       }
-               }
-               if(!bestLocale){
-                       bestLocale = "ROOT";
-               }
-       }
-
-       //See if the desired locale is already loaded.
-       var tempLocale = availableFlatLocales ? bestLocale : targetLocale;
-       var bundle = dojo._loadedModules[bundlePackage];
-       var localizedBundle = null;
-       if(bundle){
-               if(dojo.config.localizationComplete && bundle._built){return;}
-               var jsLoc = tempLocale.replace(/-/g, '_');
-               var translationPackage = bundlePackage+"."+jsLoc;
-               localizedBundle = dojo._loadedModules[translationPackage];
-       }
-
-       if(!localizedBundle){
-               bundle = dojo["provide"](bundlePackage);
-               var syms = dojo._getModuleSymbols(moduleName);
-               var modpath = syms.concat("nls").join("/");
-               var parent;
-
-               dojo.i18n._searchLocalePath(tempLocale, availableFlatLocales, function(loc){
-                       var jsLoc = loc.replace(/-/g, '_');
-                       var translationPackage = bundlePackage + "." + jsLoc;
-                       var loaded = false;
-                       if(!dojo._loadedModules[translationPackage]){
-                               // Mark loaded whether it's found or not, so that further load attempts will not be made
-                               dojo["provide"](translationPackage);
-                               var module = [modpath];
-                               if(loc != "ROOT"){module.push(loc);}
-                               module.push(bundleName);
-                               var filespec = module.join("/") + '.js';
-                               loaded = dojo._loadPath(filespec, null, function(hash){
-                                       hash = hash.root || hash;
-                                       // Use singleton with prototype to point to parent bundle, then mix-in result from loadPath
-                                       var clazz = function(){};
-                                       clazz.prototype = parent;
-                                       bundle[jsLoc] = new clazz();
-                                       for(var j in hash){ bundle[jsLoc][j] = hash[j]; }
-                               });
-                       }else{
-                               loaded = true;
-                       }
-                       if(loaded && bundle[jsLoc]){
-                               parent = bundle[jsLoc];
-                       }else{
-                               bundle[jsLoc] = parent;
-                       }
-
-                       if(availableFlatLocales){
-                               //Stop the locale path searching if we know the availableFlatLocales, since
-                               //the first call to this function will load the only bundle that is needed.
-                               return true;
-                       }
-               });
-       }
-
-       //Save the best locale bundle as the target locale bundle when we know the
-       //the available bundles.
-       if(availableFlatLocales && targetLocale != bestLocale){
-               bundle[targetLocale.replace(/-/g, '_')] = bundle[bestLocale.replace(/-/g, '_')];
-       }
-};
-
-(function(){
-       // If other locales are used, dojo.requireLocalization should load them as
-       // well, by default.
-       //
-       // Override dojo.requireLocalization to do load the default bundle, then
-       // iterate through the extraLocale list and load those translations as
-       // well, unless a particular locale was requested.
-
-       var extra = dojo.config.extraLocale;
-       if(extra){
-               if(!extra instanceof Array){
-                       extra = [extra];
-               }
-
-               var req = dojo.i18n._requireLocalization;
-               dojo.i18n._requireLocalization = function(m, b, locale, availableFlatLocales){
-                       req(m,b,locale, availableFlatLocales);
-                       if(locale){return;}
-                       for(var i=0; i<extra.length; i++){
-                               req(m,b,extra[i], availableFlatLocales);
-                       }
-               };
-       }
-})();
-
-dojo.i18n._searchLocalePath = function(/*String*/locale, /*Boolean*/down, /*Function*/searchFunc){
-       //      summary:
-       //              A helper method to assist in searching for locale-based resources.
-       //              Will iterate through the variants of a particular locale, either up
-       //              or down, executing a callback function.  For example, "en-us" and
-       //              true will try "en-us" followed by "en" and finally "ROOT".
-
-       locale = dojo.i18n.normalizeLocale(locale);
-
-       var elements = locale.split('-');
-       var searchlist = [];
-       for(var i = elements.length; i > 0; i--){
-               searchlist.push(elements.slice(0, i).join('-'));
-       }
-       searchlist.push(false);
-       if(down){searchlist.reverse();}
-
-       for(var j = searchlist.length - 1; j >= 0; j--){
-               var loc = searchlist[j] || "ROOT";
-               var stop = searchFunc(loc);
-               if(stop){ break; }
-       }
-};
-
-dojo.i18n._preloadLocalizations = function(/*String*/bundlePrefix, /*Array*/localesGenerated){
-       //      summary:
-       //              Load built, flattened resource bundles, if available for all
-       //              locales used in the page. Only called by built layer files.
-
-       function preload(locale){
-               locale = dojo.i18n.normalizeLocale(locale);
-               dojo.i18n._searchLocalePath(locale, true, function(loc){
-                       for(var i=0; i<localesGenerated.length;i++){
-                               if(localesGenerated[i] == loc){
-                                       dojo["require"](bundlePrefix+"_"+loc);
-                                       return true; // Boolean
-                               }
-                       }
-                       return false; // Boolean
-               });
-       }
-       preload();
-       var extra = dojo.config.extraLocale||[];
-       for(var i=0; i<extra.length; i++){
-               preload(extra[i]);
-       }
-};
-
-}
+//>>built
+define("dojo/i18n",["./_base/kernel","require","./has","./_base/array","./_base/config","./_base/lang","./_base/xhr","./json","module"],function(_1,_2,_3,_4,_5,_6,_7,_8,_9){_3.add("dojo-preload-i18n-Api",1);1||_3.add("dojo-v1x-i18n-Api",1);var _a=_1.i18n={},_b=/(^.*(^|\/)nls)(\/|$)([^\/]*)\/?([^\/]*)/,_c=function(_d,_e,_f,_10){for(var _11=[_f+_10],_12=_e.split("-"),_13="",i=0;i<_12.length;i++){_13+=(_13?"-":"")+_12[i];if(!_d||_d[_13]){_11.push(_f+_13+"/"+_10);_11.specificity=_13;}}return _11;},_14={},_15=function(_16,_17,_18){_18=_18?_18.toLowerCase():_1.locale;_16=_16.replace(/\./g,"/");_17=_17.replace(/\./g,"/");return (/root/i.test(_18))?(_16+"/nls/"+_17):(_16+"/nls/"+_18+"/"+_17);},_19=_1.getL10nName=function(_1a,_1b,_1c){return _1a=_9.id+"!"+_15(_1a,_1b,_1c);},_1d=function(_1e,_1f,_20,_21,_22,_23){_1e([_1f],function(_24){var _25=_6.clone(_24.root||_24.ROOT),_26=_c(!_24._v1x&&_24,_22,_20,_21);_1e(_26,function(){for(var i=1;i<_26.length;i++){_25=_6.mixin(_6.clone(_25),arguments[i]);}var _27=_1f+"/"+_22;_14[_27]=_25;_25.$locale=_26.specificity;_23();});});},_28=function(id,_29){return /^\./.test(id)?_29(id):id;},_2a=function(_2b){var _2c=_5.extraLocale||[];_2c=_6.isArray(_2c)?_2c:[_2c];_2c.push(_2b);return _2c;},_2d=function(id,_2e,_2f){var _30=_b.exec(id),_31=_30[1]+"/",_32=_30[5]||_30[4],_33=_31+_32,_34=(_30[5]&&_30[4]),_35=_34||_1.locale||"",_36=_33+"/"+_35,_37=_34?[_35]:_2a(_35),_38=_37.length,_39=function(){if(!--_38){_2f(_6.delegate(_14[_36]));}},_3a=id.split("*"),_3b=_3a[1]=="preload";if(_3("dojo-preload-i18n-Api")){if(_3b){if(!_14[id]){_14[id]=1;_46(_3a[2],_8.parse(_3a[3]),1,_2e);}_2f(1);}if(_3b||(_67(id,_2e,_2f)&&!_14[_36])){return;}}else{if(_3b){_2f(1);return;}}_4.forEach(_37,function(_3c){var _3d=_33+"/"+_3c;if(_3("dojo-preload-i18n-Api")){_3e(_3d);}if(!_14[_3d]){_1d(_2e,_33,_31,_32,_3c,_39);}else{_39();}});};if(_3("dojo-preload-i18n-Api")||1){var _3f=_a.normalizeLocale=function(_40){var _41=_40?_40.toLowerCase():_1.locale;return _41=="root"?"ROOT":_41;},_42=function(mid,_43){return (1&&1)?_43.isXdUrl(_2.toUrl(mid+".js")):true;},_44=0,_45=[],_46=_a._preloadLocalizations=function(_47,_48,_49,_4a){_4a=_4a||_2;function _4b(mid,_4c){if(_42(mid,_4a)||_49){_4a([mid],_4c);}else{_6c([mid],_4c,_4a);}};function _4d(_4e,_4f){var _50=_4e.split("-");while(_50.length){if(_4f(_50.join("-"))){return;}_50.pop();}_4f("ROOT");};function _51(){_44++;};function _52(){--_44;while(!_44&&_45.length){_2d.apply(null,_45.shift());}};function _53(_54,_55,loc,_56){return _56.toAbsMid(_54+_55+"/"+loc);};function _57(_58){_58=_3f(_58);_4d(_58,function(loc){if(_4.indexOf(_48,loc)>=0){var mid=_47.replace(/\./g,"/")+"_"+loc;_51();_4b(mid,function(_59){for(var p in _59){var _5a=_59[p],_5b=p.match(/(.+)\/([^\/]+)$/),_5c,_5d;if(!_5b){continue;}_5c=_5b[2];_5d=_5b[1]+"/";if(!_5a._localized){continue;}var _5e;if(loc==="ROOT"){var _5f=_5e=_5a._localized;delete _5a._localized;_5f.root=_5a;_14[_2.toAbsMid(p)]=_5f;}else{_5e=_5a._localized;_14[_53(_5d,_5c,loc,_2)]=_5a;}if(loc!==_58){function _60(_61,_62,_63,_64){var _65=[],_66=[];_4d(_58,function(loc){if(_64[loc]){_65.push(_2.toAbsMid(_61+loc+"/"+_62));_66.push(_53(_61,_62,loc,_2));}});if(_65.length){_51();_4a(_65,function(){for(var i=_65.length-1;i>=0;i--){_63=_6.mixin(_6.clone(_63),arguments[i]);_14[_66[i]]=_63;}_14[_53(_61,_62,_58,_2)]=_6.clone(_63);_52();});}else{_14[_53(_61,_62,_58,_2)]=_63;}};_60(_5d,_5c,_5a,_5e);}}_52();});return true;}return false;});};_57();_4.forEach(_1.config.extraLocale,_57);},_67=function(id,_68,_69){if(_44){_45.push([id,_68,_69]);}return _44;},_3e=function(){};}if(1){var _6a={},_6b,_6c=function(_6d,_6e,_6f){var _70=[];_4.forEach(_6d,function(mid){var url=_6f.toUrl(mid+".js");function _2d(_71){if(!_6b){_6b=new Function("__bundle","__checkForLegacyModules","__mid","__amdValue","var define = function(mid, factory){define.called = 1; __amdValue.result = factory || mid;},"+"\t   require = function(){define.called = 1;};"+"try{"+"define.called = 0;"+"eval(__bundle);"+"if(define.called==1)"+"return __amdValue;"+"if((__checkForLegacyModules = __checkForLegacyModules(__mid)))"+"return __checkForLegacyModules;"+"}catch(e){}"+"try{"+"return eval('('+__bundle+')');"+"}catch(e){"+"return e;"+"}");}var _72=_6b(_71,_3e,mid,_6a);if(_72===_6a){_70.push(_14[url]=_6a.result);}else{if(_72 instanceof Error){console.error("failed to evaluate i18n bundle; url="+url,_72);_72={};}_70.push(_14[url]=(/nls\/[^\/]+\/[^\/]+$/.test(url)?_72:{root:_72,_v1x:1}));}};if(_14[url]){_70.push(_14[url]);}else{var _73=_6f.syncLoadNls(mid);if(!_73){_73=_3e(mid.replace(/nls\/([^\/]*)\/([^\/]*)$/,"nls/$2/$1"));}if(_73){_70.push(_73);}else{if(!_7){try{_6f.getText(url,true,_2d);}catch(e){_70.push(_14[url]={});}}else{_7.get({url:url,sync:true,load:_2d,error:function(){_70.push(_14[url]={});}});}}}});_6e&&_6e.apply(null,_70);};_3e=function(_74){for(var _75,_76=_74.split("/"),_77=_1.global[_76[0]],i=1;_77&&i<_76.length-1;_77=_77[_76[i++]]){}if(_77){_75=_77[_76[i]];if(!_75){_75=_77[_76[i].replace(/-/g,"_")];}if(_75){_14[_74]=_75;}}return _75;};_a.getLocalization=function(_78,_79,_7a){var _7b,_7c=_15(_78,_79,_7a);_2d(_7c,(!_42(_7c,_2)?function(_7d,_7e){_6c(_7d,_7e,_2);}:_2),function(_7f){_7b=_7f;});return _7b;};}return _6.mixin(_a,{dynamic:true,normalize:_28,load:_2d,cache:_14,getL10nName:_19});});
\ No newline at end of file