[GRASS-dev] wingrass640

Glynn Clements glynn at gclements.plus.com
Sun Dec 21 21:56:00 EST 2008


Paul Kelly wrote:

> > It would be also good to modify Windows installer: add to the menu
> > (and desktop) two items
> >
> > * TCLTK GRASS
> > * WX GRASS
> 
> Something else that might be worth investigating would be to implement an 
> option to select the language. I've found that it can easily be done by 
> setting the environment variable LC_ALL to the country code (if compiled 
> with NLS support - Gnuwin32 intl packages work fine here) but the average 
> Windows user may not know how to set an environment variable and I wonder 
> is there some standard way applications using NLS support on Windows set 
> the language.

Native Windows programs normally get translated messages from string
table resources in the binary.

Windows understands setlocale(LC_ALL, "") etc to use the system
locale, as set from the control panel rather than environment
variables.

But Windows doesn't have LC_MESSAGES, and we certainly shouldn't be
calling setlocale(LC_ALL, ""), as that will change LC_NUMERIC, which
affects printf("%f").

AFAICT, the GnuWin32 libintl/gettext requires manual configuration;
the generic installation and usage instructions say:

	http://gnuwin32.sourceforge.net/install.html

	Most GNU packages have the ability to output messages in
	several languages. This native-language support (NLS) requires
	the LibIntl and the LibIconv libraries. On MS-Windows they
	have been adapted so that NLS chooses the system language,
	unless the environment variables LANG and LANGUAGE has been
	set. The language codes (ISO 639) for these environment
	variables are different from the MS-Windows ones. When using a
	program in a console window (command.com or cmd.exe) and
	setting LANG and LANGUAGE, you must also set the correct code
	page with the chcp command; for Western European languages,
	code page 1252 usually suffices. For other languages, such as
	those with a Cyrillic character set, NLS may not operate
	correctly. If you want to disable NLS, then set the
	environment variables LANGUAGE and LANG to en; then all
	messages will be in English.

It's easy enough to get Windows' version of the current locale, with
e.g.:

	orig_locale = setlocale(LC_CTYPE, NULL);
	setlocale(LC_CTYPE, "");
	default_locale = setlocale(LC_CTYPE, NULL);
	setlocale(LC_CTYPE, orig_locale);

However, that will be a string such as "English_United Kingdom.1252". 

If you want the ISO-639 code, you can use GetUserDefaultLCID() to get
an ID, then copy the windows_locale table from Python's locale.py
module to convert it.


-- 
Glynn Clements <glynn at gclements.plus.com>


More information about the grass-dev mailing list