Eclipse compile not generating i18n properties file

232 views
Skip to first unread message

Todd Vierling

unread,
Jan 1, 2010, 11:01:41 AM1/1/10
to Google Web Toolkit
I'm trying to get the GWT compile phase to spit out a template
properties file that I can hand to translators to make it easy to do
translation work. For my server-side strings, I've been using the
xgettext metaphor (and GNU gettext tools to do the string extraction,
which can then convert the translated strings to a .properties file
for ResourceBundle usage).

For the GWT side, I've been having a lot more trouble creating a
template file. For testing, I created a sample Messages interface as
follows:

===
package org.duh.gwt.client.locale;

import com.google.gwt.i18n.client.*;
import com.google.gwt.i18n.client.LocalizableResource.*;

@Generate(format =
"com.google.gwt.i18n.rebind.format.PropertiesFormat", locales =
{"default"})
public interface LocaleMessages extends Messages {
@DefaultMessage("Server error \"{0}\"; please try again later.")
String serverError(String msg);

@DefaultMessage("There's nothing to see here; move along.")
String nothingToSeeHere();
}
===

The other GWT code references these methods in order to include the
class in the compile, and I see the following in the Eclipse console
when doing the GWT compile phase (there's 12 permutations because I
explicitly included "en" in the DuhGWT.gwt.xml config, thus default +
en):

===
Compiling module org.duh.gwt.DuhGWT
Scanning for additional dependencies: file:/C:/Documents%20and
%20Settings/tv/eclipse-workspace/DuhGWT/src/org/duh/gwt/client/
DuhGWTSample.java
Computing all possible rebind results for
'org.duh.gwt.client.locale.LocaleMessages'
Rebinding org.duh.gwt.client.locale.LocaleMessages
Invoking
com.google.gwt.dev.javac.StandardGeneratorContext@1c925db
Generating
org.duh.gwt.client.locale.LocaleMessages.properties from
LocaleMessages_ for locale default
Compiling 12 permutations
Compiling permutation 0...
Compiling permutation 1...
Compiling permutation 2...
Compiling permutation 3...
Compiling permutation 4...
Compiling permutation 5...
Compiling permutation 6...
Compiling permutation 7...
Compiling permutation 8...
Compiling permutation 9...
Compiling permutation 10...
Compiling permutation 11...
Compile of permutations succeeded
Linking into C:\Documents and Settings\tv\eclipse-workspace\DuhGWT\war
\duhgwt.
Link succeeded
Compilation succeeded -- 34.485s
===

I was expecting to find a LocaleMessages.properties or
LocaleMessages_default.properties file somewhere in my workspace, but
it's nowhere to be found. (A cygwin "find . -name '*.properties' in
the workspace only shows my logging.properties file.) I also attempted
setting the annotation's fileName attribute, which did change one line
in the compile output but still didn't appear to create a template
file:

Generating foobar.properties from LocaleMessages_ for
locale default

Is there some way I should attempt to invoke the GWT compiler by hand
to try this a different way? What I'm hoping to get out of this is
similar to what xgettext does: provide a template file where the
constants are initially equal to the @Default* values -- and if
possible, comments generated from @Meaning or @Description annotations
as an aid to the translators. They could then return translated
versions to me, which I would simply check in to source control
alongside the default-locale versions, and never have to deal with the
Java code in-between.

Maybe I'm missing the point of @Generate here, but I'm not exactly
sure what it's supposed to do otherwise. :(

Todd Vierling

unread,
Jan 11, 2010, 4:46:17 PM1/11/10
to Google Web Toolkit
On Jan 1, 11:01 am, Todd Vierling <t...@duh.org> wrote:
> I'm trying to get the GWT compile phase to spit out a template
> properties file that I can hand to translators to make it easy to do
> translation work.

> Is there some way I should attempt to invoke the GWT compiler by hand


> to try this a different way? What I'm hoping to get out of this is
> similar to what xgettext does: provide a template file where the
> constants are initially equal to the @Default* values -- and if
> possible, comments generated from @Meaning or @Description annotations
> as an aid to the translators. They could then return translated
> versions to me, which I would simply check in to source control
> alongside the default-locale versions, and never have to deal with the
> Java code in-between.
>
> Maybe I'm missing the point of @Generate here, but I'm not exactly
> sure what it's supposed to do otherwise. :(

Any insight on this? The GWT compile phase says it's generating a
properties file, but there's none to be found....

dparish

unread,
May 1, 2012, 2:59:34 PM5/1/12
to google-we...@googlegroups.com
Has anyone solved this?  It's not working for me either.  Here's my class:

package dparish.client.view.impl;

import com.google.gwt.i18n.client.Messages;
import com.google.gwt.i18n.client.LocalizableResource.Generate;
import com.google.gwt.i18n.client.LocalizableResource.GenerateKeys;

@Generate(format="com.google.gwt.i18n.server.PropertyCatalogFactory") @GenerateKeys
public interface StudentMessages extends Messages {
public String saveError();
@DefaultMessage("There are {0} students")
@AlternateMessage({"one", "There is one student"})
public String studentCount(@PluralCount int studentCount);

}

No files are created during the GWT compile.  I suspect the problem relates to this note in the docs:

Requests that a message catalog file is generated during the compilation process. If the filename is not supplied, a default name based on the interface name is used. The output file is created under the -out directory.  

There is no -out for the GWT compiler. There IS for i18nCreator, but that command is listed for creating .java files from property files, not the other way around as @Generate seems to claim it will do.

dparish

unread,
May 1, 2012, 3:14:17 PM5/1/12
to google-we...@googlegroups.com
I should note that I am using the -extra compiler flag and it IS generating the property files for UiBinder messages.  I also tried changing the classname for the format to: format="com.google.gwt.i18n.rebind.format.PropertiesFormat" but that did not help.

Interestingly changing it to:

@Generate(format="fudge")

Didn't throw an error so best as I can tell, my interface or the annotation isn't even being seen!!

dparish

unread,
May 1, 2012, 3:28:48 PM5/1/12
to google-we...@googlegroups.com
I figured it out.  I had created the messages file but hadn't started using it in the app at all. The compiler must not scan for all interfaces with that annotation, but instead for all classes IN USE by the app with those annotations.
Reply all
Reply to author
Forward
0 new messages