Loading GWT Messages from a Database

Posted by Lars Tackmann on Stack Overflow See other posts from Stack Overflow or by Lars Tackmann
Published on 2010-04-04T20:38:33Z Indexed on 2010/04/04 20:43 UTC
Read the original article Hit count: 185

Filed under:
|
|

In GWT one typically loads i18n strings using a interface like this:

public interface StatusMessage extends Messages {
   String error(String username);
   :
}

which then loads the actual strings from a StatusMessage.property file:

error=User: {0} does not have access to resource

This is a great solution, however my client is unbendable in his demand for putting the i18n strings in a database so they can be changed at runtime (though its not a requirement that they be changed realtime).

One solution is to create a async service which takes a message ID and user locale and returns a string. I have implemented this and find it terribly ugly (and it introduces a huge amount of extra communication with the server, plus it makes property placeholder replacement rather complicated).

So my question is this, can I in some nice way implement a custom message provider that loads the messages from the backend in one big swoop (for the current user session). If it can also hook into the default GWT message mechanism, then I would be completely happy (i.e. so I can create a interface like above and keep using the the nice {0}, {1}... property replacement format).

Other suggestions for clean database driven messages in GWT are also welcome.

© Stack Overflow or respective owner

Related posts about i18n

Related posts about gwt