mirror of
https://github.com/igniterealtime/Spark.git
synced 2025-10-29 03:34:43 +00:00
LanguagePlugin: inline fields to avoid long living garbage
This commit is contained in:
parent
8856e6dd3b
commit
4499d1eaf2
@ -33,18 +33,15 @@ import java.util.Locale;
|
|||||||
*/
|
*/
|
||||||
public class LanguagePlugin implements Plugin {
|
public class LanguagePlugin implements Plugin {
|
||||||
|
|
||||||
private Locale[] locales;
|
|
||||||
private JMenu languageMenu;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
// Register with action menu
|
// Register with action menu
|
||||||
final JMenu actionsMenu = SparkManager.getMainWindow().getMenuByName(Res.getString("menuitem.actions"));
|
final JMenu actionsMenu = SparkManager.getMainWindow().getMenuByName(Res.getString("menuitem.actions"));
|
||||||
|
|
||||||
languageMenu = new JMenu(Res.getString("menuitem.languages"));
|
JMenu languageMenu = new JMenu(Res.getString("menuitem.languages"));
|
||||||
languageMenu.setIcon(SparkRes.getImageIcon("LANGUAGE_ICON"));
|
languageMenu.setIcon(SparkRes.getImageIcon("LANGUAGE_ICON"));
|
||||||
|
|
||||||
locales = Locale.getAvailableLocales();
|
Locale[] locales = Locale.getAvailableLocales();
|
||||||
|
|
||||||
// Load files
|
// Load files
|
||||||
for (final Locale locale : locales) {
|
for (final Locale locale : locales) {
|
||||||
@ -57,14 +54,14 @@ public class LanguagePlugin implements Plugin {
|
|||||||
|
|
||||||
// If we can find an translation file for this locale, we can support the language!
|
// If we can find an translation file for this locale, we can support the language!
|
||||||
if (getClass().getResource( targetI18nFileName ) != null) {
|
if (getClass().getResource( targetI18nFileName ) != null) {
|
||||||
addLanguage(locale);
|
addLanguage(locale, languageMenu);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
actionsMenu.add(languageMenu);
|
actionsMenu.add(languageMenu);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addLanguage(Locale locale) {
|
private void addLanguage(Locale locale, JMenu languageMenu) {
|
||||||
Action action = new AbstractAction() {
|
Action action = new AbstractAction() {
|
||||||
private static final long serialVersionUID = -7093236616888591766L;
|
private static final long serialVersionUID = -7093236616888591766L;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user