12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- define(["dojo"], function(dojo) {
- var
- nlsRe=
-
-
-
-
-
-
-
- /(^.*(^|\/)nls(\/|$))([^\/]*)\/?([^\/]*)/,
-
- getAvailableLocales= function(
- root,
- locale,
- bundlePath,
- bundleName
- ){
-
-
-
-
-
-
-
-
- for(var result= [bundlePath + bundleName], localeParts= locale.split("-"), current= "", i= 0; i<localeParts.length; i++){
- current+= localeParts[i];
- if(root[current]){
- result.push(bundlePath + current + "/" + bundleName);
- }
- }
- return result;
- },
- cache= {};
- return {
- load: function(id, require, load){
-
- var
- match= nlsRe.exec(id),
- bundlePath= (require.toAbsMid && require.toAbsMid(match[1])) || match[1],
- bundleName= match[5] || match[4],
- bundlePathAndName= bundlePath + bundleName,
- locale= (match[5] && match[4]) || dojo.locale,
- target= bundlePathAndName + "/" + locale;
-
- if (cache[target]) {
- load(cache[target]);
- return;
- }
-
- require([bundlePathAndName], function(root){
- var
- current= cache[bundlePathAndName + "/"]= dojo.clone(root.root),
- availableLocales= getAvailableLocales(root, locale, bundlePath, bundleName);
- require(availableLocales, function(){
- for (var i= 1; i<availableLocales.length; i++){
- cache[bundlePathAndName + "/" + availableLocales[i]]= current= dojo.mixin(dojo.clone(current), arguments[i]);
- }
-
- cache[target]= current;
- load(current);
- });
- });
- },
- cache: function(mid, value){
- cache[mid]= value;
- }
- };
- });
|