Skip to content

Regression: Norwegian localization no longer works in iOS with .NET 9 #112249

Closed

Description

@dotMorten

Description

When having localized resources in your application, and one of them is norwegian no, the resource lookup no longer works and falls back to english. This behavior is only observed on net9.0-ios, and not on Windows and Android or in net8.0-ios.

Reproduction Steps

  1. Open and run the following sample on iOS:
    MauiApp12.zip

  2. Notice that the button says "Language is English". Repeat on Android and Windows or downgrade the iOS target to .NET 8 and notice the output is now correctly "Language is Norwegian".

Expected behavior

Norwegian resources are correctly looked up.

Actual behavior

Resources not found and falls back to the default english resource.

Regression?

Yes

Known Workarounds

No response

Configuration

.NET 9.0.101, ios-arm64 with iOS 18.2 as well as on iOS17.5

Other information

Looking at the generated NO culture this is what I'm seeing which is likely the cause of it:

var no = new System.Globalization.CultureInfo("no");
Debug.WriteLine(no.TwoLetterISOLanguageName); // return "nb" on net9.0-iOS, "no" on  net9.0-Android and net8.0-ios
Debug.WriteLine(no.Name); // return "nb" on net9.0-iOS, "no" on  net9.0-Android and net8.0-ios

Looks like in 8.0, dotnet linked its own fork of ICU into every ios app, and in 9.0, you use system libraries as much as possible instead: #80689

I'm guessing this is the root of the problem.

Might also be related to: #110680
Also related:

This is a pretty big regression for our localized libraries that we ship to other developers.

Activity

  1. ghost added
    needs-area-label
    on Feb 6, 2025
  2. added
    untriaged
    on Feb 6, 2025
  3. added
    os-ios
    and removed
    untriaged
    needs-area-label
    on Feb 6, 2025
  4. ivanpovazan commented on Feb 6, 2025

    @ivanpovazan
    Member
  5. added this to the 10.0.0 milestone on Feb 6, 2025
  6. dotMorten commented on Feb 7, 2025

    @dotMorten
    Author

    @ivanpovazan Since this is a pretty big regression breaking localization, is there a reason it's pushed off to the next release?

  7. steveisok commented on Feb 9, 2025

    @steveisok
    Member

    @ivanpovazan Since this is a pretty big regression breaking localization, is there a reason it's pushed off to the next release?

    We'll typically set the milestone for the next release as way to track active work. A separate backport decision is made when the change goes in.

  8. ivanpovazan commented on Feb 10, 2025

    @ivanpovazan
    Member

    @dotMorten, as @steveisok said, it is being marked with 10.0.0 milestone just to annotate that we are actively working on it. Once the fix gets merged to main, we consider backporting it to the servicing releases depending on when/where the regression started occurring. Thank you for understanding.

  9. self-assigned this
    on Feb 12, 2025
  10. ivanpovazan commented on Feb 17, 2025

    @ivanpovazan
    Member

    As noted, in .NET 9 we use system libraries for globalization support on iOS platforms.

    In case of no our code paths essentially end up calling:

    NSLocale *currentLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"no"];
    const char* value = [currentLocale.localeIdentifier UTF8String];

    which returns nb.

    The same behavior has been verified with plain Objective-C app in Xcode targeting MacOS and iOS platforms, which implies the behavior is imposed by Apple.

    I opened a feedback ticket to apple: https://feedbackassistant.apple.com/feedback/16512787

    In the meantime, @dotMorten is it feasible for you to add nb resource as well to your app as a workaround?

  11. tivik7 commented on Feb 21, 2025

    @tivik7

    @dotMorten

    I am using in the startup to force the language setting, seems to be working

        if (NSLocale.PreferredLanguages.ElementAt(0).Substring(0, Math.Min(NSLocale.PreferredLanguages.ElementAt(0).Length, 3)) == "nb-")
        {
            CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("nb-NO");
            CultureInfo.DefaultThreadCurrentUICulture = new CultureInfo("nb-NO");
        } else if (NSLocale.PreferredLanguages.ElementAt(0).Substring(0, Math.Min(NSLocale.PreferredLanguages.ElementAt(0).Length, 3)) == "nn-")
        {
            CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("nn-NO");
            CultureInfo.DefaultThreadCurrentUICulture = new CultureInfo("nn-NO");
        }
    
  12. dotMorten commented on Feb 21, 2025

    @dotMorten
    Author

    @tivik7 I'm building a 3rd party class library (so no language startup code), and the no language resources suddenly won't work because of this breaking behavior, but continues to work on all other platforms.

  13. tivik7 commented on Feb 23, 2025

    @tivik7

    @dotMorten I guess you will be able to use complier directives to add the check for iOS in your library initialization code, or in the relevant features til this gets fixed. Not entirely sure how the CultureInfo.DefaultThreadCurrentCulture work, but believe that you set the culture for the entire app event if you set it from a library. Might be a need to set it using the main tread if not done in the initialization.

  14. matouskozak commented on Aug 4, 2025

    @matouskozak
    Member

    As noted, in .NET 9 we use system libraries for globalization support on iOS platforms.

    In case of no our code paths essentially end up calling:

    NSLocale currentLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"no"];
    const char
    value = [currentLocale.localeIdentifier UTF8String];
    which returns nb.

    The same behavior has been verified with plain Objective-C app in Xcode targeting MacOS and iOS platforms, which implies the behavior is imposed by Apple.

    I opened a feedback ticket to apple: https://feedbackassistant.apple.com/feedback/16512787

    In the meantime, @dotMorten is it feasible for you to add nb resource as well to your app as a workaround?

    I'll keep this open to track this regression but move it to .NET 11 until https://feedbackassistant.apple.com/feedback/16512787 is addressed.

  15. modified the milestones: 10.0.0, 11.0.0 on Aug 4, 2025
  16. matouskozak commented on Jul 13, 2026

    @matouskozak
    Member

    This looks like intended behavior by Apple https://github.com/swiftlang/swift-corelibs-foundation/blob/ffb8de57a67e81b014c0e06296b273f1fcf3a1dc/Sources/CoreFoundation/CFLocaleIdentifier.c#L741-L746. Even though ICU treats "no" as a separate culture, Foundation Locale treats it as "nb". We could special case "no" on the .NET side but from previous investigations it was just one of many culture which are treated differently by ObjectiveC APIs. @dotMorten is this still a blocking issue for your use-case?

  17. added
    needs-author-action
    on Jul 14, 2026
  18. dotMorten commented on Jul 14, 2026

    @dotMorten
    Author

    Yes it makes it really hard to make cross-platform libraries that "just work". Changing the locale as suggested above is also problematic since that might cause problems with other libraries that are ios-specific and uses the other locale.

  19. added
    needs-further-triage
    and removed
    needs-author-action
    on Jul 14, 2026
  20. added a commit that references this issue on Jul 20, 2026
    840cea3
  21. locked and limited conversation to collaborators on Aug 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area-System.Globalizationneeds-further-triageos-ios

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions