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

Re: Relocatable locale

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: Relocatable locale
Date: 2004-05-26 18:59:51
Message-ID: 200405261859.i4QIxpv08623@candle.pha.pa.us (view raw, whole thread or download thread mbox)
Thread:
Lists: pgsql-patches
Peter Eisentraut wrote:
> Bruce Momjian wrote:
> > I have two questions.  First, setlocale() seemed to be inconsistently
> > set inside and outside of ENABLE_NLS.  I assume the proper location
> > is inside.
> 
> No, in case of doubt it's outside.


OK, moved.  New code is:

	void
	set_pglocale(const char *argv0, const char *app)
	{
	#ifdef ENABLE_NLS
	    char path[MAXPGPATH];
	    char my_exec_path[MAXPGPATH];
	#endif
	
	    /* don't set LC_ALL in the backend */
	    if (strcmp(app, "postgres") != 0)
	        setlocale(LC_ALL, "");
	
	#ifdef ENABLE_NLS
	    if (find_my_exec(argv0, my_exec_path) < 0)
	        return;
	
	    get_locale_path(my_exec_path, path);
	    bindtextdomain(app, path);
	    textdomain(app);
	#endif
	}

> 
> >  Second, libpq has a locale setting for error messages,
> > but a libpq program could be in any directory, so I see no way to
> > make that relocatable.  Instead, I just use the hardcoded path.  I
> > could make it relocatable, but that seems to error-prone, plus I
> > would have to look up the exec path and stuff, and it seemed too
> > complicated.
> 
> Hmm, so this says that a relocatable install isn't in fact possible?

Yep.  I don't see how you can have a library know where to look for its
localized messages.  The only thing I can think of is an environment
variable to override the hard-coded default.  How is that?

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman(at)candle(dot)pha(dot)pa(dot)us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

In response to

Responses

pgsql-patches by date

Next:From: Andrew DunstanDate: 2004-05-26 19:48:19
Subject: Re: Relocatable locale
Previous:From: Bruce MomjianDate: 2004-05-26 18:50:28
Subject: Re: Cancel/Kill backend functions

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