bloxstrap/Bloxstrap/UI/ViewModels/Dialogs/LanguageSelectorViewModel.cs
pizzaboxer 81d7ffe3da
Draft: localisation support
this is a draft as i can't fully test this right now because i'm currently 37000 feet in the air and a 75 MB data quota costs 10 bucks :(

this also may be the first documented instance of me using wpf 100% properly as bill gates himself intended
2024-06-21 22:10:11 +01:00

31 lines
832 B
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
using CommunityToolkit.Mvvm.Input;
namespace Bloxstrap.UI.ViewModels.Dialogs
{
internal class LanguageSelectorViewModel
{
public event EventHandler? CloseRequestEvent;
public ICommand SetLocaleCommand => new RelayCommand(SetLocale);
public static List<string> Languages => Locale.SupportedLocales.Values.ToList();
public string SelectedLanguage { get; set; } = Locale.SupportedLocales[App.Settings.Prop.Locale];
private void SetLocale()
{
App.Settings.Prop.Locale = Locale.GetIdentifierFromName(SelectedLanguage);
Locale.Set();
CloseRequestEvent?.Invoke(this, new());
}
}
}