Closed ariktoledano closed 1 week ago
Tagging subscribers to this area: @dotnet/area-system-globalization
CC @vitek-karas @mkhamoyan
@matouskozak
@ariktoledano would setting DefaultThreadCurrentCulture
https://learn.microsoft.com/en-us/dotnet/api/system.globalization.cultureinfo.defaultthreadcurrentculture?view=net-8.0 work for your problem?
Thank you for the help :) in the end those lines helped me:
public static void SetEnglishCulture() { try { CultureInfo ci = new CultureInfo("es-US"); //he-IL
CultureInfo.DefaultThreadCurrentCulture = ci;
CultureInfo.DefaultThreadCurrentUICulture = ci;
Thread.CurrentThread.CurrentCulture = ci;
Thread.CurrentThread.CurrentUICulture = ci;
Console.WriteLine(CultureInfo.CurrentCulture);
}
catch (Exception ex)
{
}
}
it's being call on Application derived class -> OnCreate method see->
[Application] public class ApplicationEx : Application, IActivityLifecycleCallbacks { .. public override void OnCreate() { _SetEnglishCulture() base.OnCreate(); ..
Closing as this seems to be resolved.
Type of issue
Typo
Description
Hi After migrating from Xamarin.Android to Xamarin.AndroidX and .net 8 Android App - my current Culture of the app start as hebrew (he-IL) and I would expect it start as english(es-US) - it there a way to set the application and all of its component and sub thread to have english culture - I tried manually seeting it like that and it worked: CultureInfo ci = new CultureInfo("es-US"); //he-IL
Thread.CurrentThread.CurrentCulture = ci; Thread.CurrentThread.CurrentUICulture = ci; Console.WriteLine(CultureInfo.CurrentCulture); But the solution of setting culture for each thread doesn't make sense as we may miss places - I'd expect to have 1 place to configre it - maybe the android manifest.xml
-- just to clarify the reason to not have hebrew culture is that in my sqlite statement it disript the sql query by adding LTR mark near the minus see: //Select * from UserParentCompany where UserParentCompanyId in (0,999999,-400,-500,-600) [Enter feedback here]
Page URL
https://learn.microsoft.com/en-us/dotnet/api/system.globalization.cultureinfo.currentculture?view=net-8.0#system-globalization-cultureinfo-currentculture
Content source URL
https://github.com/dotnet/dotnet-api-docs/blob/main/xml/System.Globalization/CultureInfo.xml
Document Version Independent Id
9ec3ac32-0cbd-b723-26c8-f3986f1c658c
Article author
@dotnet-bot