Changeset 6979
- Timestamp:
- Sep 20, 2010, 7:40:36 PM (14 years ago)
- Location:
- extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/transverse/util/Messages.java
r6842 r6979 1 1 package fr.mael.jiwigo.transverse.util; 2 2 3 import java.io.File; 4 import java.io.FilenameFilter; 5 import java.util.ArrayList; 6 import java.util.List; 3 7 import java.util.Locale; 4 8 import java.util.ResourceBundle; 9 import java.util.Set; 10 import java.util.TreeSet; 5 11 6 12 /** … … 46 52 } 47 53 54 /** 55 * Gets available translations 56 * @return the list of available translations 57 */ 58 public static List<Locale> getAvailableBundles() { 59 ClassLoader loader = Thread.currentThread().getContextClassLoader(); 60 final String bundlepackage = "fr.mael.jiwigo.trad"; 61 final String bundlename = "messages"; 62 63 File root = new File(loader.getResource(bundlepackage.replace('.', '/')).getFile()); 64 File[] files = root.listFiles(new FilenameFilter() { 65 public boolean accept(File dir, String name) { 66 return name.matches("^" + bundlename + "(_\\w{2}(_\\w{2})?)?\\.properties$"); 67 } 68 }); 69 70 Set<String> languages = new TreeSet<String>(); 71 for (File file : files) { 72 languages.add(file.getName().replaceAll("^" + bundlename + "(_)?|\\.properties$", "")); 73 } 74 75 List<Locale> availableLocales = new ArrayList<Locale>(); 76 for (Locale locale : Locale.getAvailableLocales()) { 77 for (String s : languages) { 78 if (s.equals(locale.getLanguage())) { 79 availableLocales.add(locale); 80 } 81 } 82 } 83 return availableLocales; 84 } 85 48 86 } -
extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/ui/ConnexionDialog.java
r6959 r6979 13 13 import java.text.SimpleDateFormat; 14 14 import java.util.Arrays; 15 import java.util.List; 15 16 import java.util.Locale; 16 17 … … 218 219 */ 219 220 class localeModel extends AbstractListModel implements ComboBoxModel { 220 Locale[] locales = SimpleDateFormat.getAvailableLocales(); 221 // Locale[] locales = SimpleDateFormat.getAvailableLocales(); 222 List<Locale> locales = Messages.getAvailableBundles(); 221 223 String[] localesNames; 222 224 … … 224 226 225 227 public localeModel() { 226 localesNames = new String[locales. length];228 localesNames = new String[locales.size()]; 227 229 int compteur = 0; 228 230 for (Locale locale : locales) { … … 238 240 239 241 public int getSize() { 240 return locales. length;242 return locales.size(); 241 243 } 242 244
Note: See TracChangeset
for help on using the changeset viewer.