Overnuts
Overnuts

Reputation: 803

Gwt i18n > generating properties files

I'm using GWT in my stuff, and I would like to make it, international, so I use GWT constants method.

I have a java file with defaults, and I now need to make properties files.

In a remember, there is a special thing to do (or done automagically) to generate a kind of template where all constants are generated with empty labels for other langages.

Did I dream this ?

(using eclipse indigo to develop webapp with gwt but not gae)

[edit:]

this was not a dream, it's i18ncreator:

http://code.google.com/intl/fr-FR/webtoolkit/doc/latest/RefCommandLineTools.html#i18nCreator

but I can't make it working on windows :-(

[edit again ]

due to this issue : http://code.google.com/p/google-web-toolkit/issues/detail?id=5113

recommended solution is use i18ncreator in gwt 1.7 (!)

Upvotes: 4

Views: 3552

Answers (4)

Sai Phaninder Reddy J
Sai Phaninder Reddy J

Reputation: 444

I had the same issue. I was looking all over the place for the answer but could not find an answer; either in the docs or on stackoverflow.

So I asked in the GWT gitter channel and was told to use the compiler argument

-extra <destination-folder-name>

to generate the .properties files from the Interface files.

Steps in eclipse:

  1. Select project you want to compile
  2. [right click] -> Google -> GWT Compile
  3. In the window that opens, open the Advanded options.
  4. Add the following additional compiler argument -extra <destination-folder-name>
  5. Compile

setting compiler option in eclipse to generate the extra files

This should generate the *.properties files in the /destination-folder-name.

NOTE: This only generates the .properties files. It does not actually compile the application with all the locales for deploy.

  1. Move the MyInterfaceExtension_*.properties to be right beside the MyInterfaceExtension.java file.

  2. Make copies for each locale i.e. MyInterfaceExtension_fr_CA.properties, MyInterfaceExtension_fr_FR.properties, etc..

  3. Translate them

  4. Then run the compilation process again with out the -extra <destination-folder-name> option. Because it is not needed anymore.

This will compile with all the locales you enabled. You can now deploy the app the usual way.

Quick Tips:

When compiling for the first time in order to generate the .properties file, I commented out the locales in the module definition file so that the compiler will not sit there and compile again and again for every browser and every locale

i.e. supported_browser_count x enabled_locale_count = 5 browsers x 3 locales = 15 compilation Permutations, which is going to increase your compilation time.

Because, all I needed was that one *_en.properties file.

For the second compilation, after you copied and translated the properties files for each locale, you have to enable all the locales you want to support and compile.

Credits:

  1. github @niloc132 : Colin Alworth
  2. github @ibaca : Ignacio Baca Moreno-Torres

For helping me with this.

Upvotes: 2

dting
dting

Reputation: 39287

For my project, I used the i18n-Creator

http://code.google.com/webtoolkit/doc/latest/DevGuideI18n.html#DevGuidePropertiesFiles

It kind of does the opposite of what you are asking for. With the i18n-creator, you create the properties files for the various locales and run the script that is generated with the i18n-creator, and it will generate the constants interface.

Upvotes: 1

Adi Mor
Adi Mor

Reputation: 2165

you should see the page on locales in GWT

Upvotes: 2

ijball
ijball

Reputation: 108

I haven't heard yet of this feature in Eclipse but IntelliJ IDEA has this feature, you just create the Constants Interface class and the properties file. If you add a method in the class file it will warn you to add the property or the other way around. HTH.

Upvotes: 0

Related Questions