Bugzilla – Bug 6599
NSLocale.DisplayNameForKey missing in MonoTouch
Last modified: 2012-08-31 16:28:34 EDT
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
Not sure that's supported. E.g.
NSLocale en = new NSLocale ("en-US");
Console.WriteLine (en.CurrencySymbol ?? "null");
Console.WriteLine (en.GetCurrencySymbolDisplayName (en.CurrencySymbol) ??
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
new NSLocale ("en-US").CurrencyCode == "USD"
`displayNameForKey` is not the same (but it do share some constants with
Not currency code, currency display name. The output should be "US Dollars"
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
QA: unit tests added in master