source: Dev/trunk/src/client/dojox/mobile/i18n.js @ 532

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

Added Dojo 1.9.3 release.

File size: 1.6 KB
Line 
1define([
2        "dojo/_base/lang",
3        "dojo/i18n",
4        "dijit/_WidgetBase"
5], function(lang, di18n, WidgetBase){
6
7        // module:
8        //              dojox/mobile/i18n
9
10        var i18n = {
11                // summary:
12                //              An internationalization utility for applications based on dojox/mobile.
13        };
14        lang.setObject("dojox.mobile.i18n", i18n);
15
16        i18n.load = function(/*String*/packageName, /*String*/bundleName, /*String?*/locale){
17                // summary:
18                //              Loads an nls resource bundle and returns an array of localized
19                //              resources.
20                return i18n.registerBundle(di18n.getLocalization(packageName, bundleName, locale));
21        };
22
23        i18n.registerBundle = function(/*Array*/bundle){
24                // summary:
25                //              Accumulates the given localized resources in an array and returns
26                //              it.
27                if(!i18n.bundle){ i18n.bundle = []; }
28                return lang.mixin(i18n.bundle, bundle);
29        };
30
31        i18n.I18NProperties = {
32                // summary:
33                //              These properties can be specified for any widget once the dojox/mobile/i18n module is loaded.
34
35                // mblNoConv: Boolean
36                //              Disables localization by dojox/mobile/i18n for the widget on which the property is set.
37                mblNoConv: false
38        };
39
40        // Since any widget can have properties localized by dojox/mobile/i18n, mix I18NProperties
41        // into the base widget class.  (This is a hack, but it's effective.)
42        // This is for the benefit of the parser.   Remove for 2.0.  Also, hide from doc viewer.
43        lang.extend(WidgetBase, /*===== {} || =====*/ i18n.I18NProperties);
44
45        // Mixin the _cv method which is called by property setters.
46        lang.extend(WidgetBase, {
47                _cv: function(s){
48                        if(this.mblNoConv || !i18n.bundle){ return s; }
49                        return i18n.bundle[lang.trim(s)] || s;
50                }
51        });
52
53        return i18n;
54});
Note: See TracBrowser for help on using the repository browser.