Skip to main content

Supported cultures in Windows Phone 7 and showing currency symbols

I'm working on an application which has an UK English culture ('en-GB'). This application has to display currency values using the correct locale for the country of origin for the data - basically even though the application is English  it has to display the Indian Rupees with the correct currency symbol and correct currency separators.

The application also supports other countries, the couple of screen shots shown below are for Italian & Brazilian, you can see the correct currency symbol & separators are being used:


My first attempt to set the correct culture for Indian data was to look up on MSDN for what Silverlight supported. So I believed using either 'hi-IN' or 'gu-IN' should provide what I wanted, but OH NO!

These two cultures aren't supported in WP7 and it will throw an exception if you try and create a CultureInfo class using theses culture names. I then tried to find a list somewhere of supported cultures on the platform. I found several articles on the net, the most promising was about the supported cultures in the App Store (here) and one about using PInvoke on Compact Framework which wouldn't work on the current platform (here).

I decided to generate my own list of supported cultures. I did this by taking the list provided for Silverlight and  attempting to create an instance of each (using a 7.1 (Mango) application), any that didn't throw an exception was a supported culture. The code below is how I generated the list and the list is contained at the bottom of the post.

The outcome is WP7 supports less than the desktop version of Silverlight, not really a surprise:

 Silverlight (desktop version) supports 204 cultures,
 Silverlight (WP7) supports 164 cultures.

private string[] cultureNames = {
    "", "af", "af-ZA", "sq", "sq-AL", "ar", "ar-DZ", "ar-BHar-EG", "ar-IQ", "ar-JO"
    , "ar-KW", "ar-LB", "ar-LY", "ar-MA", "ar-OM", "ar-QA", "ar-SA", "ar-SY",
    "ar-TN", "ar-AE", "ar-YE", "hy", "hy-AM", "az", "az-Cyrl-AZ", "az-Latn-AZ",
    "eu", "eu-ES", "be", "be-BY", "bg", "bg-BG", "ca", "ca-ES", "zh-HK", "zh-MO",
    "zh-CN", "zh-Hans", "zh-SG", "zh-TW", "zh-Hant", "hr", "hr-BA", "hr-HR", "cs",
    "cs-CZ", "da", "da-DK", "dv", "dv-MV", "nl", "nl-BE", "nl-NL", "en", "en-AU",
    "en-BZ", "en-CA", "en-029", "en-IE", "en-JM", "en-NZ", "en-", "en-ZA", "en-TT",
    "en-GB", "en-US", "en-ZW", "et", "et-EE", "fo", "fo-FO", "fa", "fa-IR", "fi",
    "fi-FI", "fr", "fr-BE", "fr-CA", "fr-FR", "fr-LU", "fr-MC", "fr-CH", "gl",
    "gl-ES", "ka", "ka-GE", "de", "de-AT", "de-DE", "de-DE_phoneb", "de-LI",
    "de-LU", "de-", "el", "el-GR", "gu", "gu-IN", "he", "he-IL", "hi", "hi-IN",
    "hu", "hu-HU", "is", "is-IS", "id", "id-ID", "it", "it-IT", "it-CH", "ja",
    "ja-JP", "kn", "kn-IN", "kk", "kk-KZ", "kok", "kok-IN", "ko", "ko-KR", "ky",
    "ky-KG", "lv", "lv-LV", "lt", "lt-LT", "mk", "mk-MK", "ms", "ms-BN", "ms-MY",
    "mr", "mr-IN", "mn", "mn-MN", "no", "nb-NO", "nn-NO", "pl", "pl-PL", "pt",
    "pt-BR", "pt-PT", "pa", "pa-IN", "ro", "ro-RO", "ru", "ru-RU", "sa", "sa-IN",
    "sr-Cyrl-CS", "sr-Latn-CS", "sk", "sk-SK", "sl", "sl-SI", "es", "es-AR",
    "es-BO", "es-CL", "es-CO", "es-CR", "es-DO", "es-EC", "es-SV", "es-GT", "es-HN"
    , "es-MX", "es-NI", "es-PA", "es-PY", "es-PE", "es-PR", "es-ES", "es-ES_tradnl"
    , "es-UY", "es-VE", "sw", "sw-KE", "sv", "sv-FI", "sv-SE", "syr", "syr-SY",
    "ta", "ta-IN", "tt", "tt-RU", "te", "te-IN", "th", "th-TH", "tr", "tr-TR", "uk"
    , "uk-UA", "ur", "ur-PK", "uz", "uz-Cyrl-UZ", "uz-Latn-UZ", "vi", "vi-VN"
};

private void button1_Click(object sender, System.Windows.RoutedEventArgs e)
{
    Debug.WriteLine("Culture names count - " + cultureNames.Count());

    var supportedCultures = cultureNames.Select(CreateCultureInfo).Where(culture => culture != null);

    Debug.WriteLine("Supported names count - " + supportedCultures.Count());

    foreach (var supportedCulture in supportedCultures)
    {
        Debug.WriteLine("'{0}','{1}','{2}'", supportedCulture.Name, supportedCulture.DisplayName,supportedCulture.NativeName);
    }
}

private CultureInfo CreateCultureInfo(string cultureName)
{
    try
    {
        return new CultureInfo(cultureName);
    }
    catch (Exception)
    {
        return null;
    }
}

From the supported list I had a couple of new ones to try - 'in' & 'gu'. I didn't think these would work but I gave them ago. I was proved correct, both didn't have any usable properties on the instances of the  NumberFormatInfo class.


Finally I decided to try the default font for the platform - Segoe WP, or Segoe Windows Phone. A quick search for "Segoe Rupee" brought up this. Not exactly pointing to WP7 but it was a start. A quick test was in order with a 71, (Mango) application:


Bingo!

As you can see the correct Indian Rupee symbol being displayed. All I had to do now was re-factor how we deal with Indian culture requirements for currency. I had to create our own NumberFormatInfo instance with the correct symbol. Below are screen shots from my attempt to get the Rupee symbol displaying on both a 7.0 & 7.1 devices. As expected the 7.1 device handled the unicode (U+20B9) character perfectly fine, but the 7.0 wasn't able to display the required character - see 7.0 (initial). We decided to actually write the text 'Rupee' for 7.0 devices.

You can find out more about the lanaguage support for 7.1 here.


To support this scenario is very easy, all we have to do is check the current OS version for the application and act accordingly. We only need to set the CurrencySymbol property so setting a culture for India for this app was easy, but I am aware there are multiple possible languages to support for such a large country. If this had been the case we would have had to be more fine-grain with our definition for the culture.


And that covers off how we are dealing with showing currency information in our application.


As I said, here is the list of supported cultures on the WP7 platform, this was generated with a Mango 7.1 application in the emulator.




Invariant Language


Invariant Language (Invariant Country)


af


Afrikaans


Afrikaans


af-ZA


Afrikaans


Afrikaans (Suid Afrika)


sq


Albanian


shqipe


sq-AL


Albanian


shqipe (Shqipëria)


ar



العربية


hy



Հայերեն


az


Azeri (Latin)


Azərbaycan­ılı


az-Cyrl-AZ


Azeri (Cyrillic)


Азәрбајҹан
(Азәрбајҹан)


az-Latn-AZ


Azeri (Latin)


Azərbaycan­ılı (Azərbaycanca)


eu


Basque


euskara


eu-ES


Basque


euskara (euskara)


be


Belarusian


Беларускі


be-BY


Belarusian


Беларускі (Беларусь)


bg


Bulgarian


български


bg-BG


Bulgarian


български (България)


ca


Catalan


català


ca-ES


Catalan


català (català)


zh-HK


Chinese (Hong Kong S.A.R.)


中文(香港特别行政區)


zh-MO


Chinese (Macao S.A.R.)


中文(澳門特别行政區)


zh-CN


Chinese (PRC)


中文(中华人民共和国)


zh-SG


Chinese (Singapore)


中文(新加坡)


zh-TW


Chinese (Taiwan)


中文(繁體) (台灣)


hr


Croatian


hrvatski


hr-HR


Croatian


hrvatski (Hrvatska)


cs


Czech


čeština


cs-CZ


Czech


čeština (Česká republika)


da


Danish


dansk


da-DK


Danish


dansk (Danmark)


nl


Dutch (Netherlands)


Nederlands


nl-BE


Dutch (Belgium)


Nederlands (België)


nl-NL


Dutch (Netherlands)


Nederlands (Nederland)


en


English (United States)


English


en-AU


English (Australia)


English (Australia)


en-BZ


English (Belize)


English (Belize)


en-CA


English (Canada)


English (Canada)


en-029


English (Caribbean)


English (Caribbean)


en-IE


English (Ireland)


English (Eire)


en-JM


English (Jamaica)


English (Jamaica)


en-NZ


English (New Zealand)


English (New Zealand)


en-ZA


English (South Africa)


English (South Africa)


en-TT


English (Trinidad and Tobago)


English (Trinidad y Tobago)


en-GB


English (United Kingdom)


English (United Kingdom)


en-US


English (United States)


English (United States)


en-ZW


English (Zimbabwe)


English (Zimbabwe)


et


Estonian


eesti


et-EE


Estonian


eesti (Eesti)


fo


Faroese


føroyskt


fo-FO


Faroese


føroyskt (Føroyar)


fa



فارسى


fi


Finnish


suomi


fi-FI


Finnish


suomi (Suomi)


fr


French (France)


français


fr-BE


French (Belgium)


français (Belgique)


fr-CA


French (Canada)


français (Canada)


fr-FR


French (France)


français (France)


fr-LU


French (Luxembourg)


français (Luxembourg)


fr-MC


French (Principality of Monaco)


français (Principauté de Monaco)


fr-CH


French (Switzerland)


français (Suisse)


gl


Galician


galego


gl-ES


Galician


galego (galego)


ka



ქართული


de


German (Germany)


Deutsch


de-AT


German (Austria)


Deutsch (Österreich)


de-DE


German (Germany)


Deutsch (Deutschland)


de-DE


German (Germany)


Deutsch (Deutschland)


de-LI


German (Liechtenstein)


Deutsch (Liechtenstein)


de-LU


German (Luxembourg)


Deutsch (Luxemburg)


el


Greek


ελληνικά


el-GR


Greek


ελληνικά (Ελλάδα)


gu



ગુજરાતી


he



עברית


hi



हिंदी


hu


Hungarian


magyar


hu-HU


Hungarian


magyar (Magyarország)


is


Icelandic


íslenska


is-IS


Icelandic


íslenska (Ísland)


id


Indonesian


Bahasa Indonesia


id-ID


Indonesian


Bahasa Indonesia (Indonesia)


it


Italian (Italy)


italiano


it-IT


Italian (Italy)


italiano (Italia)


it-CH


Italian (Switzerland)


italiano (Svizzera)


ja


Japanese


日本語


ja-JP


Japanese


日本語 (日本)


kn



ಕನ್ನಡ


kk



Қазащb


kok



कोंकणी


ko


Korean


한국어


ko-KR


Korean


한국어 (대한민국)


ky


Kyrgyz


Кыргыз


ky-KG


Kyrgyz


Кыргыз (Кыргызстан)


lv


Latvian


latviešu


lv-LV


Latvian


latviešu (Latvija)


lt


Lithuanian


lietuvių


lt-LT


Lithuanian


lietuvių (Lietuva)


mk


Macedonian (FYROM)


македонски јазик


mk-MK


Macedonian (FYROM)


македонски јазик
(Македонија)


ms


Malay (Malaysia)


Bahasa Malaysia


ms-BN


Malay (Brunei Darussalam)


Bahasa Malaysia (Brunei Darussalam)


ms-MY


Malay (Malaysia)


Bahasa Malaysia (Malaysia)


mr



मराठी


mn


Mongolian (Cyrillic)


Монгол хэл


mn-MN


Mongolian (Cyrillic)


Монгол хэл (Монгол улс)


no


Norwegian (Bokmål)


norsk


nb-NO


Norwegian (Bokmål)


norsk


bokmål (Norge)




nn-NO


Norwegian (Nynorsk)


norsk


nynorsk (Noreg)




pl


Polish


polski


pl-PL


Polish


polski (Polska)


pt


Portuguese (Brazil)


Português


pt-BR


Portuguese (Brazil)


Português (Brasil)


pt-PT


Portuguese (Portugal)


português (Portugal)


pa



ਪੰਜਾਬੀ


ro


Romanian


română


ro-RO


Romanian


română (România)


ru


Russian


русский


ru-RU


Russian


русский (Россия)


sa



संस्कृत


sr-Cyrl-CS


Serbian (Cyrillic


Serbia and Montenegro (Former))


српски (Србија)




sr-Latn-CS


Serbian (Latin


Serbia and Montenegro (Former))


srpski (Srbija)




sk


Slovak


slovenčina


sk-SK


Slovak


slovenčina (Slovenská republika)


sl


Slovenian


slovenski


sl-SI


Slovenian


slovenski (Slovenija)


es


Spanish (Spain - Traditional Sort)


español


es-AR


Spanish (Argentina)


Español (Argentina)


es-BO


Spanish (Bolivia)


Español (Bolivia)


es-CL


Spanish (Chile)


Español (Chile)


es-CO


Spanish (Colombia)


Español (Colombia)


es-CR


Spanish (Costa Rica)


Español (Costa Rica)


es-DO


Spanish (Dominican Republic)


Español (República Dominicana)


es-EC


Spanish (Ecuador)


Español (Ecuador)


es-SV


Spanish (El Salvador)


Español (El Salvador)


es-GT


Spanish (Guatemala)


Español (Guatemala)


es-HN


Spanish (Honduras)


Español (Honduras)


es-MX


Spanish (Mexico)


Español (México)


es-NI


Spanish (Nicaragua)


Español (Nicaragua)


es-PA


Spanish (Panama)


Español (Panamá)


es-PY


Spanish (Paraguay)


Español (Paraguay)


es-PE


Spanish (Peru)


Español (Perú)


es-PR


Spanish (Puerto Rico)


Español (Puerto Rico)


es-ES


Spanish (Spain - International Sort)


español (España)


es-ES


Spanish (Spain - Traditional Sort)


español (España)


es-UY


Spanish (Uruguay)


Español (Uruguay)


es-VE


Spanish (Bolivarian Republic of Venezuela)


Español (Republica Bolivariana de Venezuela)


sw


Kiswahili


Kiswahili


sw-KE


Kiswahili


Kiswahili (Kenya)


sv


Swedish (Sweden)


svenska


sv-FI


Swedish (Finland)


svenska (Finland)


sv-SE


Swedish (Sweden)


svenska (Sverige)


syr



ܣܘܪܝܝܐ


ta



தமிழ்


tt


Tatar


Татар


tt-RU


Tatar


Татар (Россия)


te



తెలుగు


th



ไทย


tr


Turkish


Türkçe


tr-TR


Turkish


Türkçe (Türkiye)


uk


Ukrainian


україньска


uk-UA


Ukrainian


україньска (Україна)


ur



اُردو


uz


Uzbek (Latin)


Uzbek


uz-Cyrl-UZ


Uzbek (Cyrillic)


Ўзбек (Ўзбекистон)


uz-Latn-UZ


Uzbek (Latin)


Uzbek (Uzbekiston Respublikasi)


vi



Tiếng Việt

Comments

  1. It seems that there is such "en-IN" culture that is supported by WP7.1 and it formats the currency with rupee symbol.

    I.e. the code:
    CultureInfo culture = new CultureInfo("en-IN");
    string currency = string.Format(culture, "{0}, {1:C}", culture.Name, 123.45);

    creates following string:
    en-IN, ₹ 123.45

    ReplyDelete
  2. It appears this was added for the RTM version of 7.1.

    Thanks for the info.

    ReplyDelete

Post a Comment

Popular posts from this blog

WPF tips & tricks: Dispatcher thread performance

Not blogged for an age, and I received an email last week which provoked me back to life. It was a job spec for a WPF contract where they want help sorting out the performance of their app especially around grids and tabular data. I thought I'd shared some tips & tricks I've picked up along the way, these aren't probably going to solve any issues you might be having directly, but they might point you in the right direction when trying to find and resolve performance issues with a WPF app. First off, performance is something you shouldn't try and improve without evidence, and this means having evidence proving you've improved the performance - before & after metrics for example. Without this you're basically pissing into the wind, which can be fun from a developer point of view but bad for a project :) So, what do I mean by ' Dispatcher thread performance '? The 'dispatcher thread' or the 'UI thread' is probably the most

Showing a message box from a ViewModel in MVVM

I was doing a code review with a client last week for a WPF app using MVVM and they asked ' How can I show a message from the ViewModel? '. What follows is how I would (and have) solved the problem in the past. When I hear the words ' show a message... ' I instantly think you mean show a transient modal message box that requires the user input before continuing ' with something else ' - once the user has interacted with the message box it will disappear. The following solution only applies to this scenario. The first solution is the easiest but is very wrong from a separation perspective. It violates the ideas behind the Model-View-Controller pattern because it places View concerns inside the ViewModel - the ViewModel now knows about the type of the View and specifically it knows how to show a message box window: The second approach addresses this concern by introducing the idea of messaging\events between the ViewModel and the View. In the example below

Implementing a busy indicator using a visual overlay in MVVM

This is a technique we use at work to lock the UI whilst some long running process is happening - preventing the user clicking on stuff whilst it's retrieving or rendering data. Now we could have done this by launching a child dialog window but that feels rather out of date and clumsy, we wanted a more modern pattern similar to the way <div> overlays are done on the web. Imagine we have the following simple WPF app and when 'Click' is pressed a busy waiting overlay is shown for the duration entered into the text box. What I'm interested in here is not the actual UI element of the busy indicator but how I go about getting this to show & hide from when using MVVM. The actual UI elements are the standard Busy Indicator coming from the WPF Toolkit : The XAML behind this window is very simple, the important part is the ViewHost. As you can see the ViewHost uses a ContentPresenter element which is bound to the view model, IMainViewModel, it contains 3 child v