Author: evan
Date: Mon Oct 6 07:25:43 2008
New Revision: 702159
URL: http://svn.apache.org/viewvc?rev=702159&view=rev
Log: (empty)
Modified:
incubator/shindig/trunk/features/opensocial-templates/base.js
incubator/shindig/trunk/features/opensocial-templates/compiler.js
Modified: incubator/shindig/trunk/features/opensocial-templates/base.js
URL:
http://svn.apache.org/viewvc/incubator/shindig/trunk/features/opensocial-templates/base.js?rev=702159&r1=702158&r2=702159&view=diff
==============================================================================
--- incubator/shindig/trunk/features/opensocial-templates/base.js (original)
+++ incubator/shindig/trunk/features/opensocial-templates/base.js Mon Oct 6
07:25:43 2008
@@ -79,6 +79,7 @@
os.VAR_my = "$my";
os.VAR_cur = "$cur";
os.VAR_node = "$node";
+os.VAR_msg = "Msg";
os.VAR_parentnode = "$parentnode";
os.VAR_uniqueId = "$uniqueId";
os.VAR_identifierresolver = "$_ir";
@@ -172,6 +173,38 @@
};
/**
+ * A singleton instance of the current gadget Prefs - only instantiated if
+ * we are in a gadget container.
+ * @type gadgets.Prefs
+ */
+os.gadgetPrefs_ = null;
+if (window['gadgets'] && window['gadgets']['Prefs']) {
+ os.gadgetPrefs_ = new window['gadgets']['Prefs']();
+};
+
+/**
+ * A convenience function to get a localized message by key from the shared
+ * gadgets.Prefs object.
+ * @param {string} key The message key to get
+ * @return {string|null} The localized message for a given key, or null if not
+ * found, or not in the gadgets environment.
+ */
+os.getPrefMessage = function(key) {
+ if (!os.gadgetPrefs_) {
+ return null;
+ }
+ return os.gadgetPrefs_.getMsg(key);
+};
+
+/**
+ * A convenience function for identifier resolver to be able to use
+ * getPrefMessage() both as ${Msg.foo} and ${Msg('foo')}.
+ */
+os.getPrefMessage.get = function(key) {
+ return os.getPrefMessage(key);
+};
+
+/**
* Globally disallowed dynamic attributes. These are the attributes where
* ${} notation will be ignored reguardless of the tag.
*/
Modified: incubator/shindig/trunk/features/opensocial-templates/compiler.js
URL:
http://svn.apache.org/viewvc/incubator/shindig/trunk/features/opensocial-templates/compiler.js?rev=702159&r1=702158&r2=702159&view=diff
==============================================================================
--- incubator/shindig/trunk/features/opensocial-templates/compiler.js (original)
+++ incubator/shindig/trunk/features/opensocial-templates/compiler.js Mon Oct
6 07:25:43 2008
@@ -516,9 +516,9 @@
*/
os.createContext = function(data, opt_globals) {
var context = JsEvalContext.create(data);
- //context.setVariable(os.VAR_cur, os.getValueFromObject_);
context.setVariable(os.VAR_callbacks, []);
context.setVariable(os.VAR_identifierresolver, os.getFromContext);
+ context.setVariable(os.VAR_msg, os.getPrefMessage);
if (opt_globals) {
for (var global in opt_globals) {
context.setVariable(global, opt_globals[global]);