overengineered locale switch

This commit is contained in:
Oskar Rasieński 2025-12-04 14:36:00 +01:00
commit c0be17e0b0
2 changed files with 8 additions and 15 deletions

View file

@ -12,6 +12,7 @@ import client.utils.ServerUtils;
import commons.Recipe; import commons.Recipe;
import jakarta.inject.Inject; import jakarta.inject.Inject;
import javafx.event.ActionEvent;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.scene.control.Button; import javafx.scene.control.Button;
import javafx.scene.control.Label; import javafx.scene.control.Label;
@ -234,18 +235,10 @@ public class FoodpalApplicationCtrl implements LocaleAware {
// Language buttons // Language buttons
@FXML @FXML
private void switchToEnglish() { private void switchLocale(ActionEvent event) {
localeManager.setLocale(Locale.of("en")); Button button = (Button)event.getSource();
} String lang = (String)button.getUserData();
localeManager.setLocale(Locale.of(lang));
@FXML
private void switchToDutch() {
localeManager.setLocale(Locale.of("nl"));
}
@FXML
private void switchToPolish() {
localeManager.setLocale(Locale.of("pl"));
} }
@FXML @FXML

View file

@ -44,9 +44,9 @@
<buttons> <buttons>
<ToolBar prefHeight="35.0" prefWidth="123.0"> <ToolBar prefHeight="35.0" prefWidth="123.0">
<items> <items>
<Button fx:id="flagEnButton" minWidth="33.0" onAction="#switchToEnglish" prefHeight="25.0" prefWidth="33.0" text="EN" /> <Button fx:id="flagEnButton" minWidth="33.0" onAction="#switchLocale" userData="en" prefHeight="25.0" prefWidth="33.0" text="EN" />
<Button fx:id="flagNlButton" onAction="#switchToDutch" text="NL" /> <Button fx:id="flagNlButton" onAction="#switchLocale" userData="nl" text="NL" />
<Button fx:id="flagPlButton" onAction="#switchToPolish" text="PL" /> <Button fx:id="flagPlButton" onAction="#switchLocale" userData="pl" text="PL" />
</items> </items>
</ToolBar> </ToolBar>
</buttons> </buttons>