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

Getting No Names in regioninfo class on IOS #70028

Closed
rolfbjarne opened this issue May 31, 2022 · 25 comments
Closed

Getting No Names in regioninfo class on IOS #70028

rolfbjarne opened this issue May 31, 2022 · 25 comments
Assignees
Labels
area-System.Globalization enhancement Product code improvement that does NOT require public API changes/additions os-ios Apple iOS
Milestone

Comments

@rolfbjarne
Copy link
Member

From @whann0205 on Tue, 31 May 2022 11:59:45 GMT

Dont know if this is the correct place to report that question.
If not please be so kind and direct me to the correct forum or
forward my issue to them.

Environment:
Win10
Visual Studio 2022 Preview lastest revision all updates installed
Net Maui lastest revision all updates installed
MacOS Monterrey on MacBook Air M1
Visual Studio 2022 Preview lastest revision all updates installed
Net Maui lastest revision all updates installed
Attached you find a screenshot what happens when i debug the application
on an android target (works ok)
and a screenshot from the same workstation targetting
the macbook´s simulator.
Have updated Xamarin IOS to the latest version
as was suggested by the macbooks´s visual studio
check for updates dialog.

Problem is clear to see i dont get any country names only the 3letter or 2letter code.

Android
IOS

Copied from original issue xamarin/xamarin-macios#15159

@rolfbjarne
Copy link
Member Author

From @rolfbjarne on Tue, 31 May 2022 13:09:07 GMT

This might be related to #68321 or #69492.

@rolfbjarne
Copy link
Member Author

From @rolfbjarne on Tue, 31 May 2022 16:37:18 GMT

Sample code:

var regions = CultureInfo.GetCultures (CultureTypes.SpecificCultures)
	.Select (culture => new RegionInfo (culture.Name))
	.OrderBy (v => v.ThreeLetterISORegionName);
foreach (var r in regions) {
	Console.WriteLine ($"{r.ThreeLetterISORegionName} {r.NativeName} {r.Name} {r.EnglishName} {r.DisplayName}");
}

With iOS (both simulator and device) and Mac Catalyst, I get this:

 001 001 001 001
 150 150 150 150
 419 419 419 419
ABW AW AW AW AW
AIA AI AI AI AI
ALA AX AX AX AX
AND AD AD AD AD
ARE AE AE AE AE
ASM AS AS AS AS
ATG AG AG AG AG
AUS AU AU AU AU
AUT AT AT AT AT
...

on macOS, I get:

 العالم 001 world العالم
 world 001 world world
 Europe 150 Europe Europe
 Mondo 001 world Mondo
 América del Norte 003 North America América del Norte
 Latinoamérica 419 Latin America Latinoamérica
 Mundo 001 world Mundo
 world 001 world world
 world 001 world world
 וועלט 001 world וועלט
ABW Aruba AW Aruba Aruba
AFG افغانستان AF Afghanistan افغانستان
AFG افغانستان AF Afghanistan افغانستان
AFG افغانستان AF Afghanistan افغانستان
AGO Angóla AO Angola Angóla
AGO Angola AO Angola Angola
AIA Anguilla AI Anguilla Anguilla
ALA Åland AX Åland Islands Åland
...

Looks like it could be a difference between Mono and CoreCLR, so I'm moving to dotnet/runtime.

@ghost ghost added the untriaged New issue has not been triaged by the area owner label May 31, 2022
@dotnet-issue-labeler
Copy link

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

@rolfbjarne
Copy link
Member Author

CC @steveisok

@filipnavara
Copy link
Member

filipnavara commented May 31, 2022

IIRC It is a difference between how the ICU data are trimmed on mobile and desktop (where it comes from untrimmed system data, usually). It is possible to switch to a different ICU data file through _GlobalizationDataFile .csproj property but I don't think .NET ships an untrimmed one.

@steveisok
Copy link
Member

Yeah, we trimmed a great deal with WASM initially and carried it forward into iOS.

@rolfbjarne we could explore shipping an uncompressed data file that would need to be opted into. Thoughts?

@ghost
Copy link

ghost commented May 31, 2022

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

Issue Details

From @whann0205 on Tue, 31 May 2022 11:59:45 GMT

Dont know if this is the correct place to report that question.
If not please be so kind and direct me to the correct forum or
forward my issue to them.

Environment:
Win10
Visual Studio 2022 Preview lastest revision all updates installed
Net Maui lastest revision all updates installed
MacOS Monterrey on MacBook Air M1
Visual Studio 2022 Preview lastest revision all updates installed
Net Maui lastest revision all updates installed
Attached you find a screenshot what happens when i debug the application
on an android target (works ok)
and a screenshot from the same workstation targetting
the macbook´s simulator.
Have updated Xamarin IOS to the latest version
as was suggested by the macbooks´s visual studio
check for updates dialog.

Problem is clear to see i dont get any country names only the 3letter or 2letter code.

Android
IOS

Copied from original issue xamarin/xamarin-macios#15159

Author: rolfbjarne
Assignees: -
Labels:

area-System.Globalization, untriaged

Milestone: -

@steveisok steveisok added the os-ios Apple iOS label May 31, 2022
@ghost
Copy link

ghost commented May 31, 2022

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

Issue Details

From @whann0205 on Tue, 31 May 2022 11:59:45 GMT

Dont know if this is the correct place to report that question.
If not please be so kind and direct me to the correct forum or
forward my issue to them.

Environment:
Win10
Visual Studio 2022 Preview lastest revision all updates installed
Net Maui lastest revision all updates installed
MacOS Monterrey on MacBook Air M1
Visual Studio 2022 Preview lastest revision all updates installed
Net Maui lastest revision all updates installed
Attached you find a screenshot what happens when i debug the application
on an android target (works ok)
and a screenshot from the same workstation targetting
the macbook´s simulator.
Have updated Xamarin IOS to the latest version
as was suggested by the macbooks´s visual studio
check for updates dialog.

Problem is clear to see i dont get any country names only the 3letter or 2letter code.

Android
IOS

Copied from original issue xamarin/xamarin-macios#15159

Author: rolfbjarne
Assignees: -
Labels:

area-System.Globalization, untriaged, os-ios

Milestone: -

@steveisok steveisok added enhancement Product code improvement that does NOT require public API changes/additions and removed untriaged New issue has not been triaged by the area owner labels May 31, 2022
@filipnavara
Copy link
Member

we could explore shipping an uncompressed data file that would need to be opted into

That's one option, which was to some extent discussed at dotnet/designs#225. Other option is augmenting with system data through the iOS APIs (likely NSLocale localizedStringForLocaleIdentifier in this case).

@tarekgh tarekgh added this to the Future milestone May 31, 2022
@tarekgh
Copy link
Member

tarekgh commented May 31, 2022

@steveisok I marked this for future but feel free to move it back to .NET 7.0 as needed.

@steveisok
Copy link
Member

steveisok commented May 31, 2022

Thanks for refreshing my memory on the design dock ;-).

Hmm - augmenting with the iOS API's does not seem to be that big of a task. We talked about doing this early in .NET 7 and I like it better than opting into something. My team may be able to pick this up.

@whann0205
Copy link

Sorry to interrupt your "future" discussion, but may i ask what can i do now
to get that working again? It worked in older versions of net6.

@Eilon
Copy link
Member

Eilon commented Jun 16, 2022

@whann0205 I think that a workaround for now would be to have your own map of culture identifiers to culture names and not rely on the built-in ones.

Something like this:

private static readonly IDictionary<string, string> CultureNameLookup = new()
{
    { "en-us", "English (US)" },
    { "de-de", "German" },
    // ...
};

I know it isn't ideal, but you could generate this list from any working platform (e.g. .NET Core on Windows) and then paste the code into your app to run everywhere. Or, if your app only supports a limited set of cultures (say, less than 10), writing it manually should only take a few minutes.

Would this work for your app until it's fixed in .NET?

@whann0205
Copy link

Thanks for you suggestion.
It would help to know how long we have to wait get this fixed.
Since i have other things to do in the app, i can continue with
other things in the meantime.
Would also help to understand why it stopped working to identify
the source of the problem and perhabs get to know if other functions
are affected.

@tipa
Copy link

tipa commented Aug 15, 2022

@whann0205 I think that a workaround for now would be to have your own map of culture identifiers to culture names and not rely on the built-in ones.

Something like this:

private static readonly IDictionary<string, string> CultureNameLookup = new()
{
    { "en-us", "English (US)" },
    { "de-de", "German" },
    // ...
};

I know it isn't ideal, but you could generate this list from any working platform (e.g. .NET Core on Windows) and then paste the code into your app to run everywhere. Or, if your app only supports a limited set of cultures (say, less than 10), writing it manually should only take a few minutes.

Would this work for your app until it's fixed in .NET?

I was hitting this problem today as well and that workaround isn't really satisfactory (at least for an iOS app) when you are supporting a lot of languages, because the DisplayName returns the localised name, not the English name. One would have to create that dictionary for every supported language.

I would appreciate if this could be fixed soon.

@whann0205
Copy link

Thanks for your interest. Now that 2 months have passed i tried again and it is sadly not
fixed. I doubt it will be fixed anytime soon.

In my case by using:
var region = CultureInfo.GetCultures(CultureTypes.SpecificCultures)
.Where(C => C.LCID != 127 & C.LCID != 4096 & !C.IsNeutralCulture)
.Select(x => new RegionInfo(x.LCID));

You dont even get the localised Name but only the 2 letter iso code for the country in the field english
name and nativename. But only under IOS, for Android regardless of which version it is working correctly.
As i learned somebody at MS must "pick that up".

See #70028 (comment)

Have not found a way except writing here to get somebody to "pick that up".
Would highly appreciate if one can help here, too

@Cheesebaron
Copy link

Anything happening here? Just ran into this today.

@whann0205
Copy link

It is still not fixed. Have not received any info that somebody working on it.
I suggest you find a workaround.

@steveisok
Copy link
Member

We are planning on addressing this during the .net 8 timeframe. Most likely we'll call into the native api's as opposed to relying on our icu library exclusively.

@whann0205
Copy link

thanks steve.
But as i said a workaround is needed since .net 8 will be next year ...

@steveisok
Copy link
Member

thanks steve. But as i said a workaround is needed since .net 8 will be next year ...

We'll look to see how straightforward this is to fix by itself and if it's easy, get something out.

@Eilon
Copy link
Member

Eilon commented Nov 23, 2022

For what it's worth, I wrote a small tool that generates the culture data locally: https://gist.github.com/Eilon/ed9c7503b0a270fac2a94d4e0f2c42d9

You can run the tool to generated a new list, as well as show how to use an already-generated list I created on my machine. The output looks like this:

Wrote 593 rows of culture data to C:\Users\elipton\source\repos\GetCultureInfoApp\GetCultureInfoApp\bin\Debug\net7.0\rawculturedata.txt.

Found 1 data items that match ABW
        ABW, Aruba, AW, Aruba, Aruba
Found 6 data items that match FIN
        FIN, Finland, FI, Finland, Finland
        FIN, Suomi, FI, Finland, Suomi
        FIN, Suopma, FI, Finland, Suopma
        FIN, Suomâ, FI, Finland, Suomâ
        FIN, Finland, FI, Finland, Finland
        FIN, Finland, FI, Finland, Finland
Found 1 data items that match MEX
        MEX, México, MX, Mexico, México

For anyone blocked by the limitation on some devices, you should be able to copy the culture data list from my sample code into your app, and then use LINQ to query whatever data you need.

Hopefully this helps anyone who urgently needs this.

@steveisok
Copy link
Member

@mkhamoyan when you have a chance, can you please see if hybrid globalization fixes this issue?

@Kebechet
Copy link

hopefully this will be successfully shipped in .NET 8

@mkhamoyan
Copy link
Contributor

@mkhamoyan when you have a chance, can you please see if hybrid globalization fixes this issue?

Yes this will work on hybrid globalization mode.
Implemented by #81470 and #83514

@ghost ghost locked as resolved and limited conversation to collaborators Aug 31, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Globalization enhancement Product code improvement that does NOT require public API changes/additions os-ios Apple iOS
Projects
None yet
Development

No branches or pull requests

10 participants