diff --git a/languagetool-core/src/main/resources/org/languagetool/MessagesBundle.properties b/languagetool-core/src/main/resources/org/languagetool/MessagesBundle.properties index 3714156d719d..01467a06bee7 100644 --- a/languagetool-core/src/main/resources/org/languagetool/MessagesBundle.properties +++ b/languagetool-core/src/main/resources/org/languagetool/MessagesBundle.properties @@ -451,6 +451,6 @@ ShowDisambiguatorLog = Show disambiguator log guiMenuRecentFiles = &Recent Files guiFileNotFound = File Not Found dialogTitleError = Error -guiLanguage = GUI Language: +guiLanguage = GUI Language quiLanguageNeedsRestart = Restart application for the language change to take effect. guiLanguageSystem = System Default \ No newline at end of file diff --git a/languagetool-standalone/src/main/java/org/languagetool/gui/GuiLangConfigPanel.java b/languagetool-standalone/src/main/java/org/languagetool/gui/GuiLangConfigPanel.java index a08a5c4a7021..2261776d754e 100644 --- a/languagetool-standalone/src/main/java/org/languagetool/gui/GuiLangConfigPanel.java +++ b/languagetool-standalone/src/main/java/org/languagetool/gui/GuiLangConfigPanel.java @@ -27,6 +27,7 @@ import java.awt.event.ItemListener; import java.util.Locale; import java.util.ResourceBundle; +import javax.swing.BorderFactory; import javax.swing.JLabel; import javax.swing.JPanel; import org.languagetool.Languages; @@ -40,14 +41,19 @@ class GuiLangConfigPanel extends JPanel implements SavablePanel, ItemListener { private final LocalStorage storage; + private final ResourceBundle messages; private final LanguageComboBox languageBox; private final LanguageAdapter system; + private final JLabel needsRestartLabel = new JLabel(""); + private boolean needsRestart = false; private LanguageAdapter guiLang = null; GuiLangConfigPanel(ResourceBundle messages, LocalStorage storage) { super(new GridBagLayout()); applyComponentOrientation( ComponentOrientation.getOrientation(Locale.getDefault())); + setBorder(BorderFactory.createTitledBorder(messages.getString("guiLanguage"))); + this.messages = messages; this.storage = storage; system = new LanguageAdapter(messages.getString("guiLanguageSystem")); //create a ComboBox with flags, do not include hidden languages, @@ -55,28 +61,23 @@ class GuiLangConfigPanel extends JPanel implements SavablePanel, ItemListener { languageBox = LanguageComboBox.create(messages, "", true, false, system); GridBagConstraints c = new GridBagConstraints(); - c.insets = new Insets(2, 4, 2, 0); + c.insets = new Insets(2, 2, 2, 2); c.gridx = 0; c.gridy = 0; - add(new JLabel(messages.getString("guiLanguage")), c); - c.insets = new Insets(2, 4, 2, 0); - c.gridx = 1; + c.weightx = 1; + c.anchor = GridBagConstraints.LINE_START; add(languageBox, c); - c.insets = new Insets(2, 4, 2, 0); - c.gridx = 0; c.gridy = 1; - c.gridwidth = 2; - c.fill = GridBagConstraints.HORIZONTAL; - JLabel warn = new JLabel("" + messages.getString("quiLanguageNeedsRestart")); - warn.setForeground(Color.red); - add(warn, c); + add(needsRestartLabel, c); } @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { guiLang = (LanguageAdapter) e.getItem(); + needsRestartLabel.setText(messages.getString("quiLanguageNeedsRestart")); + needsRestartLabel.setForeground(Color.red); } } @@ -92,6 +93,7 @@ public void save() { if (guiLang == null) { return; } + needsRestart = true; if (guiLang.getLanguage() != null) { storage.saveProperty("gui.locale", new LocaleBean( guiLang.getLanguage().getLocaleWithCountryAndVariant())); @@ -101,6 +103,10 @@ public void save() { } private void loadOption() { + guiLang = null; + if (!needsRestart) { + needsRestartLabel.setText(""); + } LocaleBean lang = storage.loadProperty("gui.locale", LocaleBean.class); if (lang != null) { Locale l = lang.asLocale();