Windows Support Number

  • Subscribe to our RSS feed.
  • Twitter
  • StumbleUpon
  • Reddit
  • Facebook
  • Digg

Saturday, 3 September 2011

Supported cultures in Windows Phone 7 and showing currency symbols

Posted on 09:39 by Unknown
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
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Posted in WP7 Cultures C# | No comments
Newer Post Older Post Home

0 comments:

Post a Comment

Subscribe to: Post Comments (Atom)

Popular Posts

  • Unit testing Rx methods Timeout & Retry with moq
    Earlier this week I was trying to unit test an asynchronous service (Foo) which used another asynchronous service (Bar) internally and ran i...
  • Understanding RefCount in Reactive Extensions
    A couple of weeks ago  @LordHanson  & I ran into an issue converting a stateless async service exposed as an Rx cold observable to a  co...
  • StructureMap: ILifecycle
    The other day I wanted to control the scope of a service inside a web based app with semantics which didn't fit either 'HttpContextS...
  • MVVM anti-pattern: Injecting the IoC container into a View Model
    This is another anti-pattern I've seen a lot recently, the dynamic use of the IoC container inside a view model to resolve child view mo...
  • How many pins can Bing Maps handle in a WP7 app - part 1
    part2 -  http://awkwardcoder.blogspot.com/2011/10/how-many-pins-can-bing-maps-handle-in.html part3 -  http://awkwardcoder.blogspot.com/2011/...
  • Bad developers love 'The Daily WTF'
    When 'The Daily WTF' started up back in 2003/2004 it was a great laugh looking at shocking code other developers wrote, but after a ...
  • Using CompositeDisposable in base classes
    To help make an object eligible for collection by the GC (garbage collector) one would implement the IDisposable interface. Executing the di...
  • 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 whil...
  • Daily Dilbert Service - the most important service I've ever written...
    NuGet package available here ... First off a big shout to  @hamish  &  @leeoades  on this one - I'm just blogging about it. At work ...
  • Comparing performance of .Net 4.5 to .Net 4.0 for WPF
    Currently I'm working on a .Net 4.0 WPF app and we've had some discussion about moving to .Net 4.5, we don't get to make the dec...

Categories

  • .Net
  • .Net 4.5
  • Abstractions
  • Advertising
  • Agile
  • Agile Courage
  • AOP
  • Async
  • automated testing
  • Azure
  • Azure IIS RESTful development
  • BDD
  • Bing Maps
  • Bounded Context
  • C#
  • C# 5.0
  • Caching
  • Chocolatey
  • CLoud
  • CodePlex
  • Coding
  • Coding Building CI Testing
  • Coding C#
  • coding C# IoC StructureMap
  • Coding Functional-Programming
  • Coding REST Knowledge
  • Coding Services
  • Coding TDD Refactoring Agile
  • Command
  • continuous testing
  • coupling
  • CultureInfo
  • DAL
  • databases
  • DDD
  • DDD Coaching
  • DDD Domain Events Auditing nHibernate
  • DDD Entities Value Objects
  • Debugging
  • Design Patterns
  • Design Patterns Databases Auditing
  • Developement
  • Development
  • Development Coding
  • Development Process
  • Development unit testing
  • Development VS 2011
  • Diagnostics
  • Disposable
  • Exceptions
  • FINDaPAD
  • FindaPad Property Rental Windows Phone 7 Mobile Devices
  • Fun Coding Duct-Tape
  • Hotfixes
  • integration testing
  • IoC
  • jasmine
  • javascript
  • Jobs Development
  • LINQ
  • marketplace
  • Mobile Devices
  • Mocking
  • MSDN Coding
  • MSpec
  • Multilingual
  • MVC
  • MVVM
  • nCrunch
  • nHbiernate Repository Pattern Criteria
  • nHibernate Auditing Design Fluent
  • nHibnerate Entities Events Listeners
  • node.js
  • nodes.js
  • Nokia
  • NoSQL RavenDB Azure Development
  • Observations
  • OO
  • ORM
  • Performance
  • Portable Class Library
  • Portable Library
  • PostSharp
  • Process
  • Rants
  • RavenDB IIS 7.5 Development
  • Reactive
  • Reactive Extension
  • Reactive Extensions
  • ReadOnlyCollections
  • Resharper
  • REST Distributed-Systems
  • REST HTTP
  • rest web
  • RESTful
  • Rx
  • Serialization
  • Silverlight
  • Silverlight Installation
  • Task
  • TDD
  • TDD IoC DI
  • TDD Mocking
  • TDD Team Observation
  • Telerik
  • testing
  • threading
  • TPL
  • UI
  • Undo-Redo
  • unit testing
  • ViewModels
  • VS 2012
  • wcf
  • web api
  • Web Services
  • web services mobile devices data
  • WebAPI
  • Windows
  • Windows 8
  • windows phone
  • Windows Phone 7
  • WP7
  • WP7 Bing Maps Development Network HTTP
  • WP7 Bing Maps Development UK Crime
  • WP7 Bing Maps Development UK Crime Clustering
  • WP7 Bing Maps Development UK Polygons Clustering Performance
  • WP7 cryptography bouncy castle
  • WP7 Cultures C#
  • WP7 feedback development app store
  • WP7 Javascript web browser
  • WP7 MSBuild
  • WP7 ORM Databases performance
  • WP7 Serialisation
  • WP7 SilverlightSerializer C#
  • WP7 sqlite performance development
  • WP7 WP7Contrib Bing Maps Development
  • WP7 WP7Contrib Bing Maps Polygon Development
  • WP7 WP7Contrib CodePlex
  • WP7 WP7Contrib CodePlex Bing Maps Development
  • WP7 WP7Contrib CodePlex ObservableCollection
  • WP7 WP7Contrib ILMerge .Net
  • WP7 WP7Contrib Phone Maps
  • WP7 WP7Contrib SilverlightSerializer C#
  • WP7Contrib
  • WP7Contrib Bing Maps WP7
  • WP7Contrib WP7 Geo-Location development C#
  • WP7Contrib WP7 HTTP Compression
  • WP7Contrib WP7 Url Development Rx
  • WP7Dev
  • WPF
  • WPF Cultures
  • WuApi
  • XAML

Blog Archive

  • ►  2013 (16)
    • ►  November (5)
    • ►  September (3)
    • ►  August (1)
    • ►  July (1)
    • ►  June (3)
    • ►  May (2)
    • ►  January (1)
  • ►  2012 (44)
    • ►  November (2)
    • ►  October (8)
    • ►  September (5)
    • ►  August (2)
    • ►  July (4)
    • ►  June (3)
    • ►  May (1)
    • ►  April (2)
    • ►  March (13)
    • ►  February (4)
  • ▼  2011 (52)
    • ►  December (3)
    • ►  November (5)
    • ►  October (7)
    • ▼  September (7)
      • WP7Contrib: Criterion Factory - calculating a Route
      • Geo-location on WP7 - don't trust the first value ...
      • How many pins can Bing Maps handle in a WP7 app - ...
      • Attaching multiple sqlite databases in WP7
      • Using a simple ORM with sqlite on WP7
      • Supported cultures in Windows Phone 7 and showing ...
      • WP7Contrib: Criterion Factory - Location by address
    • ►  August (11)
    • ►  July (4)
    • ►  May (2)
    • ►  April (1)
    • ►  March (5)
    • ►  February (3)
    • ►  January (4)
  • ►  2010 (1)
    • ►  August (1)
  • ►  2009 (32)
    • ►  December (3)
    • ►  November (7)
    • ►  October (6)
    • ►  September (11)
    • ►  April (1)
    • ►  March (4)
Powered by Blogger.

About Me

Unknown
View my complete profile