/[schmitzm]/trunk/src/skrueger/i8n/Translation.java
ViewVC logotype

Diff of /trunk/src/skrueger/i8n/Translation.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 34 by alfonx, Sat Mar 28 18:08:42 2009 UTC revision 38 by alfonx, Sun Apr 5 15:06:56 2009 UTC
# Line 51  public class Translation extends HashMap Line 51  public class Translation extends HashMap
51          }          }
52    
53          /**          /**
54           * Set up the {@link Translation}-system to use language.           * Set up the {@link Translation}-system to use language. If a change is performed, events are fired to listeners. Nothing is done if the new language equals the old language.
55           * @param activeLang           *
56             * @param newLang The ISO Code of the new active language
57           */           */
58          public static void setActiveLang(String activeLang) {          public static void setActiveLang(String newLang) {
59                  if (!I8NUtil.isValidISOLangCode(activeLang)) {                  if (getActiveLang().equals(newLang)) {
60                          throw new IllegalArgumentException("'"+activeLang+"' is not a valid ISO language code.");                          return;
61                    }
62                    
63                    if (!I8NUtil.isValidISOLangCode(newLang)) {
64                            throw new IllegalArgumentException("'"+newLang+"' is not a valid ISO language code.");
65                  }                  }
66    
67                  Locale newLocale = new Locale(activeLang);                  Locale newLocale = new Locale(newLang);
68                  Locale.setDefault(newLocale);                  Locale.setDefault(newLocale);
69                                    
70                  /**                  /**
# Line 68  public class Translation extends HashMap Line 73  public class Translation extends HashMap
73                   */                   */
74                  JComponent.setDefaultLocale(newLocale);                  JComponent.setDefaultLocale(newLocale);
75                                    
76                  Translation.activeLang = activeLang;                  Translation.activeLang = newLang;
77                                    
78                  fireChangeEvents();                  fireChangeEvents();
79                                    
80                  log.info("skrueger.i8n.Translation switched ActiveLang to "+activeLang);                  log.info("skrueger.i8n.Translation switched ActiveLang to "+newLang);
81          }          }
82    
83          /**          /**
# Line 103  public class Translation extends HashMap Line 108  public class Translation extends HashMap
108                          put(DEFAULT_KEY, defaultTranslation);                          put(DEFAULT_KEY, defaultTranslation);
109                  }                  }
110                  else for (String code : languages){                  else for (String code : languages){
111                          put(code, defaultTranslation);                          if (code.equals(getActiveLang())) {
112                                    put(code, defaultTranslation);
113                            }
114                  }                  }
115          }          }
116    

Legend:
Removed from v.34  
changed lines
  Added in v.38

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26