jbdhl schrieb:
> Consider a case where some RPCs in a GWT application will trigger the
> server to send an email to the user where the email should be sent in
> the language used at the requesting client.
> 
> 1) How should I approach this server-side internationalization (i18n)?
> Can GWTs i18n be used in this situation?

I'm using the same property-files I defined for the GWT-project (I'm
using GWT 1.4 and don't use the plural-technique). To be able to read
in UTF-8, I defined my own ResourceBundle-implementation (quite a hack)
that is created the following way:


    /**
     * Returns the ResourceBundle used for localizing data
     * @param locale The Locale to be used
     * @return The ResourceBundle
     */
    public static ResourceBundle getResourceBundle(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() : "");
        ResourceBundle rb = 
Utf8ResourceBundle.getBundle(MyAppI18NConstants.class.getName(), loc, 
MyAppI18NConstants.class.getClassLoader());
        return rb;
    }

Utf8ResourceBundle is copied from
http://www.thoughtsabout.net/blog/archives/000044.html
You have to read the comments to, the original contains bugs.

All my RPC-functions are including a parameter specifying the
locale to be used. Here is an example tat uses this (:

    public String getConfigurationFile(String serviceName, String locale) 
throws RemoteServiceException {
        ResourceBundle rb = getResourceBundle(locale);
        try{
            IService service = 
ServiceFactory.getInstance().getService(serviceName, true);
[...]
        }
        catch(ServiceNotFoundException snfe){
            throw new 
RemoteServiceException(rb.getString("ServiceGeneral_Error_ServiceNotFound"));
        }

The only thing that you have to keep in mind writing the property-files
is that you mustn't use the classic way of specifying non-latin1-characters
by using \u1234 becaue the converted character will be converted to
ISO-8859-1 leading to the loss of this character. The file must be
UTF8 only.

> 2) The email will have multiple paragraphs of text, not just one-line
> messages as the property files are limited to (as far as I know).
> Similarly, our help-page and about-page have many large paragraphs of
> text. How can I translate these multi-line texts?

It's a property-file, so you can add e.g. \n to add a newline or you
add \r\n to add a DOS-newline. That's the reason why you have to use
\\ if you want to add a backslash to your text.


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