This is Xamarin's bug tracking system. For product support, please use the support links listed in your Xamarin Account.
Bug 6599 - NSLocale.DisplayNameForKey missing in MonoTouch
: NSLocale.DisplayNameForKey missing in MonoTouch
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS / monotouch
: 5.2
: PC Mac OS
: --- normal
: Untriaged
Assigned To: Sebastien Pouliot
  Show dependency treegraph
Reported: 2012-08-18 17:53 EDT by Bryan Moulton
Modified: 2012-08-31 16:28 EDT (History)
2 users (show)

See Also:


Description Bryan Moulton 2012-08-18 17:53:35 EDT
The DisplayNameForKey function is missing from NSLocale, and isn't anywhere to
be found in the MonoTouch documentation.
Comment 1 Sebastien Pouliot 2012-08-19 19:11:10 EDT
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:

* GetIdentifierDisplayName
* GetLanguageCodeDisplayName
* GetCountryCodeDisplayName

which in turns calls the (internal) DisplayNameForKey with the right constant.
Comment 2 Bryan Moulton 2012-08-22 13:25:10 EDT
A customer is trying to use NSLocaleCurrencyCode. Would it be possible to add a
GetCurrencyDisplayName function?
Comment 3 Sebastien Pouliot 2012-08-22 16:05:19 EDT
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 ?
Comment 5 Sebastien Pouliot 2012-08-31 15:09:37 EDT
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
Comment 6 Bryan Moulton 2012-08-31 15:18:02 EDT
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!
Comment 7 Sebastien Pouliot 2012-08-31 16:26:34 EDT
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.
Comment 8 Sebastien Pouliot 2012-08-31 16:28:34 EDT
Other constants returns null (or errors) so only GetCurrencyCodeDisplayName was

Fixed in 
master: 0625bb5611557362c19d9aff0d218d8f20862695
monotouch-5.4-series: 9ba3998148c32679a142e2a6a106b66510c12a8e

QA: unit tests added in master

Note You need to log in before you can comment on or make changes to this bug.