1 | (function(){ |
---|
2 | // monkey patch fromJson to avoid Rhino bug in eval: https://bugzilla.mozilla.org/show_bug.cgi?id=471005 |
---|
3 | var fromJson = dojo.fromJson; |
---|
4 | dojo.fromJson = function(json){ |
---|
5 | json = json.replace(/[\u200E\u200F\u202A-\u202E]/g, function(match){ |
---|
6 | return "\\u" + match.charCodeAt(0).toString(16); |
---|
7 | }) |
---|
8 | return json ? fromJson(json) : ""; //TODO: json value passed in shouldn't be empty |
---|
9 | } |
---|
10 | })(); |
---|
11 | |
---|
12 | function isLocaleAliasSrc(prop, bundle){ |
---|
13 | if(!bundle){ return false; } |
---|
14 | var isAlias = false; |
---|
15 | var LOCALE_ALIAS_MARK = '@localeAlias'; |
---|
16 | |
---|
17 | for(x in bundle){ |
---|
18 | if(x.indexOf(LOCALE_ALIAS_MARK) > 0){ |
---|
19 | var prefix = x.substring(0,x.indexOf(LOCALE_ALIAS_MARK)); |
---|
20 | if(prop.indexOf(prefix) == 0){ |
---|
21 | isAlias = true; |
---|
22 | } |
---|
23 | } |
---|
24 | } |
---|
25 | return isAlias; |
---|
26 | } |
---|
27 | |
---|
28 | function getNativeBundle(filePath){ |
---|
29 | // summary: |
---|
30 | // get native bundle content with utf-8 encoding. |
---|
31 | // native means the content of this bundle is not flattened with parent. |
---|
32 | // returns empty object if file not found. |
---|
33 | try{ |
---|
34 | var content = readFile(filePath, "utf-8"); |
---|
35 | return (!content || !content.length) ? {} : dojo.fromJson(content); |
---|
36 | }catch(e){ |
---|
37 | return {}; |
---|
38 | } |
---|
39 | } |
---|
40 | |
---|
41 | function compare(a/*String or Array*/, b/*String or Array*/){ |
---|
42 | // summary: |
---|
43 | // simple comparison |
---|
44 | if(dojo.isArray(a) && dojo.isArray(b)){ |
---|
45 | for(var i = 0; i < a.length; i++){ |
---|
46 | if(a[i] != b[i]){ return false; } |
---|
47 | } |
---|
48 | return true; |
---|
49 | } |
---|
50 | return a==b; |
---|
51 | } |
---|