Compiling templates with goog.getMsg

142 views
Skip to first unread message

Andre Tannus

unread,
Nov 16, 2011, 1:19:58 PM11/16/11
to Closure Templates Discuss
Hi. Is it still possible to compile closure templates to that they
turn messages into goog.getMsg calls?

The documentation on http://code.google.com/closure/templates/docs/translation.html#insertingmessages
says the flag --should_generate_goog_msg_defs will do that, but the
latest version of SoyToJsSrcCompiler does not support such flag.

Thanks.

Andre Tannus

unread,
Nov 16, 2011, 10:52:36 PM11/16/11
to closure-temp...@googlegroups.com
Update

It seems the option was removed, perhaps by accident?

I checked it out and here's the diff to put it back in, compiled and it works fine so far.
Check option usage message, I think it needs a tweak.

André

Index: java/src/com/google/template/soy/SoyToJsSrcCompiler.java
===================================================================
--- java/src/com/google/template/soy/SoyToJsSrcCompiler.java (revision 23)
+++ java/src/com/google/template/soy/SoyToJsSrcCompiler.java (working copy)
@@ -84,6 +84,13 @@
           handler = MainClassUtils.BooleanOptionHandler.class)
   private boolean shouldGenerateJsdoc = false;
 
+  @Option(name = "--shouldGenerateGoogMsgDefs",
+          usage = "Set this flag if you want goog.getMsg definitions to be generated for all msg" +
+  "blocks.",
+
+          handler = MainClassUtils.BooleanOptionHandler.class)
+  private boolean shouldGenerateGoogMsgDefs = true;
+
   @Option(name = "--shouldProvideRequireSoyNamespaces",
           usage = "When this option is used, each generated JS file will contain (a) one single" +
                   " goog.provide statement for the corresponding Soy file's namespace and" +
@@ -194,6 +201,7 @@
     jsSrcOptions.setIsUsingIjData(isUsingIjData);
     jsSrcOptions.setCodeStyle(codeStyle);
     jsSrcOptions.setShouldGenerateJsdoc(shouldGenerateJsdoc);
+    jsSrcOptions.setShouldGenerateGoogMsgDefs(shouldGenerateGoogMsgDefs);
     jsSrcOptions.setShouldProvideRequireSoyNamespaces(shouldProvideRequireSoyNamespaces);
     jsSrcOptions.setShouldDeclareTopLevelNamespaces(shouldDeclareTopLevelNamespaces);
     jsSrcOptions.setBidiGlobalDir(bidiGlobalDir);

Mike Samuel

unread,
Nov 17, 2011, 8:46:47 AM11/17/11
to closure-temp...@googlegroups.com
2011/11/16 Andre Tannus <andre....@gmail.com>:

> Update
> It seems the option was removed, perhaps by accident?
> I checked it out and here's the diff to put it back in, compiled and it
> works fine so far.
> Check option usage message, I think it needs a tweak.

Very odd. I don't know how that happened. Thanks for the patch. I
will try and get that fix in soon.

Reply all
Reply to author
Forward
0 new messages