How to dynamically choose locale at SuperDevMode compile time?

564 views
Skip to first unread message

Davide Cavestro

unread,
Jul 18, 2014, 10:10:50 AM7/18/14
to google-we...@googlegroups.com
It seems that the super dev mode cannot benefit from the meta tag defined within a dynamic host page. I originally tried switching to the cookie solution, but now I guess the compilation triggered by the bookmarklet simply ignores any locale-related info derived from the host page, such as the meta property, the query param and the cookie (set on host page domain).
But this way - supposed the gwt locale should reflect some data coming from a database - we have no way to make the superdevmode aware of the chosen locale.

Moreover, Thomas Broyer recently suggested to
set the locale property to the full list of supported locales:
<set-property name="locale" value="en,fr" />
in order to achieve dynamic internationalization. I thought simply extending the locale property with additional values was enough, but I've found no documentation talking about multiple values for this property.
But as soon as I define multiple values for the locale property, the SuperDevMode starts compiling too many permutations, eventually complaining Multiple fragment 0 sourcemaps found. Too many permutations.
I guess this happens because it has no way to reduce the permutations based on the chosen locale (in fact it doesn't log any binding: locale=...).

So my question is: what should I do in order to dynamically choose the locale used by SDM compiler?

Davide Cavestro

unread,
Jul 23, 2014, 11:56:32 AM7/23/14
to google-we...@googlegroups.com
Hey guys, no idea at all? I would need a way to set the locale for the super dev mode compile (even from dedicated bookmarklets would be enough...)

Aleš Pečnik

unread,
Aug 12, 2014, 4:20:37 PM8/12/14
to google-we...@googlegroups.com
I use meta tag in HTML for setting locale:
<meta name="gwt:property" content="locale=en" />

I use GWT from trunk, in Eclipse with -superDevMode argument, without bookmarklet. This patch works for me:

diff --git a/dev/codeserver/java/com/google/gwt/dev/codeserver/dev_mode_on.js b/dev/codeserver/java/com/google/gwt/dev/codeserver/dev_mode_on.js
index 2964be7..9bb0a92 100644
--- a/dev/codeserver/java/com/google/gwt/dev/codeserver/dev_mode_on.js
+++ b/dev/codeserver/java/com/google/gwt/dev/codeserver/dev_mode_on.js
@@ -380,6 +380,11 @@

     var url = url_prefix + '_callback=__gwt_bookmarklet_globals.callbacks.' +
         callback_id;
+    var nodelist=document.getElementsByTagName('meta');
+    for(var i=0; i<nodelist.length; i++) {
+        if(nodelist[i].getAttribute('name')=='gwt:property')
+            url+='&'+nodelist[i].getAttribute('content');
+    }

     var script = $doc.createElement('script');
     script.src = url;
diff --git a/dev/codeserver/java/com/google/gwt/dev/codeserver/stub.nocache.js b/dev/codeserver/java/com/google/gwt/dev/codeserver/stub.nocache.js
index 0b83ae6..bcb95de 100755
--- a/dev/codeserver/java/com/google/gwt/dev/codeserver/stub.nocache.js
+++ b/dev/codeserver/java/com/google/gwt/dev/codeserver/stub.nocache.js
@@ -202,6 +202,12 @@
     var compileScript = $doc.createElement('script');
     compileScript.src = serverUrl +
       '/recompile/__MODULE_NAME__?user.agent=' + ua + '&_callback=' + callback;
+    var nodelist=document.getElementsByTagName('meta');
+    for(var i=0; i<nodelist.length; i++) {
+        if(nodelist[i].getAttribute('name')=='gwt:property')
+            compileScript.src+='&'+nodelist[i].getAttribute('content');
+    }
+
     $head.appendChild(compileScript);
     compileButton.className = buttonClassName  + ' gwt-DevModeCompiling';
   }


Reply all
Reply to author
Forward
0 new messages