Changeset 1064
- Timestamp:
- 06/30/09 18:05:35 (15 years ago)
- Location:
- trunk/jabberit_messenger/java_source/src/nu/fw/jeti
- Files:
-
- 3 added
- 4 deleted
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/jabberit_messenger/java_source/src/nu/fw/jeti/applet/Jeti.java
r1014 r1064 66 66 { 67 67 private Start start; 68 public static JLabel from;69 68 private static Jeti applet; 70 69 private URL exitURL; 71 70 private static String groupchatRoom; 72 71 private static String groupchatServer; 73 public static LoginInfo loginInfo;74 72 private Backend backend; 75 73 private boolean started = false; 76 74 private SecureMethodRunner secureMethodInvoker; 75 public static JLabel from; 76 public static LoginInfo loginInfo; 77 77 public static String SERVEREXPRESSO; 78 78 public static String NAMECOMPANY; … … 82 82 public static List GROUPSUSER; 83 83 public static String SERVERJABBER; 84 public static String COUNTRY; 85 public static String LANGUAGE; 86 84 87 /** 85 88 * @Author : Alexandre Correia - alexandrecorreia@celepar.pr.gov.br … … 109 112 String nameCompany = new String(applet.getParameter("NAMECOMPANY")); 110 113 String cnName = new String(applet.getParameter("CNNAME")); 111 114 String country = new String(applet.getParameter("COUNTRY")); 115 String language = new String(applet.getParameter("LANGUAGE")); 116 112 117 /** 113 118 * @Author : Alexandre Correia - alexandrecorreia@celepar.pr.gov.br … … 125 130 USEHTTPS = useHttps; 126 131 CNNAME = cnName; 132 LANGUAGE = language; 133 COUNTRY = country; 134 135 // Reinit languages incase they changed 136 I18N.init(language, country); 127 137 128 138 groupchatRoom = getParameter("GROUPCHATROOM"); … … 144 154 loginInfo = new LoginInfo(server,host,user,password,resource,port,ssl,0,false); 145 155 } 146 156 147 157 Start.programURL = getCodeBase(); 148 158 Start.applet = true; … … 150 160 start = new Start(getCodeBase().toString(),panel); 151 161 152 // Reinit languages incase they changed153 I18N.init();154 155 162 backend = start.getBackend(); 156 163 backend.getMain().translate(); -
trunk/jabberit_messenger/java_source/src/nu/fw/jeti/backend/Start.java
r1014 r1064 56 56 { 57 57 public static final String VERSION = "0.7.7"; 58 //public final static String OS2 = "/2";59 58 public final static String OS2 = ""; 60 59 public static String BUILD_DATE; … … 89 88 ex.printStackTrace(); 90 89 } 91 if(!applet && System.getProperty("jnlpx.home")!=null)webstart = true;92 93 if (urlString == null)urlString = getPath();90 91 if ( urlString == null) 92 urlString = getPath(); 94 93 95 94 if (System.getProperty("file.separator").equals("/")) … … 97 96 pluginPath = urlString.substring(5); 98 97 } 99 else pluginPath = urlString.substring(6); 98 else 99 pluginPath = urlString.substring(6); 100 100 101 pluginPath = pluginPath.replace('/', File.separatorChar); 101 102 102 103 104 if(programURL==null) 105 { 106 try 107 { 108 programURL = new URL(urlString); 109 110 if(webstart || (path!=null&&path.equals("home"))) 111 { 112 path = System.getProperty("user.home")+ File.separatorChar 113 + ".jeti" +File.separatorChar; 114 File dir =new File(path); 115 if(!dir.exists()) 116 { 117 if(!dir.mkdir()) 118 { 119 JOptionPane.showMessageDialog(null, "Directory " + dir + " could not be created, Jeti will close"); 120 System.exit(1); 121 } 122 } 123 dataURL = new URL("file:/"+path); 124 } 125 else if(path!=null) 126 { 127 File dir =new File(path); 128 if(!dir.exists()) 129 { 130 if(!dir.mkdir()) 131 { 132 JOptionPane.showMessageDialog(null, "Directory " + dir + " could not be created, Jeti will close"); 133 System.exit(1); 134 } 135 } 136 dataURL = new URL("file:/"+path); 137 } 138 else 139 { 140 dataURL = programURL; 141 path = pluginPath; 142 } 143 System.out.println(programURL); 144 System.out.println(dataURL); 145 } 146 catch (MalformedURLException ex) 147 { 148 ex.printStackTrace(); 149 } 150 } 151 else 152 { 153 //if programurl null applet or network so use program path as data path 154 dataURL = programURL; 155 path = pluginPath; 156 } 157 103 /** 104 * Se o programurl for null, applet ou network tb usa program path como data path 105 */ 106 107 dataURL = programURL; 108 path = pluginPath; 109 158 110 try 159 111 { … … 162 114 BUILD_DATE = p.getProperty("buildDate"); 163 115 BUILD_NUM = p.getProperty("buildNum"); 164 } catch (Exception e) 116 } 117 catch (Exception e) 165 118 { 166 119 System.out.println("Can't find the version.properties file"); … … 170 123 backend = new Backend(this); 171 124 new Preferences(backend, parser); 172 I18N.init();173 //Preferences.initMessages();174 125 JFrame.setDefaultLookAndFeelDecorated(Preferences.getBoolean("jeti","javadecorations",false)); 175 126 176 if(Preferences.getBoolean("jeti", "nativeLnF", false))177 {178 try179 {180 UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());181 } catch (ClassNotFoundException e)182 {183 e.printStackTrace();184 } catch (InstantiationException e)185 {186 e.printStackTrace();187 } catch (IllegalAccessException e)188 {189 e.printStackTrace();190 } catch (UnsupportedLookAndFeelException e)191 {192 e.printStackTrace();193 }194 }195 127 //parse plugins? make better or make comments 196 128 new StatusIcons(parser); -
trunk/jabberit_messenger/java_source/src/nu/fw/jeti/ui/Jeti.java
r1014 r1064 455 455 } 456 456 457 if(Preferences.getBoolean("jeti","jetimenuShowOptions",true))458 {459 menuItem = new JMenuItem(I18N.gettext("main.main.jetimenu.Options")+"...");460 I18N.setMnemonic("main.main.jetimenu.Options",menuItem);461 menuItem.addActionListener(new java.awt.event.ActionListener()462 {463 public void actionPerformed(ActionEvent e)464 {465 new OptionsWindow(backend).setVisible(true);466 }467 });468 addMenuItem(menuItem);469 }470 471 457 menuItem = new JMenuItem(); 472 458 I18N.setTextAndMnemonic("main.main.jetimenu.About",menuItem,true); -
trunk/jabberit_messenger/java_source/src/nu/fw/jeti/util/FindAction.java
r1014 r1064 45 45 46 46 public FindAction(){ 47 //super("find", EditorUtilities.loadIcon("icons/Find16.gif"));48 47 super(I18N.gettext("main.popup.Find")); 49 48 putValue(MNEMONIC_KEY, new Integer(KeyEvent.VK_F)); … … 60 59 JTextComponent text = (JTextComponent) o; 61 60 if(e.getModifiers() == 0 ) 62 {//find Next 61 { 62 //find Next 63 63 if (searchString==null) askSearchString(text); 64 64 if (searchString!=null)search(text,text.getCaretPosition()); … … 83 83 String fulltext = text.getText(); 84 84 85 // // strip out the surplus \r characters86 // StringTokenizer tokenizer = new StringTokenizer(fulltext, "\r");87 // StringBuffer buffer = new StringBuffer();88 // while( tokenizer.hasMoreTokens() ){89 // buffer.append( tokenizer.nextToken() );90 // }91 92 85 //get the substring based on the requested start position 93 86 fulltext = ( fulltext ).substring(startPositionIn); … … 96 89 // so long as we can find the text in the file, go ahead and highlight it 97 90 // if we can't show the dialog 98 if(fulltext.indexOf(searchString) > -1){ 91 if(fulltext.indexOf(searchString) > -1) 92 { 99 93 startPoint = (fulltext.indexOf(searchString) ) + startPositionIn; 100 101 94 endPoint = startPoint + searchStringLength; 102 95 text.requestFocus(); 103 96 text.setCaretPosition(startPoint); 104 //move caret to endPoint - thus highlighting the selected text105 97 text.moveCaretPosition(endPoint); 106 //make the selection visible107 //text.getCaret().setSelectionVisible(true);108 98 } 109 else if (startPositionIn!=0){ 99 else if (startPositionIn!=0) 100 { 110 101 if(JOptionPane.showConfirmDialog(text.getTopLevelAncestor(),MessageFormat.format(I18N.gettext("main.popup.{0}_not_found_until_the_end_of_this_file,_start_again_from_the_beginning?"),new Object[]{searchString})) == JOptionPane.OK_OPTION) 111 102 { -
trunk/jabberit_messenger/java_source/src/nu/fw/jeti/util/I18N.java
r1014 r1064 1 1 /* 2 * Creado el 30/06/2004 por Rodolfo Gonzalez Gonzalez <rodolfo@equinoxe.g-networks.net>2 * @Author(s) - Alexndre Correia 3 3 * 4 * This class is a wrapper for easier i18n of Jeti. It uses the standard i18n5 * mechanisms given by Java.4 * This class is a wrapper for easier i18n of Jeti. 5 * It uses the standard i18n mechanisms given by Java. 6 6 * 7 * Created on - 30/06/2009 7 8 */ 9 8 10 package nu.fw.jeti.util; 9 11 10 import java.io.*;11 import java.io.BufferedReader;12 import java.io.File;13 import java.io.IOException;14 import java.io.InputStreamReader;15 import java.net.MalformedURLException;16 import java.net.URL;17 12 import java.util.*; 18 13 19 14 import javax.swing.AbstractButton; 20 import javax.swing.JComponent;21 15 import javax.swing.JLabel; 22 import javax.swing.UIManager;16 import nu.fw.jeti.languages.*; 23 17 24 import nu.fw.jeti.backend.Start; 25 import nu.fw.jeti.backend.URLClassloader; 26 27 /** 28 * @author Rodolfo Gonzalez <rodolfo@equinoxe.g-networks.net> 29 */ 30 public class I18N 18 public class I18N implements languages, languagesPlugins 31 19 { 32 private static ResourceBundle jetiBundle; 33 private static Map pluginsBundle; 34 private Language[] languages; 35 private Map countries; 36 37 public I18N() 20 private static HashMap messagesLang; 21 private static HashMap messagesLangPlugins; 22 23 public static String getText(String type, String messageID) 38 24 { 39 countries = new HashMap(); 40 if ( Start.applet || Start.webstart ) 41 { 42 try 43 { 44 BufferedReader data = null; 45 InputStream is = getClass().getResourceAsStream("/languages/list.txt"); 46 if(is==null)return;//no languages 47 data =new BufferedReader(new InputStreamReader(is)); 48 //data =new BufferedReader(new InputStreamReader(new URL(Start.programURL + "languages/list.txt").openStream())); 49 List locales = new LinkedList(); 50 while (true) 51 { 52 String file = data.readLine(); 53 if (file ==null) break;//end of stream 54 locales.add(new Locale(file)); 55 } 56 data.close(); 57 extractLanguages(locales); 58 extractCountries(); 59 } 60 catch (IOException ex){ex.printStackTrace();} 61 } 62 else 63 { 64 extractLanguages(searchTranslations()); 65 extractCountries(); 66 } 67 } 68 69 private List searchTranslations() 70 { 71 String urlString = Start.path + "languages" + File.separator; 72 File path = new File(urlString); 73 File file[] = path.listFiles(); 74 List locales = new LinkedList(); 75 //locales.add(new Locale("en"));//english is available, but java always selects default locale before base locale 76 if (file == null) return locales; 77 for (int i = 0; i < file.length; i++) 78 { 79 Locale locale = getLocale(file[i].getName()); 80 if (locale != null) locales.add(locale); 81 } 82 return locales; 83 } 84 85 private Locale getLocale(String filename) 86 { 87 if (!filename.startsWith("jeti") || !filename.endsWith(".properties")) return null; 88 int nlen = "jeti".length(); 89 String language, country = ""; 90 switch (filename.length() - nlen - 11) 91 { 92 case 6: 93 // E.g. name+"_en_US"+".properties" 94 if (filename.charAt(3 + nlen) != '_') return null; 95 country = filename.substring(nlen + 4, nlen + 6); 96 // no break; here! 97 case 3: 98 if (filename.charAt(nlen) != '_') return null; 99 language = filename.substring(nlen + 1, nlen + 3); 100 Locale locale = new Locale(language, country); 101 return locale; 102 } 103 return null; 104 } 105 106 private void extractLanguages(List availableLocales) 107 { 108 Set lang = new HashSet(); 109 for (Iterator i = availableLocales.iterator(); i.hasNext();) 110 { 111 Locale l = (Locale) i.next(); 112 String language = l.getLanguage(); 113 List langLocs = (List) countries.get(language); 114 if (langLocs == null) 115 { 116 langLocs = new ArrayList(); 117 countries.put(language, langLocs); 118 } 119 langLocs.add(new Country(l)); 120 lang.add(new Language(l)); 121 } 122 //add default locale: 123 Locale l = Locale.getDefault(); 124 String language = l.getLanguage(); 125 List langLocs = (List) countries.get(language); 126 if (langLocs == null) 127 { 128 langLocs = new ArrayList(); 129 countries.put(language, langLocs); 130 } 131 lang.add(new Language(l)); 132 languages = (Language[]) lang.toArray(new Language[0]); 133 } 134 135 private void extractCountries() 136 { 137 Locale[] allLocales = Locale.getAvailableLocales(); 138 for (int i = 0; i < allLocales.length; i++) 139 { 140 String language = allLocales[i].getLanguage(); 141 for (int j = 0; j < languages.length; j++) 142 { 143 if (language.equals(languages[j].getLanguageCode())) 144 { 145 List langLocs = (List) countries.get(language); 146 Country country = new Country(allLocales[i]); 147 if (!langLocs.contains(country)) langLocs.add(country); 148 //System.out.println(allLocales[i].getDisplayCountry()); 149 } 150 } 151 } 152 } 153 154 /** 155 * @return The available languages 156 */ 157 public Language[] getLanguages() 158 { 159 return languages; 160 } 161 162 /** 163 * @return The countries that are possible with the available languages 164 */ 165 public Map getCountries() 166 { 167 return countries; 168 } 169 170 171 public static String getText(String type, String messageID) { 172 ResourceBundle bundle = (ResourceBundle)pluginsBundle.get(type); 173 if(bundle == null) bundle = jetiBundle; 174 return getText(bundle,messageID); 25 return getText(messageID); 175 26 } 176 27 177 /**178 * Gives back a translation of the input key without '&' (which is used for mnemonics)179 *180 * @param messageID is the English phrase used as key, following the GNU gettext style181 * @param bundle is the name of the base resource bundle file182 * @return result (or messageID in case of error)183 */184 28 public static String gettext(String messageID) 185 29 { 186 return getText( jetiBundle,messageID);30 return getText(messageID); 187 31 } 188 32 189 private static String getText( ResourceBundle bundle, String messageID)33 private static String getText( String messageID ) 190 34 { 191 if (messageID==null)return null; 192 String translation = getTextWithAmp(bundle,messageID); 35 if ( messageID == null ) 36 return null; 37 38 String translation = getTextWithAmp(messageID); 193 39 //remove & 194 40 int i = translation.indexOf("&"); … … 196 42 { 197 43 translation = translation.substring(0, i) + translation.substring(i + 1, translation.length()); 198 //i = translation.indexOf("&",i);199 44 } 45 200 46 return translation; 201 47 } 202 48 203 /**204 * Gives back a translation of the input key205 *206 * @param messageID is the English phrase used as key, following the GNU gettext style207 * @param bundle is the name of the base resource bundle file208 * @return result (or messageID in case of error)209 */210 49 public static String getTextWithAmp(String messageID) 211 { //TODO change back to private when string prep is implemented212 return getTextWithAmp(jetiBundle,messageID);50 { 51 return I18N.getText_WithAmp(messageID); 213 52 } 214 53 215 private static String getText WithAmp(ResourceBundle bundle, String messageID)54 private static String getText_WithAmp( String messageID ) 216 55 { 217 if (messageID==null)return null; 218 if(bundle!=null) 56 String translation = (String)messagesLang.get(messageID); 57 58 if( translation == null ) 219 59 { 220 try 221 { 222 return (String) bundle.getObject(messageID); 223 } catch (MissingResourceException e) 224 { 225 System.out.println(messageID + " is not translated"); 226 } 60 int dotPos = messageID.lastIndexOf('.'); 61 62 if ( dotPos > 0 ) 63 messageID = messageID.substring(dotPos+1); 64 65 return messageID.replace('_',' '); 227 66 } 228 int dotPos = messageID.lastIndexOf('.'); 229 if (dotPos>0) messageID = messageID.substring(dotPos+1); 230 //return messageID.replaceAll("_"," "); 231 return messageID.replace('_',' '); 67 68 return translation; 232 69 } 233 70 234 public static void setTextAndMnemonic(String messageID,JLabel label) { 71 public static void setTextAndMnemonic(String messageID,JLabel label) 72 { 235 73 setTextAndMnemonic(messageID, label, false); 236 74 } 237 75 238 public static void setTextAndMnemonic(String messageID, JLabel label, boolean addDots)76 public static void setTextAndMnemonic(String messageID, JLabel label, boolean addDots ) 239 77 { 240 String mnemonicText = getTextWithAmp(messageID);78 String mnemonicText = I18N.getTextWithAmp(messageID); 241 79 String translation=mnemonicText; 242 80 int pos = mnemonicText.indexOf("&"); 81 243 82 if (pos > -1) 244 {245 83 translation = mnemonicText.substring(0, pos) + mnemonicText.substring(pos + 1, mnemonicText.length()); 246 } 247 if (addDots) { 84 85 if (addDots) 248 86 translation += "..."; 249 } 87 250 88 label.setText(translation); 251 pos = getMnemonicPosition(mnemonicText); 252 if(pos>-1) label.setDisplayedMnemonic(mnemonicText.charAt(pos)); 253 if(pos>0) label.setDisplayedMnemonicIndex(pos-1); 89 pos = ( (int)mnemonicText.indexOf("&") >= 0 ) ? ((int)mnemonicText.indexOf("&")) + 1 : -1; 90 91 if ( pos > -1) 92 label.setDisplayedMnemonic(mnemonicText.charAt(pos)); 93 94 if ( pos > 0 ) 95 label.setDisplayedMnemonicIndex(pos-1); 254 96 } 255 97 256 98 public static void setMnemonic(String messageID, JLabel label) 257 99 { 258 String translation = getTextWithAmp(messageID); 259 int pos = getMnemonicPosition(translation); 260 if(pos>-1)label.setDisplayedMnemonic(translation.charAt(pos)); 261 if(pos>1)label.setDisplayedMnemonicIndex(pos-1); 100 String translation = I18N.getTextWithAmp(messageID); 101 int pos = ( (int)translation.indexOf("&") >= 0 ) ? ((int)translation.indexOf("&")) + 1 : -1; 102 103 if ( pos > -1) 104 label.setDisplayedMnemonic(translation.charAt(pos)); 105 106 if ( pos > 1) 107 label.setDisplayedMnemonicIndex(pos-1); 262 108 } 263 109 264 110 public static void setMnemonic(String messageID, AbstractButton button) 265 111 { 266 String translation = getTextWithAmp(messageID); 267 int pos = getMnemonicPosition(translation); 268 if(pos>-1)button.setMnemonic(translation.charAt(pos)); 269 if(pos>1)button.setDisplayedMnemonicIndex(pos-1); 112 String translation = I18N.getTextWithAmp(messageID); 113 int pos = ( (int)translation.indexOf("&") >= 0 ) ? ((int)translation.indexOf("&")) + 1 : -1; 114 115 if ( pos >- 1) 116 button.setMnemonic(translation.charAt(pos)); 117 if ( pos > 1) 118 button.setDisplayedMnemonicIndex(pos-1); 270 119 } 271 120 272 /**273 * @param messageID is the English phrase used as key, following the274 * GNU gettext style275 * @param bundle is the name of the base resource bundle file276 * @param button The button to set the mnemonic on277 */278 121 public static void setTextAndMnemonic(String messageID,AbstractButton button) 279 122 { … … 281 124 } 282 125 283 /** 284 * @param messageID is the English phrase used as key, following the 285 * GNU gettext style 286 * @param bundle is the name of the base resource bundle file 287 * @param button The button to set the mnemonic on 288 * @param addDots If true add '...' to the translated text 289 */ 290 public static void setTextAndMnemonic(String messageID,AbstractButton button, 291 boolean addDots) 126 public static void setTextAndMnemonic(String messageID,AbstractButton button, boolean addDots) 292 127 { 293 128 String mnemonicText = getTextWithAmp(messageID); 129 String translation=mnemonicText; 294 130 295 String translation=mnemonicText;296 131 int pos = mnemonicText.indexOf("&"); 132 297 133 if (pos > -1) 298 {299 134 translation = mnemonicText.substring(0, pos) + mnemonicText.substring(pos + 1, mnemonicText.length()); 300 } 301 if (addDots) { 135 136 if (addDots) 302 137 translation += "..."; 303 } 304 button.setText(translation); 305 pos = getMnemonicPosition(mnemonicText); 306 if(pos>-1)button.setMnemonic(mnemonicText.charAt(pos)); 307 if(pos>0) button.setDisplayedMnemonicIndex(pos-1); 138 139 button.setText(translation); 140 141 pos = ( (int)mnemonicText.indexOf("&") >= 0 ) ? ((int)mnemonicText.indexOf("&")) + 1 : -1; 142 143 if( pos > -1) 144 button.setMnemonic(mnemonicText.charAt(pos)); 145 146 if( pos > 0 ) 147 button.setDisplayedMnemonicIndex(pos-1); 308 148 309 149 } 310 150 311 private static int getMnemonicPosition(String translation)151 private static void loadLanguages(Locale myLocale) 312 152 { 313 int index = translation.indexOf("&"); 314 if (index >= 0) return index+1; 315 return -1; 153 if ( myLocale.toString().equals("pt_BR")) 154 { 155 for( int i = 0; i < language_pt_BR.length; i++ ) 156 messagesLang.put(language_pt_BR[i][0].toString(), language_pt_BR[i][1].toString()); 157 158 for( int i = 0 ; i < languagePlugins_pt_BR.length; i++) 159 messagesLangPlugins.put(languagePlugins_pt_BR[i][0].toString(), languagePlugins_pt_BR[i][1].toString()); 160 } 316 161 } 162 163 public static void init(String myLanguage, String myCountry) 164 { 165 messagesLang = new HashMap(); 166 messagesLangPlugins = new HashMap(); 317 167 318 static public void init() 319 { 320 ClassLoader classLoader=null; 321 if (!Start.applet && !Start.webstart) { 322 try { 323 URL url = new URL(Start.programURL, "languages/"); 324 classLoader = new URLClassloader( 325 new URL[] { url}, I18N.class.getClassLoader()); 326 } catch (MalformedURLException e) { 327 e.printStackTrace(); 328 } 329 } else classLoader = I18N.class.getClassLoader(); 330 // see if the user has some preferences 331 String myLanguage = Preferences.getString("jeti", "language", ""); 332 String myCountry = Preferences.getString("jeti", "country", ""); 333 Locale myLocale=null; 334 if (myLanguage != "") { 335 myLocale = new Locale(myLanguage, myCountry); 336 } else { 337 myLocale = Locale.getDefault(); 338 } 339 jetiBundle = loadLanguage("jeti",classLoader,myLocale); 340 if(jetiBundle==null || jetiBundle.getLocale().getLanguage().equals("")) 341 { 342 // Make it fall back to English, this way we always get at least 343 // the english texts (which contains the menu mnemonic markings) 344 myLocale= new Locale(Locale.ENGLISH.getLanguage(),myCountry); 345 System.out.println("lang not found, default: " + myLocale); 346 jetiBundle = loadLanguage("jeti",classLoader,myLocale); 347 } 348 pluginsBundle = new HashMap(); 349 pluginsBundle.put("drawing",loadLanguage("drawing",classLoader,myLocale)); 350 JComponent.setDefaultLocale(myLocale); 351 352 //loadLanguage(classLoader, myLocale); 353 UIManager.put("OptionPane.okButtonText", gettext("OK")); 354 UIManager.put("OptionPane.cancelButtonText", gettext("Cancel")); 168 // Preferences 169 Locale myLocale = null; 170 171 if( myLanguage != "" ) 172 myLocale = new Locale(myLanguage, myCountry); 173 else 174 myLocale = new Locale("en", "US"); 175 176 System.out.println("Valor de myLocale : " + myLocale); 355 177 356 } 357 358 private static ResourceBundle loadLanguage(String type, ClassLoader classLoader, Locale myLocale) 359 { 360 try { 361 return ResourceBundle.getBundle("languages/" +type, myLocale); 362 } catch (MissingResourceException e) { 363 try { 364 return ResourceBundle.getBundle(type, 365 myLocale, classLoader); 366 } catch (MissingResourceException e2) { 367 System.out.println(e2.getMessage()); 368 return null; 369 } 370 } 371 } 372 373 public static class Country 374 { 375 private String country; 376 private String countryCode; 377 378 public Country(Locale locale) 379 { 380 country = locale.getDisplayCountry(); 381 if (country.equals("")) country = gettext("main.options.standard.Other"); 382 countryCode = locale.getCountry(); 383 } 384 385 public String getCountryCode() 386 { 387 return countryCode; 388 } 389 390 public String toString() 391 { 392 return country; 393 } 394 395 } 396 397 public static class Language 398 { 399 private String language; 400 private String languageCode; 401 402 public Language(Locale locale) 403 { 404 language = locale.getDisplayLanguage(); 405 languageCode = locale.getLanguage(); 406 } 407 408 public String getLanguageCode() 409 { 410 return languageCode; 411 } 412 413 public String toString() 414 { 415 return language; 416 } 417 418 public boolean equals(Object obj) 419 { 420 return language.equals(((Language)obj).language); 421 } 422 423 public int hashCode() 424 { 425 return language.hashCode(); 426 } 427 428 178 I18N.loadLanguages(myLocale); 429 179 } 430 180 } 431 432 181 433 182 /* -
trunk/jabberit_messenger/java_source/src/nu/fw/jeti/util/Preferences.java
r1014 r1064 65 65 { 66 66 Preferences.backend = backend; 67 68 67 InputStream data = null; 69 68 … … 77 76 addPreferences(parser, data, defaults); 78 77 } 79 catch(IOException ex) 80 { 81 // Do Nothing 82 //javax.swing.JOptionPane.showMessageDialog(null, 83 // "Comentar esta linha em Preferences.java\n" + "\nERRO : \n" + ex.getMessage() + "\n" + ex + "\n" ); 84 } 78 catch(IOException ex){} 85 79 86 80 // Initialize presence messages if none have been specified … … 91 85 } 92 86 93 private void addPreferences(SAXParser parser, InputStream data,Map store) { 94 try { 87 private void addPreferences(SAXParser parser, InputStream data,Map store) 88 { 89 try 90 { 95 91 parser.parse(data,new PreferencesHandler(store)); 96 } catch (SAXException ex) { 92 } 93 catch (SAXException ex) 94 { 97 95 ex.printStackTrace(); 98 } catch (IOException ex) { 96 } 97 catch (IOException ex) 98 { 99 99 ex.printStackTrace(); 100 100 } … … 109 109 110 110 List tempList = new ArrayList(10); 111 tempList.add("DisponÃvel"); 112 tempList.add("Livre p/ Chat"); 113 mapMessages.put("chat", tempList); 114 mapMessages.put("available", tempList); 115 tempList = new ArrayList(10); 116 tempList.add("Em reunião"); 117 tempList.add("Ocupado"); 118 tempList.add("Trabalhando"); 119 mapMessages.put("dnd", tempList); 120 tempList = new ArrayList(10); 121 tempList.add("No telefone"); 122 tempList.add("Volto Logo"); 123 mapMessages.put("away", tempList); 124 tempList = new ArrayList(10); 125 tempList.add("Férias"); 126 tempList.add("Em casa"); 127 tempList.add("Ausente"); 128 mapMessages.put("xa", tempList); 111 tempList.add("Disponível"); 112 tempList.add("Livre p/ Chat"); 113 mapMessages.put("chat", tempList); 114 mapMessages.put("available", tempList); 115 tempList = new ArrayList(10); 116 tempList.add("Em reunião"); 117 tempList.add("Ocupado"); 118 tempList.add("Trabalhando"); 119 mapMessages.put("dnd", tempList); 120 tempList = new ArrayList(10); 121 tempList.add("No telefone"); 122 tempList.add("Volto Logo"); 123 mapMessages.put("away", tempList); 124 tempList = new ArrayList(10); 125 tempList.add("Férias"); 126 tempList.add("Em casa"); 127 tempList.add("Ausente"); 128 mapMessages.put("xa", tempList); 129 129 130 return mapMessages; 130 131 }
Note: See TracChangeset
for help on using the changeset viewer.