Hi,
Currently I have created a selection screen for the users to change their Portal Language.
The code attached below works for English, French and German, but none of the other languages.
I think the problem is to do with Locales, but I am not sure.
Anyone experienced this problem? If I select for instance, Greek, the users language doesnt change.
Help greatly appreciated and points readily awarded!
Cheers,
Mark
-
public void doContent(IPortalComponentRequest request, IPortalComponentResponse response)
{
String language = request.getParameter("language");
IUserFactory userFact = UMFactory.getUserFactory();
boolean oksofar = true;
IUser me = request.getUser();
boolean restart = false;
if (oksofar && language!=null) {
try {
IUserMaint modUser =
userFact.getMutableUser(me.getUid());
if (language.equalsIgnoreCase("english"))
modUser.setLocale(Locale.ENGLISH);
if (language.equalsIgnoreCase("french"))
modUser.setLocale(Locale.FRENCH);
if (language.equalsIgnoreCase("german"))
modUser.setLocale(Locale.GERMAN);
if (language.equalsIgnoreCase("dutch")){
modUser.setLocale(new Locale("nl"));
modUser.setCountry("NL");
}
if (language.equalsIgnoreCase("finnish")){
modUser.setLocale(new Locale("fi"));
modUser.setCountry("FI");
}
if (language.equalsIgnoreCase("greek")){
modUser.setLocale(new Locale("el"));
modUser.setCountry("EL");
}
if (language.equalsIgnoreCase("portugese")){
modUser.setLocale(new Locale("pt"));
modUser.setCountry("PT");
}
if (language.equalsIgnoreCase("italian")){
modUser.setLocale(Locale.ITALIAN);
modUser.setCountry("IT");
}
if (language.equalsIgnoreCase("spanish")){
modUser.setLocale(new Locale("es"));
modUser.setCountry("ES");
}
modUser.commit();
modUser.save();
restart = true;
}
catch (Exception e) {
response.write("<br>Problem setting language: "+e.getMessage());
e.printStackTrace();
oksofar = false;
}
}