Thanks a lot Sebastien!
I will need constants+messages on server side too.

I find it kinda odd though that we have to look for workarounds, given
one of GWT's strong points is supposed to be sharing code between
client and server.

On Oct 6, 10:37 am, Jerome Cance <jerome.ca...@gmail.com> wrote:
> Thans a lot for all your replies.
>
> It does not run for me because my property files are not copied in the
> target directory so your solutions do not find my property file.
>
> I don't understand how I can force the copy of property files in target
> directory. I'm using maven/spring/hibernate/gwt and it's very hard to
> configure all :(
>
> ---------------------------
> Jérôme CANCE
>
> On Tue, Oct 6, 2009 at 6:18 AM, Sebastien <chassa...@gmail.com> wrote:
>
> > Hu,
>
> > One year ago I write a simple support of I18N on server side. The
> > mechanism was based on Java reflexion. All is in a single class:
>
> >http://code.google.com/p/gwt-fusionchart/source/browse/trunk/fusionch...
> > The simple call to GWTI18N.create(XXXMessages.class) provides the
> > expected instance implemented your interface and load properties.
>
> > Maybe this could help you.
>
> > Regards,
> > Seb
>
> > On 6 oct, 02:18, bufferings <bufferi...@gmail.com> wrote:
> > > hi
>
> > > I'm very sorry.
> > > I made a mistake in my writing.
>
> > > >  (2) Use KtrI18NCreator.create() in your server side code
>
> > > Please use
> > > KtrI18N.createConstants() or KtrI18N.createMessages().
> > > These are static methods.
>
> > > --
> > > bufferings
>
> > > 2009/10/6 bufferings <bufferi...@gmail.com>:
>
> > > >> that's exactly what I need and it runs perfectly !
>
> > > >> Thanks a lot !
>
> > > > Glad to hear that.
>
> > > >> Bufferings, when I look at your site, the procedure to make it work
> > seems to
> > > >> be more complex. Why ?
>
> > > > From my site's [How Does It Work?]==
> > > > Kotori I18N uses the super-source trick. It gives the super-source
> > > > code to the client, and gives the real code to the server. In fact, It
> > > > uses the GWT#create(Class) for the client as usual, and it uses the
> > > > javassist for the server to create an implimentation of the interface
> > > > given on the runtime.
>
> > > > For the first time I thought it was going to be simple, but it didn't
> > > > become so because of the limitation of GWT#create(Class) that it must
> > > > be called with a class literal. To cope with the limitation, I created
> > > > Kotori I18N Plugin that automatically create the super-source in your
> > > > project and replace the KtrI18N#createXXX to GWT#create(Class).
>
> > > > Is it confusing? Yes, I think so. But I don't know the other way to
> > > > get over the limitation. I hope GWT to remove the limitation. If the
> > > > limitation would be removed, I will throw the plugin away with
> > > > pleasure.
> > > > ==
>
> > > >> I don't add the super-source tag and it runs like a charm.
>
> > > > If you want to use KtrI18N.create only on the server side not on the
> > > > client, you don't have to use super-source and you don't have to edit
> > > > your gwt.xml module file.
>
> > > > All you have to do is
> > > >  (1) Put ktr-i18n.jar and javassist.jar in your classpath
> > > >  (2) Use KtrI18NCreator.create() in your server side code
>
> > > > --
> > > > bufferings
>
> > > > On 10月5日, 午後11:45, Jerome Cance <jerome.ca...@gmail.com> wrote:
> > > >> Wooah,
>
> > > >> that's exactly what I need and it runs perfectly !
>
> > > >> Thanks a lot !
>
> > > >> I think this kind of feature should be available directly in the GWT
> > > >> project.
>
> > > >> Bufferings, when I look at your site, the procedure to make it work
> > seems to
> > > >> be more complex. Why ?
> > > >> I don't add the super-source tag and it runs like a charm.
>
> > > >> ---------------------------
> > > >> Jérôme CANCE
>
> > > >> On Mon, Oct 5, 2009 at 4:20 PM, bufferings <bufferi...@gmail.com>
> > wrote:
>
> > > >> > Hi Jerome
>
> > > >> > > I want to do on my server side:
> > > >> > > myConstants.myMessage();
>
> > > >> > I also thought about the same thing with you, and I created that
> > with
> > > >> > javassist.
> > > >> > [Kotori I18N Project]
> > > >> >http://code.google.com/p/kotori/wiki/KotoriI18N?wl=en
> > > >> > I think a part of the project is useful to you.
>
> > > >> > If you try using the library,
> > > >> > (1) download "Kotori I18N"(ktr-i18n-0.1.0-alpha-v200909202315.zip).
> > > >> > In this time, you don't have to download "Kotori I18N Plugin(Eclipse
> > > >> > plugin)", which is a trick for the seamless use on both the client
> > and
> > > >> > the server.
> > > >> > (2) Put ktr-i18n.jar and javassist.jar in your classpath.
> > > >> > (3) Use KtrI18NCreator.create() in your server side code like
> > > >> > GWT.create in the client.
>
> > > >> > If you don't use the library,
> > > >> > I think a part of it is useful to you.
>
> >http://code.google.com/p/kotori/source/browse/#svn/trunk/ktr-i18n/src...
>
> > > >> > --
> > > >> > bufferings
>
> > > >> > On 10月5日, 午後9:35, Jerome Cance <jerome.ca...@gmail.com> wrote:
> > > >> > > Thank you for this response, I was thinking of a solution like
> > this but
> > > >> > what
> > > >> > > I don't like in this solution is the use of a constant for server
> > side
> > > >> > > ressource bundle.
>
> > > >> > > If I can, I want to use a function to refer to an
> > internationalized
> > > >> > string.
>
> > > >> > > In summary:
>
> > > >> > > I want to do on my server side:
> > > >> > > myConstants.myMessage();
> > > >> > > (like I do on client side)
>
> > > >> > > instead of:
> > > >> > > myConstants.getString("myMessage");
> > > >> > > (avoid the ressource bundle mechanism to have unicity on client
> > and
> > > >> > server
> > > >> > > internationalization)
>
> > > >> > > But if I can't I will use your solution.
>
> > > >> > > ---------------------------
> > > >> > > Jérôme CANCE
>
> > > >> > > On Mon, Oct 5, 2009 at 2:18 PM, Lothar Kimmeringer <
> > j...@kimmeringer.de
> > > >> > >wrote:
>
> > > >> > > > Jerome C. schrieb:
>
> > > >> > > > > I need to use internationalization files on server side (send
> > email,
> > > >> > > > > and email content is internationalized).
> > > >> > > > > When I use GWT.create on my server side, it does not run
> > (exception).
>
> > > >> > > > [...]
>
> > > >> > > > > If I can, I don't want to use two different mechanisms for
> > client and
> > > >> > > > > server internationalization.
>
> > > >> > > > I solved it by adding the locale-string to the parameters of the
> > > >> > > > servlet-method to be called:
>
> > > >> > > > public String getSomething(String param1, long param2, String
> > locale)
> > > >> > > > throws RemoteServiceException {
> > > >> > > >  ResourceBundle rb = getResourceBundle(locale);
> > > >> > > >  try{
> > > >> > > >    doSomething()
> > > >> > > >  }
> > > >> > > >  catch(Exception e){
> > > >> > > >    throw new
>
> > RemoteServiceException(rb.getString("ServiceGeneral_Error_SomethingHappened­­"));
> > > >> > > >  }
> > > >> > > > }
>
> > > >> > > > public static ResourceBundle getResourceBundle(String locale) {
> > > >> > > >  Locale loc = getLocale(locale);
> > > >> > > >  ResourceBundle rb =
>
> > Utf8ResourceBundle.getBundle(AdminToolsI18NConstants.class.getName(),
> > > >> > loc,
> > > >> > > > AdminToolsI18NConstants.class.getClassLoader());
> > > >> > > >  return rb;
> > > >> > > > }
>
> > > >> > > > public static Locale getLocale(String locale){
> > > >> > > >  if (locale == null){
> > > >> > > >    return null;
> > > >> > > >  }
> > > >> > > >  StringTokenizer tt = new StringTokenizer (locale, "_");
> > > >> > > >  Locale loc = new Locale(tt.nextToken(), tt.hasMoreTokens() ?
> > > >> > > > tt.nextToken() : "", tt.hasMoreTokens() ? tt.nextToken() : "");
> > > >> > > >  return loc;
> > > >> > > > }
>
> > > >> > > > The Utf8ResourceBundle is inspired by
> > > >> > > >http://www.thoughtsabout.net/blog/archives/000044.html
> > > >> > > > That way you can use the ResourceBundle-files you created for
> > the
> > > >> > > > GWT-client. In each bundle I added one property, e.g.
>
> > > >> > > > Locale = DE
>
> > > >> > > > So a call in the GWT-client looks like this:
>
> > > >> > > > public static final MyI18NConstants CONSTANTS =
> > (MyI18NConstants)
> > > >> > > > GWT.create(MyI18NConstants.class);
>
> > > >> > > > [...]
>
> > > >> > > >  GeneralServices.Util.getInstance().getSomething(param1, param2,
> > > >> > > > CONSTANTS.Locale(), new AsyncCallback(){
> > > >> > > >    [...]
> > > >> > > >    public void onFailure(Throwable caught) {
> > > >> > > >      Window.alert(caught.getMessage());
> > > >> > > >    }
> > > >> > > >  };
>
> > > >> > > > If you have defined Messages instead of Constants you can do the
> > > >> > filling
> > > >> > > > of the parameters by a simple text-replacement, e.g. by
> > replaceAll:
>
> > > >> > > > rb.getString(...).replaceAll("\{0\}", e.getMessage());
>
> > > >> > > > Regards, Lothar- 引用テキストを表示しない -
>
> > > >> > > - 引用テキストを表示 -- 引用テキストを表示しない -
>
> > > >> - 引用テキストを表示 -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to