Debian Codegraph @

dojox/app/utils/nls.js

raw symbols SCIP
1 define(["require", "dojo/Deferred"], function(require, Deferred){
2 return function(/*Object*/ config, /*Object*/ parent){
3 // summary:
4 // nsl is called to create to load the nls all for the app, or for a view.
5 // config: Object
6 // The section of the config for this view or for the app.
7 // parent: Object
8 // The parent of this view or the app itself, so that models from the parent will be
9 // available to the view.
10 var path = config.nls;
11 if(path){
12 var nlsDef = new Deferred();
13 var requireSignal;
14 try{
15 var loadFile = path;
16 var index = loadFile.indexOf("./");
17 if(index >= 0){
18 loadFile = path.substring(index+2);
19 }
20 requireSignal = require.on ? require.on("error", function(error){
21 if (nlsDef.isResolved() || nlsDef.isRejected()) {
22 return;
23 }
24 if(error.info[0] && (error.info[0].indexOf(loadFile)>= 0)){
25 nlsDef.resolve(false);
26 if(requireSignal){
27 requireSignal.remove();
28 }
29 }
30 }) : null;
31
32 if(path.indexOf("./") == 0){
33 path = "app/"+path;
34 }
35
36 require(["dojo/i18n!"+path], function(nls){
37 nlsDef.resolve(nls);
38 requireSignal.remove();
39 });
40 }catch(e){
41 nlsDef.reject(e);
42 if(requireSignal){
43 requireSignal.remove();
44 }
45 }
46 return nlsDef;
47 }else{
48 return false;
49 }
50 };
51 });