1 25 26 package net.killingar.actions; 27 28 import webwork.action.SessionAware; 29 30 import java.util.Locale ; 31 import java.util.Map ; 32 import java.util.StringTokenizer ; 33 34 public class ActionSupport extends webwork.action.ActionSupport implements SessionAware 35 { 36 38 40 42 44 public void setSession(Map session) 46 { 47 try 48 { 49 synchronized (session) 50 { 51 Locale localeObject = (Locale )session.get("localeObject"); 52 if (localeObject == null) 53 { 54 String locale = (String )session.get("locale"); 55 56 if (locale != null) 57 { 58 try 59 { 60 StringTokenizer localeTokens = new StringTokenizer (locale, "_"); 61 String lang = null; 62 String country = null; 63 if (localeTokens.hasMoreTokens()) 64 lang = localeTokens.nextToken(); 65 if (localeTokens.hasMoreTokens()) 66 country = localeTokens.nextToken(); 67 68 localeObject = new Locale (lang, country); 69 session.put("localeObject", localeObject); 70 } 71 catch (Exception e){} 72 } 73 } 74 75 if (localeObject != null) 76 webwork.action.ActionContext.setLocale(localeObject); 77 } 78 } 79 catch (Exception e) 80 { 81 addErrorMessage("failed to initialize locale, exception thrown ("+e.toString()+")"); 82 } 83 } 84 } 85 | Popular Tags |