More ASP.NET Globalization/Localization/Internationalization and my mad, mad, mad, mad life
For some reason I keep wanting to apologize, presumably to myself, whenever I don't blog for a day. But I've been so heads-down on some really fun ASP.NET stuff. Plus, this is my last big term before my graduation on June 6th (anyone want to come?). I'm taking classes from 6pm to 10pm most days. This week was crazy...I worked M-F, went to school, T, Th, F, and Weds I drove up to Redmond to meet with COM+ folks and drove back in the same day. I tell ya, it's always 3hours up from Portland and 5 hours down. Traffic on I5 is unbelievable. Anyway, all this plus an interesting programming project I'm obsessed with, and PPTs for at least 6 different presentations. Then, the PCC Engineering folks call me to do a lunch seminar tommorow, and what do I do? I say YES. :) Madness.
At any rate, today I was localizing an eFinance application to Spanish, Chinese, and Arabic, and I noticed that after these lines:
Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(strCulture);
all the currencies were formatted as the Locales currency, when I wanted to format them in the Banks currency, which of course is different than the "preferred language." So, rather than messing with CultureInfo every time I wanted to format a currency, I really just want to override the NumberFormat for the CurrentThread's Culture, so number format strings like {0:C} would just "do the right thing." So...
Thread.CurrentThread.CurrentCulture.NumberFormat.CurrencySymbol = "$";
Actually I do a bunch of other stuff for the sake of being generic, storing a Default CurrentCulture away and querying it for it's CurrencySymbol...but you get the idea. Overall I'm very impressed by the Globalization Namespace. It's certainly more well thoughout for WinForms than WebForms, but with some thought (the devil's in the details) I'm localizing everything on the page, the grids, column headers, menus, etc without a significant perf hit.One interesting note...while changing to RTL (Right To Left) for Arabic, I've noted that when you switch to WebForm Design Mode in Visual Studio 2002 it YANKS the runat="server" attribute from my HTML tag! What's THAT about?
About Scott
Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.
About Newsletter
Comments are closed.