Skip to content

Commit

Permalink
add multi-language support
Browse files Browse the repository at this point in the history
  • Loading branch information
DerCodeDev committed May 29, 2023
1 parent 7fb387c commit 9032715
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 3 deletions.
11 changes: 10 additions & 1 deletion src/main/java/dev/samir/vmdconverter/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,26 @@
import javafx.stage.Stage;

import java.io.IOException;
import java.util.Locale;

/**
* JavaFX App
*/
public class App extends Application {

private final Locale locale = Locale.getDefault();
private static Scene scene;

@Override
public void start(Stage stage) throws IOException {
scene = new Scene(loadFXML("vmdconverter"));


if (locale.getDisplayLanguage().equals("Deutsch")){
scene = new Scene(loadFXML("german"));

}else {
scene = new Scene(loadFXML("englisch"));
}
stage.setResizable(false);
stage.setTitle("VMD Converter");
stage.setScene(scene);
Expand Down
21 changes: 20 additions & 1 deletion src/main/java/dev/samir/vmdconverter/AppController.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package dev.samir.vmdconverter;

import dev.samir.vmdconverter.utils.ConsoleOutput;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.concurrent.Task;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
Expand All @@ -10,6 +12,7 @@
import dev.samir.vmdconverter.converter.VMDConverter;

import java.io.File;
import java.io.IOException;
import java.io.PrintStream;


Expand All @@ -31,6 +34,9 @@ public class AppController {

@FXML
private TextArea consoleLog;
@FXML
private ComboBox<String> comboBox;
private final ObservableList<String> languagesList = FXCollections.observableArrayList("Deutsch (German)", "Englisch (US)");


@FXML
Expand Down Expand Up @@ -60,10 +66,23 @@ public void outputFieldBrowseButton(final ActionEvent actionEvent) {
}

@FXML
public void initialize() {
public void initialize(){
ConsoleOutput consoleOutput = new ConsoleOutput(consoleLog);
PrintStream consolePrintStream = new PrintStream(consoleOutput);
System.setOut(consolePrintStream);
comboBox.setItems(languagesList);

}


@FXML
public void switchLanguage(final ActionEvent actionEvent) throws IOException {
actionEvent.consume();
if (comboBox.getValue().equals(languagesList.get(0))) {
App.setRoot("german");
return;
}
App.setRoot("englisch");
}


Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.control.Button?>
<?import javafx.scene.control.ComboBox?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.RadioButton?>
<?import javafx.scene.control.TextArea?>
Expand All @@ -12,8 +13,9 @@
<?import javafx.scene.layout.Pane?>
<?import javafx.scene.text.Font?>

<Pane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="631.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/19" xmlns:fx="http://javafx.com/fxml/1" fx:controller="dev.samir.vmdconverter.AppController">
<Pane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="631.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/20.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="dev.samir.vmdconverter.AppController">
<children>
<ComboBox fx:id="comboBox" layoutX="6.0" layoutY="2.0" onAction="#switchLanguage" prefWidth="150.0" promptText="Englisch (US)" />
<Label layoutX="241.0" layoutY="14.0" prefHeight="38.0" prefWidth="166.0" text="VMD Converter" textAlignment="CENTER">
<font>
<Font size="18.0" />
Expand Down
66 changes: 66 additions & 0 deletions src/main/resources/dev/samir/vmdconverter/german.fxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.control.Button?>
<?import javafx.scene.control.ComboBox?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.RadioButton?>
<?import javafx.scene.control.TextArea?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.control.ToggleGroup?>
<?import javafx.scene.effect.Blend?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.Pane?>
<?import javafx.scene.text.Font?>

<Pane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="631.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/20.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="dev.samir.vmdconverter.AppController">
<children>
<ComboBox fx:id="comboBox" layoutX="6.0" layoutY="2.0" onAction="#switchLanguage" prefWidth="150.0" promptText="Deutsch (German)" />
<Label layoutX="241.0" layoutY="14.0" prefHeight="38.0" prefWidth="166.0" text="VMD Converter" textAlignment="CENTER">
<font>
<Font size="18.0" />
</font>
</Label>
<AnchorPane layoutX="190.0" layoutY="86.0" prefHeight="114.0" prefWidth="249.0">
<children>
<TextField fx:id="inputField" editable="false" layoutX="-17.0" layoutY="24.0" prefHeight="25.0" prefWidth="166.0" />
<Button layoutX="161.0" layoutY="24.0" mnemonicParsing="false" onAction="#inputFieldBrowseButton" prefHeight="25.0" prefWidth="92.0" text="Durchsuchen" textAlignment="CENTER" />
<TextField fx:id="outputField" editable="false" layoutX="-17.0" layoutY="81.0" prefHeight="25.0" prefWidth="166.0" />
<Button layoutX="161.0" layoutY="81.0" mnemonicParsing="false" onAction="#outputFieldBrowseButton" prefHeight="25.0" prefWidth="92.0" text="Durchsuchen" />
<Label layoutX="-15.0" layoutY="60.0" text="Ausgangs Ordner:" textAlignment="CENTER">
<font>
<Font name="Cascadia Code SemiBold" size="14.0" />
</font>
</Label>
<Label layoutX="-15.0" layoutY="6.0" prefHeight="20.0" prefWidth="81.0" text="VMD Datei:" textAlignment="CENTER">
<font>
<Font name="Cascadia Code SemiBold" size="14.0" />
</font>
</Label>
</children>
</AnchorPane>
<HBox layoutX="190.0" layoutY="231.0" prefHeight="25.0" prefWidth="200.0" spacing="60.0">
<children>
<RadioButton fx:id="rb3" mnemonicParsing="false" text="MP3" textAlignment="CENTER">
<toggleGroup>
<ToggleGroup fx:id="Group1" />
</toggleGroup></RadioButton>
<RadioButton fx:id="rb4" mnemonicParsing="false" text="MP4" textAlignment="CENTER" toggleGroup="$Group1" />
</children>
</HBox>
<Label layoutX="177.0" layoutY="206.0" text="Konvertiere zu:" textAlignment="CENTER">
<font>
<Font name="System Bold" size="12.0" />
</font>
</Label>
<Button fx:id="startButton" layoutX="196.0" layoutY="288.0" mnemonicParsing="false" onAction="#startButton" prefHeight="25.0" prefWidth="189.0" text="Start" textAlignment="CENTER">
<font>
<Font name="System Bold" size="12.0" />
</font>
</Button>
<TextArea fx:id="consoleLog" editable="false" layoutX="66.0" layoutY="345.0" prefHeight="272.0" prefWidth="469.0" promptText="Wartet auf eine VMD Datei..." />
</children>
<effect>
<Blend />
</effect>
</Pane>

0 comments on commit 9032715

Please sign in to comment.