~ubuntu-branches/ubuntu/raring/maas/raring-updates

« back to all changes in this revision

Viewing changes to src/maasserver/static/jslibs/yui/3.4.1/build/widget-locale/widget-locale-debug.js

  • Committer: Package Import Robot
  • Author(s): Andres Rodriguez
  • Date: 2012-07-03 17:42:37 UTC
  • mfrom: (1.1.13)
  • Revision ID: package-import@ubuntu.com-20120703174237-p8l0keuuznfg721k
Tags: 0.1+bzr709+dfsg-0ubuntu1
* New Upstream release
* debian/control:
  - Depends on python-celery, python-tempita, libjs-yui3-{full,min},
    libjs-raphael
* debian/maas.install:
  - Install apiclient, celeryconfig.py, maas-import-pxe-files, preseeds_v2.
  - Update to install various files from chroot, rather tha manually copy
    them from the source.
* debian/maas.links: symlink celeryconfig.py
* debian/maas.maas-celery.upstart: Add job.
* debian/rules:
  - Install celery upstart job.
  - Do not install jslibs as packages are now used.
  - Drop copying of maas_local_settings_sample.py as source now ships
    a maas_local_settings.py
* debian/patches:
  - 04-maas-http-fix.patch: Drop. Merged upstream.
  - 01-fix-database-settings.patch: Refreshed.
  - 99_enums_js.patch: Added until creation of enum.js / build process
    is fixed.
* debian/maas.postinst: Update bzr version to correctly handle upgrades.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
YUI 3.4.1 (build 4118)
3
 
Copyright 2011 Yahoo! Inc. All rights reserved.
4
 
Licensed under the BSD License.
5
 
http://yuilibrary.com/license/
6
 
*/
7
 
YUI.add('widget-locale', function(Y) {
8
 
 
9
 
/**
10
 
 * Provides string support for widget with BCP 47 language tag lookup. This module has been deprecated. It's replaced by the "intl" module which provides generic internationalization and BCP 47 language tag support with externalization.
11
 
 *
12
 
 * @module widget-locale
13
 
 * @deprecated This module has been deprecated. It's replaced by the "intl" module which provides generic internationalization and BCP 47 language tag support with externalization.
14
 
 */
15
 
var TRUE = true,
16
 
    LOCALE = "locale",
17
 
    INIT_VALUE = "initValue",
18
 
    HYPHEN = "-",
19
 
    EMPTY_STR = "",
20
 
    Widget = Y.Widget;
21
 
 
22
 
/**
23
 
 * @attribute locale
24
 
 * @deprecated Use Y.config.lang and Y.Intl externalization support
25
 
 * @description
26
 
 * The default locale for the widget. NOTE: Using get/set on the "strings" attribute will
27
 
 * return/set strings for this locale.
28
 
 * @default "en"
29
 
 * @type String
30
 
 */
31
 
Widget.ATTRS[LOCALE] = {
32
 
    value: "en"
33
 
};
34
 
 
35
 
// Since strings support with locale needs the private _strs setup
36
 
Widget.ATTRS.strings.lazyAdd = false;
37
 
 
38
 
Y.mix(Widget.prototype, {
39
 
 
40
 
    /**
41
 
     * Sets strings for a particular locale, merging with any existing
42
 
     * strings which may already be defined for the locale.
43
 
     *
44
 
     * @method _setStrings
45
 
     * @protected
46
 
     * @param {Object} strings The hash of string key/values to set
47
 
     * @param {Object} locale The locale for the string values being set
48
 
     */
49
 
    _setStrings : function(strings, locale) {
50
 
        var strs = this._strs;
51
 
        locale = locale.toLowerCase();
52
 
 
53
 
        if (!strs[locale]) {
54
 
            strs[locale] = {};
55
 
        }
56
 
 
57
 
        Y.aggregate(strs[locale], strings, TRUE);
58
 
        return strs[locale];
59
 
    },
60
 
 
61
 
    /**
62
 
     * Returns the strings key/value hash for a paricular locale, without locale lookup applied.
63
 
     *
64
 
     * @method _getStrings
65
 
     * @protected
66
 
     * @param {Object} locale
67
 
     */
68
 
    _getStrings : function(locale) {
69
 
        return this._strs[locale.toLowerCase()];
70
 
    },
71
 
 
72
 
    /**
73
 
     * Gets the entire strings hash for a particular locale, performing locale lookup.
74
 
     * <p>
75
 
     * If no values of the key are defined for a particular locale the value for the 
76
 
     * default locale (in initial locale set for the class) is returned.
77
 
     * </p>
78
 
     * @method getStrings
79
 
     * @param {String} locale (optional) The locale for which the string value is required. Defaults to the current locale, if not provided.
80
 
     */
81
 
    // TODO: Optimize/Cache. Clear cache on _setStrings call.
82
 
    getStrings : function(locale) {
83
 
    
84
 
        locale = (locale || this.get(LOCALE)).toLowerCase();
85
 
    
86
 
        Y.log("getStrings: For " + locale, "info", "widget"); 
87
 
    
88
 
        var defLocale = this.getDefaultLocale().toLowerCase(),
89
 
            defStrs = this._getStrings(defLocale),
90
 
            strs = (defStrs) ? Y.merge(defStrs) : {},
91
 
            localeSegments = locale.split(HYPHEN),
92
 
            localeStrs,
93
 
            i, l,
94
 
            lookup;
95
 
    
96
 
        // If locale is different than the default, or needs lookup support
97
 
        if (locale !== defLocale || localeSegments.length > 1) {
98
 
            lookup = EMPTY_STR;
99
 
            for (i = 0, l = localeSegments.length; i < l; ++i) {
100
 
                lookup += localeSegments[i];
101
 
    
102
 
                Y.log("getStrings: Merging in strings from: " + lookup, "info", "widget"); 
103
 
    
104
 
                localeStrs = this._getStrings(lookup);
105
 
                if (localeStrs) {
106
 
                    Y.aggregate(strs, localeStrs, TRUE);
107
 
                }
108
 
                lookup += HYPHEN;
109
 
            }
110
 
        }
111
 
    
112
 
        return strs;
113
 
    },
114
 
    
115
 
    /**
116
 
     * Gets the string for a particular key, for a particular locale, performing locale lookup.
117
 
     * <p>
118
 
     * If no values if defined for the key, for the given locale, the value for the 
119
 
     * default locale (in initial locale set for the class) is returned.
120
 
     * </p>
121
 
     * @method getString
122
 
     * @param {String} key The key.
123
 
     * @param {String} locale (optional) The locale for which the string value is required. Defaults to the current locale, if not provided.
124
 
     */
125
 
    getString : function(key, locale) {
126
 
 
127
 
        locale = (locale || this.get(LOCALE)).toLowerCase();
128
 
    
129
 
        Y.log("getString: For " + locale, "info", "widget"); 
130
 
    
131
 
        var defLocale = (this.getDefaultLocale()).toLowerCase(),
132
 
            strs = this._getStrings(defLocale) || {},
133
 
            str = strs[key],
134
 
            idx = locale.lastIndexOf(HYPHEN);
135
 
    
136
 
        // If locale is different than the default, or needs lookup support
137
 
        if (locale !== defLocale || idx != -1) {
138
 
            do {
139
 
                Y.log("getString: Performing lookup for: " + locale, "info", "widget"); 
140
 
    
141
 
                strs = this._getStrings(locale);
142
 
                if (strs && key in strs) {
143
 
                    str = strs[key];
144
 
                    break;
145
 
                }
146
 
                idx = locale.lastIndexOf(HYPHEN);
147
 
                // Chop of last locale segment
148
 
                if (idx != -1) {
149
 
                    locale = locale.substring(0, idx);
150
 
                }
151
 
    
152
 
            } while (idx != -1);
153
 
        }
154
 
    
155
 
        return str;
156
 
    },
157
 
 
158
 
    /**
159
 
     * Returns the default locale for the widget (the locale value defined by the
160
 
     * widget class, or provided by the user during construction).
161
 
     *
162
 
     * @method getDefaultLocale
163
 
     * @return {String} The default locale for the widget
164
 
     */
165
 
    getDefaultLocale : function() {
166
 
        return this._state.get(LOCALE, INIT_VALUE);
167
 
    },
168
 
    
169
 
    _strSetter : function(val) {
170
 
        return this._setStrings(val, this.get(LOCALE));
171
 
    },
172
 
 
173
 
    _strGetter : function(val) {
174
 
        return this._getStrings(this.get(LOCALE));
175
 
    }
176
 
}, true);
177
 
 
178
 
 
179
 
}, '3.4.1' ,{requires:['widget-base']});