1 19 20 package org.netbeans.modules.j2ee.blueprints.ui; 21 22 import java.net.URL ; 23 import java.util.Locale ; 24 25 28 public class BpcatalogLocalizedResource { 29 30 private String orgpath; 31 private Locale defaultLocale; 32 private String lang; 33 private String country; 34 private String variant; 35 private int offset; 36 private URL articleURL; 37 38 39 public BpcatalogLocalizedResource(String resource, String suffix) { 40 orgpath = resource; 41 defaultLocale = Locale.getDefault(); 42 lang = defaultLocale.getLanguage(); 43 country = defaultLocale.getCountry(); 44 variant = defaultLocale.getVariant(); 45 offset = resource.indexOf("."+suffix); 46 } 47 48 public URL getResourceURL() { 49 String path = getResourcePath(); 50 articleURL = (URL )getClass().getResource(path); 51 return articleURL; 52 } 53 54 public String getResourcePath() { 55 StringBuffer path = new StringBuffer (orgpath); 56 if (!variant.equals("")) { 57 if (!country.equals("")) { 58 path.insert(offset, "_"+lang+"_"+country+"_"+variant); 59 articleURL = getClass().getResource(path.toString()); 60 if (articleURL!=null) { 61 return path.toString(); 62 } 63 } 64 } 65 if (!country.equals("")) { 66 path.replace(0, path.length(), orgpath); 68 path.insert(offset, "_"+lang+"_"+country); 69 articleURL = getClass().getResource(path.toString()); 70 if (articleURL!=null) { 71 return path.toString(); 72 } 73 } 74 path.replace(0, path.length(), orgpath); 75 path.insert(offset, "_"+lang); 76 articleURL = getClass().getResource(path.toString()); 77 if (articleURL!=null) { 78 return path.toString(); 79 } else { 80 return orgpath; 81 } 82 } 83 84 } 85 | Popular Tags |