Changeset 159 in josm for src/org/openstreetmap/josm/tools
- Timestamp:
- 2006-10-13T13:02:57+02:00 (19 years ago)
- Location:
- src/org/openstreetmap/josm/tools
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/org/openstreetmap/josm/tools/I18n.java
r158 r159 1 1 package org.openstreetmap.josm.tools; 2 2 3 import java.io.File;4 import java.net.URL;5 import java.net.URLClassLoader;6 3 import java.text.MessageFormat; 7 import java.util.Locale;8 import java.util.MissingResourceException;9 10 import org.openstreetmap.josm.Main;11 import org.xnap.commons.i18n.I18nFactory;12 4 13 5 /** … … 17 9 */ 18 10 public class I18n { 19 private static org.xnap.commons.i18n.I18n i18n; 20 21 static { 22 String localeFile = Main.pref.getPreferencesDir()+"lang/"+Locale.getDefault()+".jar"; 23 Class<?> klass = Main.class; 24 if (new File(localeFile).exists()) { 25 try { 26 String url = localeFile.replace('\\','/'); 27 if (System.getProperty("os.name").startsWith("Windows")) 28 url = "file:/"+url; 29 else 30 url = "file://"+url; 31 URLClassLoader loader = new URLClassLoader(new URL[]{new URL(url)}); 32 klass = Class.forName("org.openstreetmap.josm.Translation_"+Locale.getDefault(), true, loader); 33 } catch (Exception e) { 34 System.out.println("Couldn't load locale file "+localeFile); 35 e.printStackTrace(); 36 } 37 } 38 try { 39 i18n = I18nFactory.getI18n(klass); 40 } catch (MissingResourceException e) { 41 System.out.println("Locale '"+Locale.getDefault()+"' not found. Using default."); 42 } 43 } 11 /** 12 * Set by MainApplication. Changes here later will probably mess up everything, because 13 * many strings are already loaded. 14 */ 15 public static org.xnap.commons.i18n.I18n i18n; 44 16 45 17 public static String tr(String text, Object... objects) { -
src/org/openstreetmap/josm/tools/ImageProvider.java
r101 r159 12 12 import java.net.URL; 13 13 import java.util.HashMap; 14 import java.util.LinkedList; 15 import java.util.List; 14 16 import java.util.Map; 15 17 … … 37 39 38 40 /** 41 * Add here all ClassLoader whose ressource should be searched. 42 * Plugin's class loaders are added by main. 43 */ 44 public static final List<Class<?>> sources = new LinkedList<Class<?>>(); 45 46 /** 39 47 * Return an image from the specified location. 40 48 * … … 47 55 subdir += "/"; 48 56 String ext = name.indexOf('.') != -1 ? "" : ".png"; 49 URL path = Main.class.getResource("/images/"+subdir+name+ext); 57 URL path = null; 58 for (Class<?> source : sources) { 59 path = source.getResource("/images/"+subdir+name+ext); 60 if (path != null) 61 break; 62 } 50 63 if (path == null) 51 64 throw new NullPointerException("/images/"+subdir+name+ext+" not found"); … … 108 121 return new ImageIcon(img); 109 122 } 123 124 static { 125 sources.add(Main.class); 126 } 110 127 } -
src/org/openstreetmap/josm/tools/UrlLabel.java
r149 r159 21 21 setContentType("text/html"); 22 22 setText("<html><a href=\""+url+"\">"+description+"</a></html>"); 23 setToolTipText(url); 23 24 setEditable(false); 24 25 setOpaque(false);
Note:
See TracChangeset
for help on using the changeset viewer.