diff --git a/Elwig/App.xaml.cs b/Elwig/App.xaml.cs index 3b238ed..06a76e7 100644 --- a/Elwig/App.xaml.cs +++ b/Elwig/App.xaml.cs @@ -65,22 +65,27 @@ namespace Elwig { MainDispatcher = Dispatcher; Scales = Array.Empty(); CurrentApp = this; + OverrideCulture(); } - protected override async void OnStartup(StartupEventArgs evt) { - var locale = new CultureInfo("de-AT"); - locale.NumberFormat.CurrencyGroupSeparator = "\u202f"; - locale.NumberFormat.NumberGroupSeparator = "\u202f"; - locale.NumberFormat.PercentGroupSeparator = "\u202f"; + private static void OverrideCulture() { + var locale = new CultureInfo("de-AT", false); + locale.NumberFormat.CurrencyGroupSeparator = Utils.GroupSeparator; + locale.NumberFormat.NumberGroupSeparator = Utils.GroupSeparator; + locale.NumberFormat.PercentGroupSeparator = Utils.GroupSeparator; + CultureInfo.CurrentCulture = locale; + CultureInfo.CurrentUICulture = locale; Thread.CurrentThread.CurrentCulture = locale; Thread.CurrentThread.CurrentUICulture = locale; CultureInfo.DefaultThreadCurrentCulture = locale; CultureInfo.DefaultThreadCurrentUICulture = locale; FrameworkElement.LanguageProperty.OverrideMetadata( typeof(FrameworkElement), - new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag)) + new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.Name)) ); + } + protected override async void OnStartup(StartupEventArgs evt) { Version = typeof(App).GetTypeInfo().Assembly.GetCustomAttribute()?.InformationalVersion.Split("+")[0] ?? "0.0.0"; try { diff --git a/Elwig/Dialogs/AbwertenDialog.xaml.cs b/Elwig/Dialogs/AbwertenDialog.xaml.cs index f89c0f6..cacae5e 100644 --- a/Elwig/Dialogs/AbwertenDialog.xaml.cs +++ b/Elwig/Dialogs/AbwertenDialog.xaml.cs @@ -12,7 +12,7 @@ namespace Elwig.Dialogs { InitializeComponent(); TextLsNr.Text = lsnr; TextMember.Text = name; - TextWeight.Text = $"{weight:N0}\u202fkg"; + TextWeight.Text = $"{weight:N0}{Utils.GroupSeparator}kg"; } private void ConfirmButton_Click(object sender, RoutedEventArgs evt) { diff --git a/Elwig/Dialogs/LinearPriceIncreaseDialog.xaml.cs b/Elwig/Dialogs/LinearPriceIncreaseDialog.xaml.cs index d782d6a..ada4c04 100644 --- a/Elwig/Dialogs/LinearPriceIncreaseDialog.xaml.cs +++ b/Elwig/Dialogs/LinearPriceIncreaseDialog.xaml.cs @@ -1,5 +1,4 @@ using Elwig.Helpers; -using System.Text.RegularExpressions; using System.Windows; using System.Windows.Controls; @@ -14,7 +13,7 @@ namespace Elwig.Dialogs { private void ConfirmButton_Click(object sender, RoutedEventArgs evt) { DialogResult = true; - Price = double.Parse(PriceInput.Text.Replace("\u202f", "")); + Price = double.Parse(PriceInput.Text.Replace(Utils.GroupSeparator, "")); Close(); } diff --git a/Elwig/Helpers/Utils.cs b/Elwig/Helpers/Utils.cs index 9969a98..6a2200f 100644 --- a/Elwig/Helpers/Utils.cs +++ b/Elwig/Helpers/Utils.cs @@ -48,6 +48,9 @@ namespace Elwig.Helpers { [GeneratedRegex(@"^(.*?) +([0-9].*)$", RegexOptions.Compiled)] private static partial Regex GeneratedAddressRegex(); + public static readonly string GroupSeparator = "\u202F"; + public static readonly string UnitSeparator = "\u00A0"; + public static readonly KeyValuePair[] PhoneNrTypes = [ new("landline", "Tel.-Nr. (Festnetz)"), new("mobile", "Tel.-Nr. (mobil)"), diff --git a/Elwig/Windows/DeliveryAdminWindow.xaml.cs b/Elwig/Windows/DeliveryAdminWindow.xaml.cs index f50d015..110fb9f 100644 --- a/Elwig/Windows/DeliveryAdminWindow.xaml.cs +++ b/Elwig/Windows/DeliveryAdminWindow.xaml.cs @@ -889,7 +889,7 @@ namespace Elwig.Windows { p.Acid = (AcidInput.Text == "") ? null : double.Parse(AcidInput.Text); p.Comment = (PartCommentInput.Text == "") ? null : PartCommentInput.Text; - p.Weight = int.Parse(WeightInput.Text.Replace("\u202f", "")); + p.Weight = int.Parse(WeightInput.Text.Replace(Utils.GroupSeparator, "")); p.ManualWeighing = ManualWeighingInput.IsChecked ?? false; p.ScaleId = ScaleId; p.WeighingId = WeighingId;