UiBinder i18n Example

313 views
Skip to first unread message

Japi

unread,
Oct 13, 2009, 2:29:56 AM10/13/09
to Google Web Toolkit
I finally gave up...

I know how to use Messages, and i figured out how to use the UiBinder
(which is IMHO the greatest thing that could happend to GWT), But
UiBinderi18n just won't get trhough this thick skull of mine. I've
searched forums, and mailist and browsed through the source code
samples and I just cannot link Message objects to all those ui:msg
tags.

How do you link a Binder to a properties file? how is it that the
parser figures out which property to use for each ui:msg tag?

Is there anyone wise enough to point the way with a simple example /
use case ???

Sripathi Krishnan

unread,
Oct 13, 2009, 9:20:40 AM10/13/09
to google-we...@googlegroups.com
I am also stuck on this one for some time.

ui:msg is fine, and I am able to see the property files that get generated based on those; but I am yet to figure out how I can supply property files for other languages.

--Sri
P.S. And I agree, UiBinder is the greatest thing that has happened to GWT.

2009/10/13 Japi <elj...@gmail.com>

Lore

unread,
Oct 21, 2009, 10:47:58 AM10/21/09
to Google Web Toolkit
if you look at the compiler output, you'll see something like:
Generating sample_translate_source_nl.properties from
SampleEntryBinderImplGenMessages_ for locale nl
(assumming a template Sample.ui.xml)

So take the generated property files from the -gen directory,
translate and put them next to the template, but rename them:
sample_translate_source_nl.properties ->
SampleBinderImplGenMessages_nl.properties
repeat for every locale

and recompile

perhaps not perfect, but it works

On 13 okt, 15:20, Sripathi Krishnan <sripathi.krish...@gmail.com>
wrote:
> I am also stuck on this one for some time.
>
> ui:msg is fine, and I am able to see the property files that get generated
> based on those; but I am yet to figure out how I can supply property files
> for other languages.
>
> --Sri
> P.S. And I agree, UiBinder *is the* greatest thing that has happened to GWT.

Arnaud

unread,
Oct 24, 2009, 8:10:39 AM10/24/09
to Google Web Toolkit

Hi all,

I can't get the default properties file generated !

I don't have -gen in my gwtc so I added it like this in build.xml :

<target name="gwtc" depends="javac" description="GWT compile to
JavaScript">
<java failonerror="true" fork="true"
classname="com.google.gwt.dev.Compiler">
<classpath>
<pathelement location="src"/>
<path refid="project.class.path"/>
</classpath>
<!-- add jvmarg -Xss16M or similar if you see a
StackOverflowError -->
<jvmarg value="-Xmx256M"/>
<!-- Additional arguments like -style PRETTY or -logLevel DEBUG
-->
<arg value="-gen"/>
<arg value="gen"/>
<arg value="com.rheanet.Profiles"/>
</java>
</target>

A "gen" directory get created with a lot of generated java stuff, but
not my properties file !

My XML looks like this :

<ui:UiBinder
xmlns:ui='urn:ui:com.google.gwt.uibinder'
xmlns:g='urn:import:com.google.gwt.user.client.ui'
ui:defaultLocale="es"
ui:generateKeys="com.google.gwt.i18n.rebind.keygen.MD5KeyGenerator"

ui:generateFormat="com.google.gwt.i18n.rebind.format.PropertiesFormat"
ui:generateFilename="PageTest"
ui:generateLocales="default"
>

<!-- StyleSheet -->

<ui:style>
.mainpanel {
border: solid 1px #000000;
}
</ui:style>

<!-- User Interface -->
<g:DockPanel styleName='{style.mainpanel}' width='97%' height='100%'>
<g:Dock direction='NORTH'>
<g:SimplePanel styleName='{style.mainpanel}' width='100%'
height='80px'>
<g:HTML><ui:msg key="testMessage">prueba de mensaje en español</
ui:msg></g:HTML>
</g:SimplePanel>
</g:Dock>
<g:Dock direction='CENTER'>
<g:SimplePanel styleName='{style.mainpanel}' width='100%'
height='100%'><g:HTML>x</g:HTML></g:SimplePanel>
</g:Dock>
<g:Dock direction='SOUTH'>
<g:SimplePanel styleName='{style.mainpanel}' width='100%'
height='30px'><g:HTML>x</g:HTML></g:SimplePanel>
</g:Dock>
</g:DockPanel>

</ui:UiBinder>

Compiles perfectly but no properties files...

I'm using 2.0 ms2

Has somebody suceeded in generated the defaultproperties files and
how ?

Thanks all

Arnaud

Thomas Broyer

unread,
Oct 24, 2009, 10:52:39 AM10/24/09
to Google Web Toolkit


On 24 oct, 14:10, Arnaud <conn...@gmail.com> wrote:
> Hi all,
>
> I can't get the default properties file generated !
>
> I don't have -gen in my gwtc so I added it like this in build.xml :

IIRC, properties files are generated in the -extra dir, while the -gen
dir is only for the Java code of generated classes.

Arnaud

unread,
Oct 24, 2009, 2:54:00 PM10/24/09
to Google Web Toolkit

Works perfectly ! Merci Thomas !

Solo solution is to add : "-extra folder" to the gwtc section in
build.xml

<target name="gwtc" depends="javac" description="GWT compile to
JavaScript">
<java failonerror="true" fork="true"
classname="com.google.gwt.dev.Compiler">
<classpath>
<pathelement location="src"/>
<path refid="project.class.path"/>
</classpath>
<!-- add jvmarg -Xss16M or similar if you see a
StackOverflowError -->
<jvmarg value="-Xmx256M"/>
<!-- Additional arguments like -style PRETTY or -logLevel DEBUG
-->
<arg value="-extra"/>
<arg value="extra"/>
<arg value="com.rheanet.Profiles"/>
</java>
</target>

When doing a build the file will be generated under folder specified.
The files don't get generated in developer mode, only if building
completly.

Arnaud
Reply all
Reply to author
Forward
0 new messages