feat(i18n): add Language preference and Save() to AppSettings
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user