Parcourir la source

add setting for user-chosen "language"

Sebastian Stenzel il y a 3 ans
Parent
commit
c130441700

+ 7 - 0
src/main/java/org/cryptomator/common/settings/Settings.java

@@ -44,6 +44,7 @@ public class Settings {
 	public static final String DEFAULT_LICENSE_KEY = "";
 	public static final boolean DEFAULT_SHOW_MINIMIZE_BUTTON = false;
 	public static final String DEFAULT_DISPLAY_CONFIGURATION = "";
+	public static final String DEFAULT_LANGUAGE = null;
 
 
 	private final ObservableList<VaultSettings> directories = FXCollections.observableArrayList(VaultSettings::observables);
@@ -66,6 +67,7 @@ public class Settings {
 	private final IntegerProperty windowWidth = new SimpleIntegerProperty();
 	private final IntegerProperty windowHeight = new SimpleIntegerProperty();
 	private final ObjectProperty<String> displayConfiguration = new SimpleObjectProperty<>(DEFAULT_DISPLAY_CONFIGURATION);
+	private final StringProperty language = new SimpleStringProperty(DEFAULT_LANGUAGE);
 
 
 	private Consumer<Settings> saveCmd;
@@ -96,6 +98,7 @@ public class Settings {
 		windowWidth.addListener(this::somethingChanged);
 		windowHeight.addListener(this::somethingChanged);
 		displayConfiguration.addListener(this::somethingChanged);
+		language.addListener(this::somethingChanged);
 	}
 
 	void setSaveCmd(Consumer<Settings> saveCmd) {
@@ -191,4 +194,8 @@ public class Settings {
 	public ObjectProperty<String> displayConfigurationProperty() {
 		return displayConfiguration;
 	}
+
+	public StringProperty languageProperty() {
+		return language;
+	}
 }

+ 2 - 0
src/main/java/org/cryptomator/common/settings/SettingsJsonAdapter.java

@@ -57,6 +57,7 @@ public class SettingsJsonAdapter extends TypeAdapter<Settings> {
 		out.name("windowWidth").value((value.windowWidthProperty().get()));
 		out.name("windowHeight").value((value.windowHeightProperty().get()));
 		out.name("displayConfiguration").value((value.displayConfigurationProperty().get()));
+		out.name("language").value((value.languageProperty().get()));
 
 		out.endObject();
 	}
@@ -97,6 +98,7 @@ public class SettingsJsonAdapter extends TypeAdapter<Settings> {
 				case "windowWidth" -> settings.windowWidthProperty().set(in.nextInt());
 				case "windowHeight" -> settings.windowHeightProperty().set(in.nextInt());
 				case "displayConfiguration" -> settings.displayConfigurationProperty().set(in.nextString());
+				case "language" -> settings.languageProperty().set(in.nextString());
 
 				default -> {
 					LOG.warn("Unsupported vault setting found in JSON: " + name);