ResolveLocaleName cleans up and flies right

by Michael S. Kaplan, published on 2012/08/07 07:05 -04:00, original URI: http://blogs.msdn.com/b/michkap/archive/2012/08/07/10337516.aspx


Regular readers may remember my Four cases where I don't like ResolveLocaleName (and you shouldn't either!) from a few months ago.

I described a terrible sitation with ResolveLocaleName.

Ths function, added in Windows 7, would do all of the following:

In Out
en-Latn-AU en-US
zh-Hant-TW zh-HK
en-Cyrl-TT en-US
en-CanYouBelieve-THISCRAP en-US

and I pointed out how this function works. It works badly.

Well, one person took this to heart, my friend Brendan.

He entered a bug on this for Windows 8 (I was actually just looking at the Win7 repro but it was I guess in Win8 too!).

Anyhow, despite how late it was they did do a quick fix!

So, once you have RTM bits, the results are much more reasonable:

In Out
en-Latn-AU en-AU
zh-Hant-TW zh-TW
en-Cyrl-TT en-TT
en-CanYouBelieve-THISCRAP en-US

 Wow -- much bettter!

Now, we just need to port it to Wndows 7... ::-)


Matthew Slyman on 16 Apr 2013 9:42 AM:

I've been working on this very problem: perhaps you reached the same conclusion I did, that the correct way to handle these things is via the traversal of a tree-structure representing the range of permissible/available language options. My own algorithm actually does something slightly more advanced: it takes two SETS of language codes (one set, the permissible/available options for a particular URI; the other set, the permissible/desired options according to a website visitor's HTTP language preferences.) Using set theory and ordered trees, I combine the sets into an ordered list of language options. You can see the results, for example, at the foot of this page:

www.aaabit.com/.../bin-packing

Change the language options in your browser, and see which localization options you are offered! This is just Version 1 of my system. I'm working on Version 2, which will work on simpler, tidier code; and give better results. I plan to publish my code & algorithms, possibly as "open-source code". Might pay this page another visit when I've done it...


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