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/ktr/i18n/server

--
bufferings


On 10月5日, 午後9:35, Jerome Cance <[email protected]> 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 <[email protected]>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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to