Localization
The localization process seems extremely painful for a Brit who just wants to have his dates the right way round. Is there not a simple way to tell my app to respect the operating systems Regional and Language settings?
Thanks
Michael
The localization process seems extremely painful for a Brit who just wants to have his dates the right way round. Is there not a simple way to tell my app to respect the operating systems Regional and Language settings?
Thanks
Michael
If you are developing for a single language, you should not need to do any localization.
Where are you seeing the Dates shown backwards?
Thanks, Rob Relyea
Program Manager, WPF Team
http://rrelyea.spaces.live.com
Hi Rob,
I'm using the DatePicker from Kevin Moore's Bag-O-Tricks which calls Language.GetSpecificCulture() to do the date conversion.
When I start my app, System.Threading.Thread.CurrentThread.CurrentCulture is en-GB but CurrentUICulture is en-US.
Setting CurrentUICulture to en-GB did'nt have any effect. I've started going through the WPF Globalization and Localization Overview from the SDK and added <UICulture>en-GB</UICulture> and uncommented [assembly: NeutralResourcesLanguage("en-GB", UltimateResourceFallbackLocation.Satellite)] in AssemblyInfo.cs. Dates are still backwards so I presume the next step is to add UID properties.
Am I heading in the wrong direction?
Thanks
Michael
Hi Michael,
You are heading in the wrong direction here. Date formatting has nothing to do with localization. Things like dates and currency usually depend on user settings, such as User Locale (CurrentCulture) and language settings of the application itself (xml language).
The DatePicker sample is using xml:Lang attribute value to determine the date formatting. If no xml:Lang is set in the sample you need to set it yourself (ie xml:lang="en-GB").
If you want to use regional settings to determine the date format in your app you would need to change some date picker code to use CurrentCulture instead of Language.GetSepecificCulture().
-Alik
Thanks Alik, that makes sense. I've set xml:lang in my MainWindow.xaml and that seems to work well.
But...
Why does xml:lang not default to the User Locale CurrentCulture on app startup?
The SDK says Thead.CurrentUICulture is set with a call to GetUserDefaultUILanguage Win32 API so why does this report en-US? How do I set the default UILanguage for the operating system if not in Control Panel?
Thanks
Michael
xml:lang and CurrentCulture are not the same things. xml:lang allows you to set the language for a particular UI, such as a document. CurrentCulture is more of a global setting that controls the display of currency, dates, delimiters etc on your system.
The way the datepicker sample app is written is that it only looks at xml:lang when formatting the date and doesn't use the CurrentCulture. The default for xml:lang might be en-US. I agree that it would be much better for the sample to use CurrentCulture if xml:lang is not set.
UICulture controls the resource loading of the application. It determines what language specific assembly your resource will load from. You cannot set it through a Control Panel. It is controlled by localization of your operating system or can be overridden inside your app by explicitly setting it to a particular language on a current thread.
This is making my head spin so I think I'll just accept that I need to set xml:lang until I get round to globalizing it properly. :)
It just seems counter-intuitive that CurrentCulture should report en-GB but the app will still try and lookup en-US resources unless I change the UICulture and it will use a US spellchecker and dateformat unless I set xml:lang. I would have thought the two things should be in sync on the UI thread unless set otherwise. I'm guessing that XP is reporting en-US because I'm using an MSDN supplied version.
Anyway, many thanks Arik for the explanations.
Michael