Changeset 1065 in josm for trunk/src/org/openstreetmap/josm/tools
- Timestamp:
- 2008-11-02T15:06:01+01:00 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/I18n.java
r1058 r1065 3 3 4 4 import java.text.MessageFormat; 5 import java.util.Arrays; 6 import java.util.Comparator; 7 import java.util.Locale; 8 import java.util.Vector; 5 9 6 10 /** … … 10 14 */ 11 15 public class I18n { 16 17 /* Base name for translation data. Used for detecting available translations */ 18 private static final String TR_BASE = "org.openstreetmap.josm.i18n.Translation_"; 19 12 20 /** 13 21 * Set by MainApplication. Changes here later will probably mess up everything, because … … 43 51 return i18n.trn(text, pluralText, n); 44 52 } 53 54 /** 55 * Get a list of all available JOSM Translations. 56 * @return an array of locale objects. 57 */ 58 public static final Locale[] getAvailableTranslations() { 59 Vector<Locale> v = new Vector<Locale>(); 60 Locale[] l = Locale.getAvailableLocales(); 61 for (int i = 0; i < l.length; i++) { 62 String cn = TR_BASE + l[i]; 63 try { 64 Class.forName(cn); 65 v.add(l[i]); 66 } catch (ClassNotFoundException e) { 67 } 68 } 69 l = new Locale[v.size()]; 70 l = v.toArray(l); 71 Arrays.sort(l, new Comparator<Locale>() { 72 public int compare(Locale o1, Locale o2) { 73 return o1.toString().compareTo(o2.toString()); 74 } 75 }); 76 return l; 77 } 45 78 }
Note:
See TracChangeset
for help on using the changeset viewer.