Chore/42 translate multiple client components to english #225

Merged
jona.walpert merged 2 commits from chore/42-translate-multiple-client-components-to-english into main 2026-04-01 14:26:51 +02:00
5 changed files with 62 additions and 50 deletions
Showing only changes of commit 56ba5b81ae - Show all commits
@@ -8,17 +8,19 @@ import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
/** /**
* Entry point for the Casono client application. Handles client startup and connection parameters. * Entry point for the Casono client application. Handles client startup and
* connection parameters.
* *
* <p>Standardkonstruktor für die Anwendung. * <p>
* Default constructor for the application.
*/ */
public class ClientApp { public class ClientApp {
private static final Logger LOGGER = LogManager.getLogger(ClientApp.class); private static final Logger LOGGER = LogManager.getLogger(ClientApp.class);
/** Standardkonstruktor. */ /** Default constructor. */
public ClientApp() { public ClientApp() {
// Standardkonstruktor // Default constructor
} }
/** /**
@@ -6,13 +6,14 @@ import javafx.application.Application;
/** /**
* Launcher for the Casono main UI. * Launcher for the Casono main UI.
* *
* <p>Standardkonstruktor für die Anwendung. * <p>
* Default constructor for the application.
*/ */
public class Launcher { public class Launcher {
/** Standardkonstruktor. */ /** Default constructor. */
public Launcher() { public Launcher() {
// Standardkonstruktor // Default constructor
} }
/** /**
@@ -10,13 +10,14 @@ import javafx.stage.Stage;
/** /**
* JavaFX Application class for the Casono main UI. * JavaFX Application class for the Casono main UI.
* *
* <p>Standardkonstruktor für die Anwendung. * <p>
* Default constructor for the application.
*/ */
public class Casinomainui extends Application { public class Casinomainui extends Application {
/** Standardkonstruktor. */ /** Default constructor. */
public Casinomainui() { public Casinomainui() {
// Standardkonstruktor // Default constructor
} }
private static final int SCENE_WIDTH = 1200; private static final int SCENE_WIDTH = 1200;
@@ -30,12 +31,10 @@ public class Casinomainui extends Application {
* @throws IOException If loading the FXML fails. * @throws IOException If loading the FXML fails.
*/ */
public void start(Stage stage) throws IOException { public void start(Stage stage) throws IOException {
FXMLLoader fxmlLoader = FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/ui-structure/Casinomainui.fxml"));
new FXMLLoader(getClass().getResource("/ui-structure/Casinomainui.fxml"));
Scene scene = new Scene(fxmlLoader.load(), SCENE_WIDTH, SCENE_HEIGHT); Scene scene = new Scene(fxmlLoader.load(), SCENE_WIDTH, SCENE_HEIGHT);
stage.setTitle("Casono"); stage.setTitle("Casono");
javafx.scene.image.Image icon = javafx.scene.image.Image icon = new javafx.scene.image.Image(
new javafx.scene.image.Image(
getClass().getResource("/images/logoinverted.png").toExternalForm()); getClass().getResource("/images/logoinverted.png").toExternalForm());
stage.getIcons().add(icon); stage.getIcons().add(icon);
stage.setScene(scene); stage.setScene(scene);
@@ -12,17 +12,27 @@ import javafx.scene.shape.Rectangle;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
/** Controller for the Casono main UI lobby. Handles UI initialization and user actions. */ /**
* Controller for the Casono main UI lobby. Handles UI initialization and user
* actions.
*/
public class CasinomainuiController { public class CasinomainuiController {
private static final Logger LOGGER = LogManager.getLogger(CasinomainuiController.class); private static final Logger LOGGER = LogManager.getLogger(CasinomainuiController.class);
@FXML private AnchorPane rootPane; @FXML
@FXML private Label titleLabel; private AnchorPane rootPane;
@FXML private Label subtitleLabel; @FXML
@FXML private ImageView logoView; private Label titleLabel;
@FXML private Rectangle greenBox; @FXML
@FXML private Button exitbutton; private Label subtitleLabel;
@FXML private VBox casinoTable; @FXML
private ImageView logoView;
@FXML
private Rectangle greenBox;
@FXML
private Button exitbutton;
@FXML
private VBox casinoTable;
private LobbyButtonTranslationManager translationManager; private LobbyButtonTranslationManager translationManager;
private LobbyButtonGridManager gridManager; private LobbyButtonGridManager gridManager;
@@ -41,8 +51,7 @@ public class CasinomainuiController {
logoView.setImage(new Image(getClass().getResource("/images/logo.png").toExternalForm())); logoView.setImage(new Image(getClass().getResource("/images/logo.png").toExternalForm()));
translationManager = LobbyButtonTranslationManager.getInstance(); translationManager = LobbyButtonTranslationManager.getInstance();
gridManager = gridManager = new LobbyButtonGridManager(new javafx.scene.layout.GridPane(), translationManager);
new LobbyButtonGridManager(new javafx.scene.layout.GridPane(), translationManager);
casinoTable.getChildren().clear(); casinoTable.getChildren().clear();
casinoTable.getChildren().add(gridManager.getGridPane()); casinoTable.getChildren().add(gridManager.getGridPane());
gridManager.renderLobbyButtons(); gridManager.renderLobbyButtons();
@@ -58,7 +67,7 @@ public class CasinomainuiController {
@FXML @FXML
public void handleCreateLobbyButton() { public void handleCreateLobbyButton() {
if (translationManager.isFull()) { if (translationManager.isFull()) {
LOGGER.warn("Grid voll! Keine weiteren Lobbys moeglich."); LOGGER.warn("Grid is full! No more lobbies available.");
return; return;
} }
int buttonId = nextButtonId++; int buttonId = nextButtonId++;
@@ -68,7 +77,7 @@ public class CasinomainuiController {
LOGGER.info("ButtonID: {}, LobbyID: {}", buttonId, lobbyId); LOGGER.info("ButtonID: {}, LobbyID: {}", buttonId, lobbyId);
gridManager.renderLobbyButtons(); gridManager.renderLobbyButtons();
} catch (Exception e) { } catch (Exception e) {
LOGGER.error("Fehler beim Hinzufügen: {}", e.getMessage()); LOGGER.error("Error while adding lobby button: {}", e.getMessage());
} }
} }
} }
@@ -4,19 +4,20 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
/** /**
* Verwaltet das Mapping zwischen Button-IDs und Lobby-IDs rein im Speicher. Keine Dateioperationen, * Manages the mapping between Button IDs and Lobby IDs in memory only. No file
* nur Laufzeitdatenstruktur. * operations,
* runtime-only data structure.
*/ */
public class LobbyButtonTranslationManager { public class LobbyButtonTranslationManager {
// Singleton-Instanz // Singleton instance
private static LobbyButtonTranslationManager instance; private static LobbyButtonTranslationManager instance;
// Singleton-Zugriff // Singleton access
/** /**
* Liefert die Singleton-Instanz des Managers. * Returns the singleton instance of the manager.
* *
* @return die einzige Instanz von {@code LobbyButtonTranslationManager} * @return the single instance of {@code LobbyButtonTranslationManager}
*/ */
public static LobbyButtonTranslationManager getInstance() { public static LobbyButtonTranslationManager getInstance() {
if (instance == null) { if (instance == null) {
@@ -25,32 +26,32 @@ public class LobbyButtonTranslationManager {
return instance; return instance;
} }
/** Maximale Anzahl an Buttons/Lobbys */ /** Maximum number of buttons/lobbies */
private static final int MAX_BUTTONS = 8; private static final int MAX_BUTTONS = 8;
/** Zuordnung ButtonID → LobbyID */ /** Mapping ButtonID → LobbyID */
private final Map<Integer, Integer> buttonIdToLobbyId = new HashMap<>(); private final Map<Integer, Integer> buttonIdToLobbyId = new HashMap<>();
/** Privater Konstruktor für Singleton-Pattern */ /** Private constructor for the singleton pattern */
private LobbyButtonTranslationManager() { private LobbyButtonTranslationManager() {
// Zuordnung bleibt leer beim Start // Mapping is empty at startup
} }
/** /**
* Prüft, ob das Grid voll ist (MAX_BUTTONS erreicht). * Checks whether the grid is full (MAX_BUTTONS reached).
* *
* @return true, wenn Grid voll; sonst false * @return true if the grid is full; otherwise false
*/ */
public boolean isFull() { public boolean isFull() {
return buttonIdToLobbyId.size() >= MAX_BUTTONS; return buttonIdToLobbyId.size() >= MAX_BUTTONS;
} }
/** /**
* Fügt eine Zuordnung ButtonID → LobbyID hinzu. * Adds a mapping ButtonID → LobbyID.
* *
* @param buttonId Die ID des Buttons * @param buttonId the ID of the button
* @param lobbyId Die ID der Lobby * @param lobbyId the ID of the lobby
* @throws Exception wenn das Grid voll ist * @throws Exception when the grid is full
*/ */
public void addLobbyButton(int buttonId, int lobbyId) throws Exception { public void addLobbyButton(int buttonId, int lobbyId) throws Exception {
if (isFull()) { if (isFull()) {
@@ -60,28 +61,28 @@ public class LobbyButtonTranslationManager {
} }
/** /**
* Entfernt eine Zuordnung für die gegebene ButtonID. * Removes the mapping for the given ButtonID.
* *
* @param buttonId Die ID des zu entfernenden Buttons * @param buttonId the ID of the button to remove
*/ */
public void removeLobbyButton(int buttonId) { public void removeLobbyButton(int buttonId) {
buttonIdToLobbyId.remove(buttonId); buttonIdToLobbyId.remove(buttonId);
} }
/** /**
* Gibt die LobbyID für eine gegebene ButtonID zurück. * Returns the LobbyID for a given ButtonID.
* *
* @param buttonId Die ButtonID * @param buttonId the ButtonID
* @return Die zugehoerige LobbyID oder null, falls nicht vorhanden * @return the associated LobbyID or null if not present
*/ */
public Integer getLobbyIdForButton(int buttonId) { public Integer getLobbyIdForButton(int buttonId) {
return buttonIdToLobbyId.get(buttonId); return buttonIdToLobbyId.get(buttonId);
} }
/** /**
* Gibt die gesamte Zuordnung ButtonID → LobbyID zurück. * Returns the full mapping ButtonID → LobbyID.
* *
* @return Map aller Zuordnungen * @return Map of all mappings
*/ */
public Map<Integer, Integer> getButtonIdToLobbyId() { public Map<Integer, Integer> getButtonIdToLobbyId() {
return buttonIdToLobbyId; return buttonIdToLobbyId;