Re: How to change package structure (location) of LocalizableResource

150 views
Skip to first unread message

Joseph Lust

unread,
Oct 3, 2012, 11:13:53 AM10/3/12
to google-we...@googlegroups.com
Ritesh,

I'm not familiar with an ability to override the property and did not see one in i18n.gwt.xml. However, check out the code that actually does the magic as you'll find any undocumented classpath/loaders and properties that you might be able to use in there. 

However, what is the trouble with just added that package structure to your project? Perhaps there is another means to workaround this issue.

Sincerely,
Joseph

Thomas Broyer

unread,
Oct 3, 2012, 11:24:48 AM10/3/12
to google-we...@googlegroups.com

On Thursday, September 27, 2012 4:04:07 PM UTC+2, Ritesh Jagga wrote:
We are using UIBinder to create UI screens and implementing internationalization in them. We are able to read values associated with keys from the LocalizableResource_<locale>.properties file. The docs here https://developers.google.com/web-toolkit/doc/latest/DevGuideUiBinderI18n says that this file should be present at this location com/google/gwt/i18n/client. As far as we are following the package structure and the name of properties file, internationalization works.

Is there a way in which we can change/configure the package structure?

You can make all your generated interfaces extend an interface you create (using ui:baseMessagesInterface in your UiBinder templates); you can then put all your properties' files relative to this interface. And you can also take advantage of annotation inheritance. E.g.

   package com.example.myapp.shared;
   @DefaultLocale("en-US")
   @Generate(format = "com.google.gwt.i18n.server.PropertyCatalogFactory")
   public interface Messages extends com.google.gwt.i18n.client.Messages {
   }

   <ui:UiBinder xmlns:ui="…" ui:baseMessagesInterface="com.example.myapp.shared.Messages">

The reason is that GWT I18N looks up the interface hierarchy to find the messages for a given interface, and given that all I18N interface ultimately extend com.google.gwt.i18n.client.LocalizableResource, you can be sure that GWT will look at that place, so it's the "most central" place where you can put your properties files.
Reply all
Reply to author
Forward
0 new messages