UI languages don't limit cultures

by Michael S. Kaplan, published on 2010/10/28 07:01 -04:00, original URI: http://blogs.msdn.com/b/michkap/archive/2010/10/28/10081912.aspx


The question that came up a few weeks ago:

Is the method CultureInfo.GetCultures() OS dependent, such that an English OS may only load en-US and en-GB but an OS would additional localizations would return more?

        public static string GetCurrencySymbol(string ISOCurrency) {
            if (currencySymbols == null) {
                currencySymbols = new Hashtable();
                foreach (CultureInfo ci in CultureInfo.GetCultures(CultureTypes.SpecificCultures)) {
                    RegionInfo ri = new RegionInfo(ci.LCID);
                    if (!currencySymbols.ContainsKey(ri.ISOCurrencySymbol))
                        currencySymbols.Add(ri.ISOCurrencySymbol, ri.CurrencySymbol);
                }
            }
            return currencySymbols[ISOCurrency].ToString();
        }

Wow.

I think about that huge list of locales on Windows, and I wonder what people think that list is for if not for stuff like this -- locale data like currency symbols!

Of course the answer is the UI language of Windows is not something that gates this information in any way....

Though in truth there is at least one case where this question could be reasonable to ask.

It isn't correct there either, mind you. But there is a time that things do seem kind of filtered.

Does anyone know the scenario I am thinking of here? :-)


Mihai on 28 Oct 2010 10:42 AM:

Not sure if this is the scenario you are thinking about, but here is one:

If I have an application localized into languages not available for Windows UI, I might try to use the user locale (used for matting) to make a better guess what the UI of my application should be.

For instance, if I have a French France and French Canada localized versions and your OS has French UI (the only one available) and French Canada user locale, then I can refine my guess and select fr-CA for my UI.

At least until Windows gets to expose a list of of UI locales that is independent of what MS localizes ant that I can edit/sort as I want (you know, Mac OS X or browser style :-)

Other times you might want to filter things? If you are a native non-Unicode application, or if you run on Win 9x (non-Unicode) then you might want to look at the system code page (not the system locale though).

Michael S. Kaplan on 28 Oct 2010 5:04 PM:

Not bad, though I had something slightly different in mind -- the way the old Win Mobile Platform Builder would let you filter out what locale data made it onto the devicve, so no app could depend on any subset being there....


Please consider a donation to keep this archive running, maintained and free of advertising.
Donate €20 or more to receive an offline copy of the whole archive including all images.

go to newer or older post, or back to index or month or day