This is the mail archive of the cygwin-developers mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: The old $LANG-in-a-box trick (was Re: X11R7.5 and C.UTF-8)


2009/12/3 Corinna Vinschen:
> I created a new, simplified version of my tiny getlocale tool, which
> prints "export LANG=..." to stdout, or "setenv LANG ..." if the -c
> option has been given. ÂSee attached source.

Good idea!

Two more additions would be good: GetUserDefaultUILanguage, and
GetSystemDefaultUILanguage. (These return LANGIDs; to turn them into
LCIDs: MAKELCID(langid, SORT_DEFAULT)).

Bit of background: the language returned by GetUserDefaultUILanguage
is what Windows itself uses for its UIs. If you've got multiple
language packs installed, a 'Display Language' choice appears on the
'Keyboard and Languages' tab of the 'Region and Language' control
panel. Only problem: the function is not available on NT.

The LOCALE_USER_DEFAULT, meanwhile, reflects what's set on the
'Formats' tab of the 'Region and Language' panel.

More on this at the blog of MS's internationalization expert Michael
Kaplan: http://blogs.msdn.com/michkap/archive/2007/04/15/2146890.aspx


> In theory we could use it in /etc/profile.d/lang.{c}sh:
>
> /etc/profile.d/lang.sh:
>
> Âtest -z "${LC_ALL:-${LC_CTYPE:-$LANG}}" && eval $(getlocale -U)
>
> /etc/profile.d/lang.csh:
>
> Âif ( $?LC_ALL == 0 && $?LC_CTYPE == 0 && $?LANG == 0 ) eval `getlocale -cU`
>
> If that's desired, I could easily create a getlocale package for the
> Base category.

It's very tempting, but I'm not sure. A couple of issues to consider:
- The setting is too late for terminal and shell, but then again, do
any of them care about the language setting (rather than the charset)?
- It would change the UI language of localized apps. I'd guess most
users would welcome programs speaking their language, but some would
complain loudly and demand to know how to get back to English.


> One problem we still have is that the iso639 language code returned by
> Windows is a three-letter code in rare cases (see the --testloop output)
> This is not feasible for newlib so far. ÂMaybe the getlocale tool should
> drop back to "C" in these cases.

Seems fair enough. I think our Mohawk and Quechua users would understand. :)

Andy


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]