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 |
/** |
/** |
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 |
/** |
/** |