The DisplayNameForKey function is missing from NSLocale, and isn't anywhere to be found in the MonoTouch documentation.
DisplayNameForKey is available but the method itself is internal. This happens when better, more .net-ish, API are provided (e.g. to avoid dealing with NSString constants the too comon typos when using them).
So the replace it NSLocale provides a few methods such as:
which in turns calls the (internal) DisplayNameForKey with the right constant.
A customer is trying to use NSLocaleCurrencyCode. Would it be possible to add a GetCurrencyDisplayName function?
Not sure that's supported. E.g.
NSLocale en = new NSLocale ("en-US");
Console.WriteLine (en.CurrencySymbol ?? "null");
Console.WriteLine (en.GetCurrencySymbolDisplayName (en.CurrencySymbol) ?? "null");
Can you elaborate on what's required ?
The customer is trying to get the display name for a country's currency:
The stackoverflow question (and answer) is about the current code "USD", not display name (which would be, I guess, "US dollar", but that's not something the API returns AFAIK).
SO's answer uses `objectForKey` which in MonoTouch is mapped to the NSLocale properties. So:
new NSLocale ("en-US").CurrencyCode == "USD"
`displayNameForKey` is not the same (but it do share some constants with objectForKey).
Not currency code, currency display name. The output should be "US Dollars" hence:
usd = [locale displayNameForKey:NSLocaleCurrencyCode value:@"USD"];
I referenced the wrong example there, sorry!
Ah, get you now :-) I made a CurrencySymbol vs CurrencyCode mistake in comment #3 - but you're right this one (and maybe others) do have a DisplayName.
Other constants returns null (or errors) so only GetCurrencyCodeDisplayName was added.
QA: unit tests added in master
Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on GitHub
to continue tracking issues. Bugzilla will remain available for
reference in read-only mode. We will continue to work on open Bugzilla
bugs, copy them to the new locations as needed for follow-up, and add
the new items under Related Links.
Create a new report for Bug 6599 on Developer
Community or GitHub if you have new information to add and do not yet see a matching
In special cases on GitHub you might also want the comments:
GitHub Markdown with public comments
Our sincere thanks to everyone who has contributed on this bug tracker
over the years. Thanks also for your understanding as we make these
adjustments and improvements for the future.