Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

macOS / Mac Catalyst / iOS: CurrentThread.Current[UI]Culture is always the invariant culture #68321

Closed
Tracked by #8901
rolfbjarne opened this issue Apr 21, 2022 · 17 comments · Fixed by #68706
Closed
Tracked by #8901
Assignees
Labels
Milestone

Comments

@rolfbjarne
Copy link
Member

Description

Thread.CurrentThread.Current[UI]Culture is always the invariant culture at launch in macOS and Mac Catalyst (and probably iOS and tvOS as well).

This affects both Mono (on Mac Catalyst) and CoreCLR (no macOS).

Ref: xamarin/xamarin-macios#14740
Ref: dotnet/maui#3962

Reproduction Steps

  1. Create a new Mac Catalyst app:
dotnet new maccatalyst
  1. Print out Current[UI]Culture at launch by changing the Main.cs file to:
using System.Globalization;

Console.WriteLine ($"CurrentUICulture: {GetString (Thread.CurrentThread.CurrentUICulture)}");
Console.WriteLine ($"CurrentCulture: {GetString (Thread.CurrentThread.CurrentCulture)}");

Thread.CurrentThread.CurrentUICulture = new CultureInfo ("en-US");
Thread.CurrentThread.CurrentCulture = new CultureInfo ("en-US");

Console.WriteLine ("After setting to 'en-US':");
Console.WriteLine ($"CurrentUICulture: {GetString (Thread.CurrentThread.CurrentUICulture)}");
Console.WriteLine ($"CurrentCulture: {GetString (Thread.CurrentThread.CurrentCulture)}");


static string GetString (CultureInfo ci)
{
	return $"Name: {ci.Name} NativeName: '{ci.NativeName}' DisplayName: '{ci.DisplayName}' EnglishName: '{ci.EnglishName}'";
}
  1. Build
dotnet run
  1. Run the executable (not the app) to get stdout written to a terminal:
$ ./bin/Debug/net6.0-maccatalyst/maccatalyst-x64/currentculturetest.app/Contents/MacOS/currentculturetest
[...]
CurrentUICulture: Name:  NativeName: 'Invariant Language (Invariant Country)' DisplayName: 'Invariant Language (Invariant Country)' EnglishName: 'Invariant Language (Invariant Country)'
CurrentCulture: Name:  NativeName: 'Invariant Language (Invariant Country)' DisplayName: 'Invariant Language (Invariant Country)' EnglishName: 'Invariant Language (Invariant Country)'
After setting to 'en-US':
CurrentUICulture: Name: en-US NativeName: 'en (US)' DisplayName: 'en (US)' EnglishName: 'en (US)'
CurrentCulture: Name: en-US NativeName: 'en (US)' DisplayName: 'en (US)' EnglishName: 'en (US)

Complete test project: currentculturetest-d0b7a3f.zip

Expected behavior

CurrentThread.Current[UI]Culture should reflect whatever's configured in the OS.

Actual behavior

Always Invariant culture

Regression?

Don't know

Known Workarounds

No response

Configuration

No response

Other information

No response

@dotnet-issue-labeler dotnet-issue-labeler bot added area-System.Globalization untriaged New issue has not been triaged by the area owner labels Apr 21, 2022
@ghost
Copy link

ghost commented Apr 21, 2022

Tagging subscribers to this area: @dotnet/area-system-globalization
See info in area-owners.md if you want to be subscribed.

Issue Details

Description

Thread.CurrentThread.Current[UI]Culture is always the invariant culture at launch in macOS and Mac Catalyst (and probably iOS and tvOS as well).

This affects both Mono (on Mac Catalyst) and CoreCLR (no macOS).

Ref: xamarin/xamarin-macios#14740
Ref: dotnet/maui#3962

Reproduction Steps

  1. Create a new Mac Catalyst app:
dotnet new maccatalyst
  1. Print out Current[UI]Culture at launch by changing the Main.cs file to:
using System.Globalization;

Console.WriteLine ($"CurrentUICulture: {GetString (Thread.CurrentThread.CurrentUICulture)}");
Console.WriteLine ($"CurrentCulture: {GetString (Thread.CurrentThread.CurrentCulture)}");

Thread.CurrentThread.CurrentUICulture = new CultureInfo ("en-US");
Thread.CurrentThread.CurrentCulture = new CultureInfo ("en-US");

Console.WriteLine ("After setting to 'en-US':");
Console.WriteLine ($"CurrentUICulture: {GetString (Thread.CurrentThread.CurrentUICulture)}");
Console.WriteLine ($"CurrentCulture: {GetString (Thread.CurrentThread.CurrentCulture)}");


static string GetString (CultureInfo ci)
{
	return $"Name: {ci.Name} NativeName: '{ci.NativeName}' DisplayName: '{ci.DisplayName}' EnglishName: '{ci.EnglishName}'";
}
  1. Build
dotnet run
  1. Run the executable (not the app) to get stdout written to a terminal:
$ ./bin/Debug/net6.0-maccatalyst/maccatalyst-x64/currentculturetest.app/Contents/MacOS/currentculturetest
[...]
CurrentUICulture: Name:  NativeName: 'Invariant Language (Invariant Country)' DisplayName: 'Invariant Language (Invariant Country)' EnglishName: 'Invariant Language (Invariant Country)'
CurrentCulture: Name:  NativeName: 'Invariant Language (Invariant Country)' DisplayName: 'Invariant Language (Invariant Country)' EnglishName: 'Invariant Language (Invariant Country)'
After setting to 'en-US':
CurrentUICulture: Name: en-US NativeName: 'en (US)' DisplayName: 'en (US)' EnglishName: 'en (US)'
CurrentCulture: Name: en-US NativeName: 'en (US)' DisplayName: 'en (US)' EnglishName: 'en (US)

Complete test project: currentculturetest-d0b7a3f.zip

Expected behavior

CurrentThread.Current[UI]Culture should reflect whatever's configured in the OS.

Actual behavior

Always Invariant culture

Regression?

Don't know

Known Workarounds

No response

Configuration

No response

Other information

No response

Author: rolfbjarne
Assignees: -
Labels:

area-System.Globalization, untriaged

Milestone: -

@rolfbjarne
Copy link
Member Author

In legacy Xamarin, the current culture was set in the get_darwin_locale method in mono. This function doesn't exist anymore in this repo (removed in 738066c).

Ref: xamarin/xamarin-macios#14740 (comment)

@rolfbjarne
Copy link
Member Author

CC @steveisok @akoeplinger

@rolfbjarne
Copy link
Member Author

For reference, this is the output of an equivalent Xamarin.Mac test project:

$ ./bin/Debug/mactestapp.app/Contents/MacOS/mactestapp
CurrentUICulture: Name: en-US NativeName: 'English (United States)' DisplayName: 'English (United States)' EnglishName: 'English (United States)'
CurrentCulture: Name: en-US NativeName: 'English (United States)' DisplayName: 'English (United States)' EnglishName: 'English (United States)'
After setting to 'en-US':
CurrentUICulture: Name: en-US NativeName: 'English (United States)' DisplayName: 'English (United States)' EnglishName: 'English (United States)'
CurrentCulture: Name: en-US NativeName: 'English (United States)' DisplayName: 'English (United States)' EnglishName: 'English (United States)'

@steveisok steveisok removed the untriaged New issue has not been triaged by the area owner label Apr 21, 2022
@steveisok steveisok added this to the 6.0.x milestone Apr 21, 2022
@steveisok steveisok self-assigned this Apr 21, 2022
@steveisok
Copy link
Member

Looks like we're relying on the default to come out of ICU, which I believe is "en_US_POSIX" and we subsequently ignore

if (strcmp(icuLocale, "en_US_POSIX") == 0)
{
return "";
}

The right way would be to add a get_darwin_locale equivalent.

@am11
Copy link
Member

am11 commented Apr 21, 2022

ICU uses system default, which you can check with locale(1) command or from environment vars like $LANG, $LC_ALL and $LC_MESSAGES etc.

6.0.x milestone

This applies to all supported Unix OS and versions of .NET Core; it is not specific to Darwin and .NET 6.

@tarekgh
Copy link
Member

tarekgh commented Apr 21, 2022

Yes, setting the LANG environment variable should workaround this issue. But I hope this can be fixed as @steveisok mentioned in #68321 (comment).

@steveisok will you take care with this issue? I am seeing you have marked for 6.x.

@rolfbjarne
Copy link
Member Author

Yes, setting the LANG environment variable should workaround this issue.

That's really only feasible for command-line executables. There's no user-friendly way to set LANG for normal (UI) apps.

@tarekgh
Copy link
Member

tarekgh commented Apr 21, 2022

That's really only feasible for command-line executables. There's no user-friendly way to set LANG for normal (UI) apps.

Agree. The UI apps can force the culture in the startup code too. I am not suggesting that but just mentioning it.

Looks like we're relying on the default to come out of ICU, which I believe is "en_US_POSIX" and we subsequently ignore

does en_US_POSIX set on the device/machine? I think what is happening is there is no locale set in the environment variable LANG nor LC_ALL which causes us to fallback to invariant. uloc_getDefault() just return empty string I guess.

const char* icuLocale = uloc_getDefault();

@tarekgh tarekgh added os-mac-os-x macOS aka OSX os-tvos Apple tvOS os-maccatalyst MacCatalyst OS labels Apr 21, 2022
@ghost
Copy link

ghost commented Apr 21, 2022

Tagging subscribers to 'os-tvos': @steveisok, @akoeplinger
See info in area-owners.md if you want to be subscribed.

Issue Details

Description

Thread.CurrentThread.Current[UI]Culture is always the invariant culture at launch in macOS and Mac Catalyst (and probably iOS and tvOS as well).

This affects both Mono (on Mac Catalyst) and CoreCLR (no macOS).

Ref: xamarin/xamarin-macios#14740
Ref: dotnet/maui#3962

Reproduction Steps

  1. Create a new Mac Catalyst app:
dotnet new maccatalyst
  1. Print out Current[UI]Culture at launch by changing the Main.cs file to:
using System.Globalization;

Console.WriteLine ($"CurrentUICulture: {GetString (Thread.CurrentThread.CurrentUICulture)}");
Console.WriteLine ($"CurrentCulture: {GetString (Thread.CurrentThread.CurrentCulture)}");

Thread.CurrentThread.CurrentUICulture = new CultureInfo ("en-US");
Thread.CurrentThread.CurrentCulture = new CultureInfo ("en-US");

Console.WriteLine ("After setting to 'en-US':");
Console.WriteLine ($"CurrentUICulture: {GetString (Thread.CurrentThread.CurrentUICulture)}");
Console.WriteLine ($"CurrentCulture: {GetString (Thread.CurrentThread.CurrentCulture)}");


static string GetString (CultureInfo ci)
{
	return $"Name: {ci.Name} NativeName: '{ci.NativeName}' DisplayName: '{ci.DisplayName}' EnglishName: '{ci.EnglishName}'";
}
  1. Build
dotnet run
  1. Run the executable (not the app) to get stdout written to a terminal:
$ ./bin/Debug/net6.0-maccatalyst/maccatalyst-x64/currentculturetest.app/Contents/MacOS/currentculturetest
[...]
CurrentUICulture: Name:  NativeName: 'Invariant Language (Invariant Country)' DisplayName: 'Invariant Language (Invariant Country)' EnglishName: 'Invariant Language (Invariant Country)'
CurrentCulture: Name:  NativeName: 'Invariant Language (Invariant Country)' DisplayName: 'Invariant Language (Invariant Country)' EnglishName: 'Invariant Language (Invariant Country)'
After setting to 'en-US':
CurrentUICulture: Name: en-US NativeName: 'en (US)' DisplayName: 'en (US)' EnglishName: 'en (US)'
CurrentCulture: Name: en-US NativeName: 'en (US)' DisplayName: 'en (US)' EnglishName: 'en (US)

Complete test project: currentculturetest-d0b7a3f.zip

Expected behavior

CurrentThread.Current[UI]Culture should reflect whatever's configured in the OS.

Actual behavior

Always Invariant culture

Regression?

Don't know

Known Workarounds

No response

Configuration

No response

Other information

No response

Author: rolfbjarne
Assignees: steveisok
Labels:

area-System.Globalization, os-mac-os-x, os-tvos, os-maccatalyst

Milestone: 6.0.x

@am11
Copy link
Member

am11 commented Apr 21, 2022

Running locale on macOS M1 in its factory settings shows this:

% locale

LANG=""
LC_COLLATE="C"
LC_CTYPE="UTF-8"
LC_MESSAGES="C"
LC_MONETARY="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_ALL=

This is the same case with some Linux distros, especially in minimal installation mode (or containers). IMO, we should take those cases into account if we are planning to do something about it (not only Darwin).

@tarekgh
Copy link
Member

tarekgh commented Apr 21, 2022

This is the same case with some Linux distros, especially in minimal installation mode (or containers). IMO, we should take those cases into account if we are planning to do something about it (not only Darwin).

What are you suggesting doing here? How you will fix this on Linux? C locale is the POSIX locale which has very bad behavior with collations. That is why we fallback to Invariant when we see this locale.

@am11
Copy link
Member

am11 commented Apr 21, 2022

What are you suggesting doing here?

I think in addition to porting get_darwin_locale, maybe also port get_posix_locale at the same time? This way when icuLocale has POSIX locale, before falling back to Invariant on Linux as we currently do, it will attempt to use setlocale(.., NULL) (which implies "get locale") on Linux / FreeBSD etc. and CFLocaleGetValue on Darwin platforms.

@tarekgh
Copy link
Member

tarekgh commented Apr 21, 2022

@am11 we are currently calling ICU uloc_getDefault API, which does all the logic you are mentioning here. https:/unicode-org/icu/blob/fca6b342c03d89998eba227d284e232dabbfab47/icu4c/source/common/putil.cpp#L1676. The only missing part is on Darwin, it doesn't call CFLocaleGetValue.

@rolfbjarne
Copy link
Member Author

@steveisok I looked into setting LANG in the native main method as a workaround, and I ran into a few issues:

It doesn't work with CoreCLR (i.e. on macOS), because CoreCLR links with the system libicucore.dylib, and that library reads LANG in a dylib initializer (so before the native main method):

(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 2.4
  * frame #0: 0x00007ff800657090 libsystem_c.dylib`getenv
    frame #1: 0x00007ff802b58ccb libicucore.A.dylib`uprv_getDefaultLocaleID + 137
    frame #2: 0x00007ff802b3d832 libicucore.A.dylib`___lldb_unnamed_symbol229$$libicucore.A.dylib + 58
    frame #3: 0x00007ff802b3e073 libicucore.A.dylib`icu::Locale::getDefault() + 63
    frame #4: 0x00007ff802b3e02e libicucore.A.dylib`___lldb_unnamed_symbol233$$libicucore.A.dylib + 9
    frame #5: 0x00007ff802bd4b0e libicucore.A.dylib`___lldb_unnamed_symbol1298$$libicucore.A.dylib + 663
    frame #6: 0x00007ff802b4660a libicucore.A.dylib`uloc_getTableStringWithFallback + 140
    frame #7: 0x00007ff802b39855 libicucore.A.dylib`___lldb_unnamed_symbol183$$libicucore.A.dylib + 171
    frame #8: 0x00007ff802b37e6d libicucore.A.dylib`uloc_getDisplayLanguage + 207
    frame #9: 0x00007ff800816779 CoreFoundation`__CFLocaleLanguageName + 73
    frame #10: 0x00007ff8008165d3 CoreFoundation`CFLocaleCopyDisplayNameForPropertyValue + 354
    frame #11: 0x00007ff800816465 CoreFoundation`-[__NSCFLocale displayNameForKey:value:] + 15
    frame #12: 0x00007ff80164ce98 Foundation`-[NSUserDefaults(NSUserDefaults) init] + 1626
    frame #13: 0x00007ff80164c7fe Foundation`+[NSUserDefaults(NSUserDefaults) standardUserDefaults] + 66
    frame #14: 0x00007ff80323d415 AppKit`_NSGetBoolAppConfig + 66
    frame #15: 0x00007ff803adb74d AppKit`registerTaggedPointerColorsIfNecessary + 85
    frame #16: 0x00007ff80323d354 AppKit`_NSColorSpaceTaggedPointerColor + 24
    frame #17: 0x00007ff8032427d6 AppKit`+[NSColor colorWithColorSpace:components:count:] + 33
    frame #18: 0x00007ff80347255d AppKit`+[NSColor colorWithRed:green:blue:alpha:] + 176
    frame #19: 0x00007ffa1d560b1c GameplayKit`_GLOBAL__sub_I_GKNoiseMap.mm + 92
    frame #20: 0x000000010045cddb dyld`invocation function for block in dyld4::Loader::findAndRunAllInitializers(dyld4::RuntimeState&) const + 182
    frame #21: 0x0000000100483257 dyld`invocation function for block in dyld3::MachOAnalyzer::forEachInitializer(Diagnostics&, dyld3::MachOAnalyzer::VMAddrConverter const&, void (unsigned int) block_pointer, void const*) const + 242
    frame #22: 0x000000010047a85a dyld`invocation function for block in dyld3::MachOFile::forEachSection(void (dyld3::MachOFile::SectionInfo const&, bool, bool&) block_pointer) const + 557
    frame #23: 0x0000000100449db3 dyld`dyld3::MachOFile::forEachLoadCommand(Diagnostics&, void (load_command const*, bool&) block_pointer) const + 129
    frame #24: 0x000000010047a5eb dyld`dyld3::MachOFile::forEachSection(void (dyld3::MachOFile::SectionInfo const&, bool, bool&) block_pointer) const + 179
    frame #25: 0x0000000100482dae dyld`dyld3::MachOAnalyzer::forEachInitializer(Diagnostics&, dyld3::MachOAnalyzer::VMAddrConverter const&, void (unsigned int) block_pointer, void const*) const + 466
    frame #26: 0x000000010045cd0e dyld`dyld4::Loader::findAndRunAllInitializers(dyld4::RuntimeState&) const + 144
    frame #27: 0x000000010046322a dyld`dyld4::PrebuiltLoader::runInitializers(dyld4::RuntimeState&) const + 30
    frame #28: 0x000000010045ce9a dyld`dyld4::Loader::runInitializersBottomUp(dyld4::RuntimeState&, dyld3::Array<dyld4::Loader const*>&) const + 178
    frame #29: 0x000000010045ce7d dyld`dyld4::Loader::runInitializersBottomUp(dyld4::RuntimeState&, dyld3::Array<dyld4::Loader const*>&) const + 149
    frame #30: 0x000000010045ce7d dyld`dyld4::Loader::runInitializersBottomUp(dyld4::RuntimeState&, dyld3::Array<dyld4::Loader const*>&) const + 149
    frame #31: 0x000000010045cf3e dyld`dyld4::Loader::runInitializersBottomUpPlusUpwardLinks(dyld4::RuntimeState&) const + 108
    frame #32: 0x000000010047054e dyld`dyld4::APIs::runAllInitializersForMain() + 222
    frame #33: 0x000000010044e37d dyld`dyld4::prepare(dyld4::APIs&, dyld3::MachOAnalyzer const*) + 3443
    frame #34: 0x000000010044d4d4 dyld`start + 388
(lldb) p (char *) $rdi
(char *) $1 = 0x00007ff802da24e9 "LANG"

It seems to work when using Mono as the runtime (iOS, tvOS, Mac Catalyst), until an unknown value for LANG is set (say LANG=en-garbage), then the app crashes: https://gist.github.com/rolfbjarne/59de02a3facfbb723f21466ac692f0e4. The fact that it crashes might be a separate issue, but in order to make the workaround useful we'd have to fix the crash too, and that makes it less viable as a last moment temporary workaround. And even if we did fix the crash itself, we'd still probably throw an exception, which app developers would likely have a hard time track down (because it wouldn't happen on their devices, only on end user devices with uncommon regional settings).

This leads me to believe that setting LANG isn't viable as a workaround, it's much better to have an easily understandable bug that app developers can work around themselves instead.

@tarekgh
Copy link
Member

tarekgh commented Apr 28, 2022

@rolfbjarne the crash because you are using a locale name en-garbage. When calling ICU library to normalize this name, it returns something like en__GARBAGE which is invalid name. Try to use a name with a second part is 4 characters or less. Something like en-GARB.

@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Apr 29, 2022
steveisok pushed a commit to steveisok/runtime that referenced this issue Apr 29, 2022
This change adds a function to lookup the current NSLocale and extract the language + country code to load into ICU by default.  Previously, we would defer to uloc_getDefault in ICU, which would return a value we would ignore (en_US_POSIX) and result in falling back to invariant mode.

Fixes dotnet#68321
@marek-safar marek-safar added the os-ios Apple iOS label Apr 30, 2022
@ghost
Copy link

ghost commented Apr 30, 2022

Tagging subscribers to 'os-ios': @steveisok, @akoeplinger
See info in area-owners.md if you want to be subscribed.

Issue Details

Description

Thread.CurrentThread.Current[UI]Culture is always the invariant culture at launch in macOS and Mac Catalyst (and probably iOS and tvOS as well).

This affects both Mono (on Mac Catalyst) and CoreCLR (no macOS).

Ref: xamarin/xamarin-macios#14740
Ref: dotnet/maui#3962

Reproduction Steps

  1. Create a new Mac Catalyst app:
dotnet new maccatalyst
  1. Print out Current[UI]Culture at launch by changing the Main.cs file to:
using System.Globalization;

Console.WriteLine ($"CurrentUICulture: {GetString (Thread.CurrentThread.CurrentUICulture)}");
Console.WriteLine ($"CurrentCulture: {GetString (Thread.CurrentThread.CurrentCulture)}");

Thread.CurrentThread.CurrentUICulture = new CultureInfo ("en-US");
Thread.CurrentThread.CurrentCulture = new CultureInfo ("en-US");

Console.WriteLine ("After setting to 'en-US':");
Console.WriteLine ($"CurrentUICulture: {GetString (Thread.CurrentThread.CurrentUICulture)}");
Console.WriteLine ($"CurrentCulture: {GetString (Thread.CurrentThread.CurrentCulture)}");


static string GetString (CultureInfo ci)
{
	return $"Name: {ci.Name} NativeName: '{ci.NativeName}' DisplayName: '{ci.DisplayName}' EnglishName: '{ci.EnglishName}'";
}
  1. Build
dotnet run
  1. Run the executable (not the app) to get stdout written to a terminal:
$ ./bin/Debug/net6.0-maccatalyst/maccatalyst-x64/currentculturetest.app/Contents/MacOS/currentculturetest
[...]
CurrentUICulture: Name:  NativeName: 'Invariant Language (Invariant Country)' DisplayName: 'Invariant Language (Invariant Country)' EnglishName: 'Invariant Language (Invariant Country)'
CurrentCulture: Name:  NativeName: 'Invariant Language (Invariant Country)' DisplayName: 'Invariant Language (Invariant Country)' EnglishName: 'Invariant Language (Invariant Country)'
After setting to 'en-US':
CurrentUICulture: Name: en-US NativeName: 'en (US)' DisplayName: 'en (US)' EnglishName: 'en (US)'
CurrentCulture: Name: en-US NativeName: 'en (US)' DisplayName: 'en (US)' EnglishName: 'en (US)

Complete test project: currentculturetest-d0b7a3f.zip

Expected behavior

CurrentThread.Current[UI]Culture should reflect whatever's configured in the OS.

Actual behavior

Always Invariant culture

Regression?

Don't know

Known Workarounds

No response

Configuration

No response

Other information

No response

Author: rolfbjarne
Assignees: steveisok
Labels:

area-System.Globalization, os-mac-os-x, os-ios, os-tvos, in-pr, os-maccatalyst

Milestone: 6.0.x

steveisok added a commit that referenced this issue May 5, 2022
)

This change adds a function to lookup the current NSLocale and extract the language + country code to load into ICU by default. Previously, we would defer to uloc_getDefault in ICU, which would return a value we would ignore (en_US_POSIX) and result in falling back to invariant mode.

Fixes #68321
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label May 5, 2022
github-actions bot pushed a commit that referenced this issue May 5, 2022
This change adds a function to lookup the current NSLocale and extract the language + country code to load into ICU by default.  Previously, we would defer to uloc_getDefault in ICU, which would return a value we would ignore (en_US_POSIX) and result in falling back to invariant mode.

Fixes #68321
carlossanlop pushed a commit that referenced this issue May 16, 2022
…platforms (#68934)

* Detect the default locale name during startup on Apple platforms

This change adds a function to lookup the current NSLocale and extract the language + country code to load into ICU by default.  Previously, we would defer to uloc_getDefault in ICU, which would return a value we would ignore (en_US_POSIX) and result in falling back to invariant mode.

Fixes #68321

* Link in foundation and address feedback

* Link in foundation in coreclr

* Check LANG env variable first

* Defer to icu first, since it's looking for LANG and certain values.

* #ifdef not #if

* PR feedback

* Remove redundant string replace

* pal_locale.m needs to be in a different location than upstream

* cmake tweak to make sure foundation gets linked in

Co-authored-by: Steve Pfister <[email protected]>
@ghost ghost locked as resolved and limited conversation to collaborators Jun 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants