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
Summary: NSLocale.DisplayNameForKey missing in MonoTouch
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll (show other bugs)
Version: 5.2
Hardware: PC Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Sebastien Pouliot
Depends on:
Reported: 2012-08-18 17:53 UTC by Bryan Moulton
Modified: 2012-08-31 16:28 UTC (History)
2 users (show)

See Also:
Is this bug a regression?: ---
Last known good build:


Description Bryan Moulton 2012-08-18 17:53:35 UTC
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 UTC
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 UTC
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 UTC
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 ?
Comment 5 Sebastien Pouliot 2012-08-31 15:09:37 UTC
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).
Comment 6 Bryan Moulton 2012-08-31 15:18:02 UTC
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!
Comment 7 Sebastien Pouliot 2012-08-31 16:26:34 UTC
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 UTC
Other constants returns null (or errors) so only GetCurrencyCodeDisplayName was added.

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.