source: Dev/trunk/src/client/dojox/app/utils/nls.js @ 532

Last change on this file since 532 was 483, checked in by hendrikvanantwerpen, 11 years ago

Added Dojo 1.9.3 release.

  • Property svn:executable set to *
File size: 1.2 KB
Line 
1define(["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("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                                                requireSignal.remove();
27                                        }
28                                });
29
30                                if(path.indexOf("./") == 0){
31                                        path = "app/"+path;
32                                }
33
34                                require(["dojo/i18n!"+path], function(nls){
35                                        nlsDef.resolve(nls);
36                                        requireSignal.remove();
37                                });
38                        }catch(e){
39                                nlsDef.reject(e);
40                                if(requireSignal){
41                                        requireSignal.remove();
42                                }
43                        }
44                        return nlsDef;
45                }else{
46                        return false;
47                }
48        };
49});
Note: See TracBrowser for help on using the repository browser.