39 |
import java.util.List; |
import java.util.List; |
40 |
import java.util.Locale; |
import java.util.Locale; |
41 |
import java.util.Random; |
import java.util.Random; |
42 |
|
import java.util.WeakHashMap; |
43 |
|
|
44 |
import javax.swing.JComponent; |
import javax.swing.JComponent; |
45 |
|
|
65 |
static final Logger LOGGER = Logger.getLogger(Translation.class); |
static final Logger LOGGER = Logger.getLogger(Translation.class); |
66 |
static String activeLang = Locale.getDefault().getLanguage(); |
static String activeLang = Locale.getDefault().getLanguage(); |
67 |
|
|
68 |
static protected List<PropertyChangeListener> listeners = new ArrayList<PropertyChangeListener>(); |
static protected WeakHashSet<PropertyChangeListener> listeners = new WeakHashSet<PropertyChangeListener>( |
69 |
|
PropertyChangeListener.class); |
70 |
|
|
71 |
static { |
static { |
72 |
|
|
145 |
|
|
146 |
fireLocaleChangeEvents(); |
fireLocaleChangeEvents(); |
147 |
|
|
148 |
LOGGER.info("skrueger.i8n.Translation switched ActiveLang to " + newLang); |
LOGGER.info("skrueger.i8n.Translation switched ActiveLang to " |
149 |
|
+ newLang); |
150 |
} |
} |
151 |
|
|
152 |
/** |
/** |
287 |
|
|
288 |
/** |
/** |
289 |
* {@link PropertyChangeListener} can be registered to be informed when the |
* {@link PropertyChangeListener} can be registered to be informed when the |
290 |
* {@link Locale} changed. |
* {@link Locale} changed.<br> |
291 |
|
* The listeners are kept in a {@link WeakHashMap}, so you have to keep a |
292 |
|
* reference to the listener or it will be removed! |
293 |
* |
* |
294 |
* @param propertyChangeListener |
* @param propertyChangeListener |
295 |
|
* A {@link PropertyChangeListener} that will be called when |
296 |
|
* {@link #setActiveLang(String)} changes the language. |
297 |
*/ |
*/ |
298 |
public static void addLocaleChangeListener( |
public static void addLocaleChangeListener( |
299 |
PropertyChangeListener propertyChangeListener) { |
PropertyChangeListener propertyChangeListener) { |
320 |
*/ |
*/ |
321 |
public void addTranslationChangeListener(ActionListener actionListener) { |
public void addTranslationChangeListener(ActionListener actionListener) { |
322 |
if (actionListeners.add(actionListener)) { |
if (actionListeners.add(actionListener)) { |
323 |
LOGGER.debug("registering a new translationChangeActionListener in the WeakHashSet"); |
LOGGER |
324 |
|
.debug("registering a new translationChangeActionListener in the WeakHashSet"); |
325 |
} |
} |
326 |
} |
} |
327 |
|
|