1 61 62 package org.objectweb.jonas.webapp.jonasadmin; 63 64 import java.util.ArrayList ; 65 import java.util.List ; 66 import java.util.Locale ; 67 import java.util.ResourceBundle ; 68 69 import org.apache.struts.Globals; 70 import org.apache.struts.action.ActionServlet; 71 import org.apache.struts.util.MessageResources; 72 73 80 81 public final class ApplicationLocales { 82 83 85 90 public ApplicationLocales(ActionServlet servlet) { 91 92 super(); 93 Locale list[] = Locale.getAvailableLocales(); 94 MessageResources resources = (MessageResources) 95 servlet.getServletContext().getAttribute(Globals.MESSAGES_KEY); 96 if (resources == null) { 97 return; 98 } 99 String config = resources.getConfig(); 100 if (config == null) { 101 return; 102 } 103 for (int i = 0; i < list.length; i++) { 104 ResourceBundle bundle = ResourceBundle.getBundle(config, list[i]); 105 if (bundle == null) { 106 continue; 107 } 108 if (list[i].equals(bundle.getLocale())) { 109 localeLabels.add(list[i].getDisplayName()); 110 localeValues.add(list[i].toString()); 111 supportedLocales.add(list[i]); 112 } 113 } 114 115 } 116 117 119 122 protected ArrayList localeLabels = new ArrayList (); 123 124 127 protected ArrayList localeValues = new ArrayList (); 128 129 132 protected ArrayList supportedLocales = new ArrayList (); 133 134 136 139 public List getLocaleLabels() { 140 141 return (localeLabels); 142 143 } 144 145 148 public List getLocaleValues() { 149 150 return (localeValues); 151 152 } 153 154 157 public List getSupportedLocales() { 158 159 return (supportedLocales); 160 161 } 162 163 } 164 | Popular Tags |