Skip to main content

Posts

Showing posts with the label CultureInfo

Testing when the culture changes in WPF

Recently I've do some work on a WPF app which required to support multiple languages in the UI - a spike to see how easy supporting multiple languages is in WPF, the test UI is shown below in English & French: The app is easy enough to understand - change the UI language and all the text based values are updated with the locale specific instances. I wanted to follow the standard pattern of using language specific resource files to store the translated text, these were placed in the standard location inside the project structure: One of the big advantages of using this mechanism is the resources are compiled into a class which can be used in your ViewModels and Views and this is why see above the 'Resource.resx' file - this contains the 'untranslated' resource strings etc: I've been aware for a long time there are 2 culturing settings per thread in .Net - Thread.CurrentCulture  & Thread.CurrentUICulture , the second is the one of interest here...

Be careful of the culture when using Bing Maps REST API

When developing the Bing Maps Wrapper service for the WP7Contrib we weren't aware of the importance of the instance of the CultureInfo class used to format the geo-coordinate data when building the URL parameters. This was for the simple reason, being based in the UK we were relying on the default culture, which happens to be 'en-US'  and this culture formats decimal numbers in the required format for calls to the Bing Maps REST API. The documentation on MSDN does state this, but does not make it very clear. Show below is the formatting for a couple of different cultures, what you'll see is the formatting for the Lat & Long for the Netherlands & Russian cultures is different to the rest. They both use commas as the decimal point. When the Lat & Long are used to format the URL parameter they need to be in InvariantCulture so that your URL looks like the following: If I force the Bing Maps Service to use the Netherlands culture with the code shown b...