Wednesday, October 3, 2012

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


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.

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/tLMLidKY-mIJ.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment