Skip to content

Commit

Permalink
Fix decimal separator
Browse files Browse the repository at this point in the history
This commit amends the IOS app to introspect the decimal separator from the native IOS locale settings, and updates the culture to match.

The existing behaviour seems to be to use the language code only to set the decimal formatter, however ios allows users to configure number formatting independently of language/region.

Fixes #332
  • Loading branch information
LiamMorrow committed Dec 3, 2024
1 parent 08ddb20 commit 4dbfe81
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
15 changes: 13 additions & 2 deletions LiftLog.Maui/Platforms/iOS/AppDelegate.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Foundation;
using System.Globalization;
using Foundation;
using LiftLog.Maui.Services;
using UIKit;

Expand All @@ -7,5 +8,15 @@ namespace LiftLog.Maui;
[Register("AppDelegate")]
public class AppDelegate : MauiUIApplicationDelegate
{
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
protected override MauiApp CreateMauiApp()
{
var app = MauiProgram.CreateMauiApp();
var newCulture = CultureInfo.CurrentCulture.Clone() as CultureInfo;
newCulture!.NumberFormat.NumberDecimalSeparator = NSLocale.CurrentLocale.DecimalSeparator;
newCulture.NumberFormat.CurrencyGroupSeparator = NSLocale.CurrentLocale.GroupingSeparator;

CultureInfo.CurrentCulture = newCulture;
CultureInfo.CurrentUICulture = newCulture;
return app;
}
}
3 changes: 1 addition & 2 deletions LiftLog.Maui/Platforms/iOS/Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using ObjCRuntime;
using UIKit;
using UIKit;

namespace LiftLog.Maui;

Expand Down

0 comments on commit 4dbfe81

Please sign in to comment.