/usr/share/javascript/yui3/intl/intl.js is in libjs-yui3-full 3.5.1-1ubuntu3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | /*
YUI 3.5.1 (build 22)
Copyright 2012 Yahoo! Inc. All rights reserved.
Licensed under the BSD License.
http://yuilibrary.com/license/
*/
YUI.add('intl', function(Y) {
var _mods = {},
ROOT_LANG = "yuiRootLang",
ACTIVE_LANG = "yuiActiveLang",
NONE = [];
/**
* Provides utilities to support the management of localized resources (strings and formatting patterns).
*
* @module intl
*/
/**
* The Intl utility provides a central location for managing sets of localized resources (strings and formatting patterns).
*
* @class Intl
* @uses EventTarget
* @static
*/
Y.mix(Y.namespace("Intl"), {
/**
* Private method to retrieve the language hash for a given module.
*
* @method _mod
* @private
*
* @param {String} module The name of the module
* @return {Object} The hash of localized resources for the module, keyed by BCP language tag
*/
_mod : function(module) {
if (!_mods[module]) {
_mods[module] = {};
}
return _mods[module];
},
/**
* Sets the active language for the given module.
*
* Returns false on failure, which would happen if the language had not been registered through the <a href="#method_add">add()</a> method.
*
* @method setLang
*
* @param {String} module The module name.
* @param {String} lang The BCP 47 language tag.
* @return boolean true if successful, false if not.
*/
setLang : function(module, lang) {
var langs = this._mod(module),
currLang = langs[ACTIVE_LANG],
exists = !!langs[lang];
if (exists && lang !== currLang) {
langs[ACTIVE_LANG] = lang;
this.fire("intl:langChange", {module: module, prevVal: currLang, newVal: (lang === ROOT_LANG) ? "" : lang});
}
return exists;
},
/**
* Get the currently active language for the given module.
*
* @method getLang
*
* @param {String} module The module name.
* @return {String} The BCP 47 language tag.
*/
getLang : function(module) {
var lang = this._mod(module)[ACTIVE_LANG];
return (lang === ROOT_LANG) ? "" : lang;
},
/**
* Register a hash of localized resources for the given module and language
*
* @method add
*
* @param {String} module The module name.
* @param {String} lang The BCP 47 language tag.
* @param {Object} strings The hash of localized values, keyed by the string name.
*/
add : function(module, lang, strings) {
lang = lang || ROOT_LANG;
this._mod(module)[lang] = strings;
this.setLang(module, lang);
},
/**
* Gets the module's localized resources for the currently active language (as provided by the <a href="#method_getLang">getLang</a> method).
* <p>
* Optionally, the localized resources for alternate languages which have been added to Intl (see the <a href="#method_add">add</a> method) can
* be retrieved by providing the BCP 47 language tag as the lang parameter.
* </p>
* @method get
*
* @param {String} module The module name.
* @param {String} key Optional. A single resource key. If not provided, returns a copy (shallow clone) of all resources.
* @param {String} lang Optional. The BCP 47 language tag. If not provided, the module's currently active language is used.
* @return String | Object A copy of the module's localized resources, or a single value if key is provided.
*/
get : function(module, key, lang) {
var mod = this._mod(module),
strs;
lang = lang || mod[ACTIVE_LANG];
strs = mod[lang] || {};
return (key) ? strs[key] : Y.merge(strs);
},
/**
* Gets the list of languages for which localized resources are available for a given module, based on the module
* meta-data (part of loader). If loader is not on the page, returns an empty array.
*
* @method getAvailableLangs
* @param {String} module The name of the module
* @return {Array} The array of languages available.
*/
getAvailableLangs : function(module) {
var loader = Y.Env._loader,
mod = loader && loader.moduleInfo[module],
langs = mod && mod.lang;
return (langs) ? langs.concat() : NONE;
}
});
Y.augment(Y.Intl, Y.EventTarget);
/**
* Notification event to indicate when the lang for a module has changed. There is no default behavior associated with this event,
* so the on and after moments are equivalent.
*
* @event intl:langChange
* @param {EventFacade} e The event facade
* <p>The event facade contains:</p>
* <dl>
* <dt>module</dt><dd>The name of the module for which the language changed</dd>
* <dt>newVal</dt><dd>The new language tag</dd>
* <dt>prevVal</dt><dd>The current language tag</dd>
* </dl>
*/
Y.Intl.publish("intl:langChange", {emitFacade:true});
}, '3.5.1' ,{requires:['event-custom', 'intl-base']});
|