On Fri, Feb 09, 2001 at 11:20:40AM +0100, ingo schuster wrote:
> Today, it is not easy to build a multi-lingual web application with turbine 
> (apart from having a set of screens for each language). If different users 
> are to be served responses in different languages, then it's currently up 
> to the output producing modules to detect the requested language.
> I'd find it very useful if RunData could hold information about the 
> preferred language for the response. As default the it could be set to the 
> browsers preferred language information and the application could override 
> this setting if it knows better.
> 
> Are you interrested in this enhancment? I'd develop patches.

For this kind of thing, rather than always adding stuff to RunData I
prefer this pattern: (many things like FormMessages for instance might
be better done this way).

package org.apache.turbine.util.UserLanguage;

public class UserLanguage
{
  private static final String TEMP_KEY = "org.apache.turbine.util.UserLanguage";
  public static getUserLanguage(RunData data)
  {
    UserLanguage userLanguage = (UserLanguage)data.getUser().getTemp(TEMP_KEY);
    if (userLanguage == null)
    {
      userLanguage = new UserLanguage();
      data.getUser().setTemp(TEMP_KEY, userLanguage);
    }
    return userLanguage;
  }
}

(or use setPerm/getPerm for persistence)

Then instead of data.getUserLanguage() you simply use
UserLanguage.getUserLanguage(data)

The rest of the class would hold whatever state/preferences you had in
mind for RunData, and could also provide convenience methods to retrieve
messages/template names etc ...

Sean

-- 
Sean Legassick
[EMAIL PROTECTED]
      Hombre soy, nada humano me puede ser ajeno  
      
      


------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Search: <http://www.mail-archive.com/turbine%40list.working-dogs.com/>
Problems?:           [EMAIL PROTECTED]

Reply via email to