Skip site navigation (1) Skip section navigation (2)

Win32 & NLS

From: "Magnus Hagander" <mha(at)sollentuna(dot)net>
To: <pgsql-hackers-win32(at)postgresql(dot)org>,"pgsql-patches" <pgsql-patches(at)postgresql(dot)org>
Subject: Win32 & NLS
Date: 2004-10-17 15:31:32
Message-ID: 6BCB9D8A16AC4241919521715F4D8BCE475F0D@algol.sollentuna.se (view raw or flat)
Thread:
Lists: pgsql-hackers-win32pgsql-patches
Hi!

Working the NLS stuff on win32. Considering I know very little about
this part (don't use it myself, never coded around in it), perhaps
someone else can shed some light?

PostgreSQL responds correctly to whatever the LC_MESSAGES environment
variable is set to upon startup of postgresql - I get my error messages
in swedish, english, german or whatever depending on that.

However, postgresql.conf does not load with the error message:
FATAL:  invalid value for parameter "lc_messages": "EN"

This goes for whatever I set lc_messages to, including all the
combinations that work when set in the environment variable. If I
comment it out completely from the config file, things appear to work
with the locale picked up from the environment.
(The error msg of course only shows up when NLS is enabled in configure)


Some quick tracking-down of this shows that the code on line 80-82 of
pg_locale.c:

	save = setlocale(category, NULL);
	if (!save)
		return NULL;			/* won't happen, we hope
*/

*does* return NULL...

Now, I really don't know anything about the setlocale() integration, but
from the MSDN documentation
(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/
html/_crt_setlocale.2c_._wsetlocale.asp) doesn't even list LC_MESSAGES
as a valid identifier. My bet is that's why it returns NULL on
LC_MESSAGES.

Also, some googling lead me to this:
http://www.haible.de/bruno/gettext-FAQ.html#windows_woe32

Which appears to suggest that we should change the locale using putenv()
etc, and not using setlocale() at all... Because setlocale() does not
support LC_MESSAGES, probably.

Attached is a patch with adds a environment variable based version of
locale_messages_assign(). It's not a pretty solution, but I think it's
probably necessary.

Comments?


(There is also a patch for initdb required to work on win32 when
compiled with NLS enabled, but this is the start...)


//Magnus

Attachment: win32nls.patch
Description: application/octet-stream (2.4 KB)

Responses

pgsql-patches by date

Next:From: Peter EisentrautDate: 2004-10-17 15:47:19
Subject: Re: [PATCHES] Win32 & NLS
Previous:From: Greg StarkDate: 2004-10-17 05:10:14
Subject: Re: Nearing final release?

pgsql-hackers-win32 by date

Next:From: Peter EisentrautDate: 2004-10-17 15:47:19
Subject: Re: [PATCHES] Win32 & NLS
Previous:From: Andrew DunstanDate: 2004-10-16 19:37:36
Subject: Re: get_progname and .exe suffix

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group