diff --git a/src/ClaudeDo.Ui/AppSettings.cs b/src/ClaudeDo.Ui/AppSettings.cs index 73b6b11..e9c9037 100644 --- a/src/ClaudeDo.Ui/AppSettings.cs +++ b/src/ClaudeDo.Ui/AppSettings.cs @@ -7,6 +7,7 @@ public sealed class AppSettings { public string DbPath { get; set; } = "~/.todo-app/todo.db"; public string SignalRUrl { get; set; } = "http://127.0.0.1:47821/hub"; + public string Language { get; set; } = ""; private static readonly string ConfigPath = Paths.Expand("~/.todo-app/ui.config.json"); @@ -27,4 +28,12 @@ public sealed class AppSettings } return new(); } + + public void Save() + { + var dir = Path.GetDirectoryName(ConfigPath); + if (!string.IsNullOrEmpty(dir)) Directory.CreateDirectory(dir); + var json = JsonSerializer.Serialize(this, new JsonSerializerOptions { WriteIndented = true }); + File.WriteAllText(ConfigPath, json); + } } diff --git a/tests/ClaudeDo.Ui.Tests/AppSettingsTests.cs b/tests/ClaudeDo.Ui.Tests/AppSettingsTests.cs new file mode 100644 index 0000000..88ffdd1 --- /dev/null +++ b/tests/ClaudeDo.Ui.Tests/AppSettingsTests.cs @@ -0,0 +1,22 @@ +using System.Text.Json; +using ClaudeDo.Ui; + +namespace ClaudeDo.Ui.Tests; + +public class AppSettingsTests +{ + [Fact] + public void Language_defaults_to_empty() + { + Assert.Equal("", new AppSettings().Language); + } + + [Fact] + public void Language_round_trips_through_json() + { + var json = JsonSerializer.Serialize(new AppSettings { Language = "de" }); + var back = JsonSerializer.Deserialize(json, + new JsonSerializerOptions { PropertyNameCaseInsensitive = true })!; + Assert.Equal("de", back.Language); + } +}