Skip to Content
0
Former Member
Oct 22, 2009 at 11:57 AM

Portal Language through code

19 Views

Hi,

I currently have the following code to check the language of a user within Portal, but when the user has no language populated I would like to set this to a default. How can I check the value as when I have coded this before this has errored.

IUser me = request.getUser();

String language = "en";

Locale myLocale = me.getLocale();

language = myLocale.getLanguage();

try {

IUserMaint modUser = userFact.getMutableUser(me.getUid());

if (language.equalsIgnoreCase(""))

modUser.setLocale(Locale.UK);

if (language.equalsIgnoreCase("english"))

modUser.setLocale(Locale.UK);

if (language.equalsIgnoreCase("italian"))

modUser.setLocale(Locale.ITALIAN);

if (language.equalsIgnoreCase("german"))

modUser.setLocale(Locale.GERMAN);

modUser.commit();

modUser.save();

}

catch (Exception e) {

response.write("<br>Problem setting language: "+e.getMessage());

oksofar = false;

}

Any help would gratefully appreciated.