Re: Relocatable locale - Mailing list pgsql-patches

From Bruce Momjian
Subject Re: Relocatable locale
Date
Msg-id 200405261859.i4QIxpv08623@candle.pha.pa.us
Whole thread Raw
In response to Re: Relocatable locale  (Peter Eisentraut <peter_e@gmx.net>)
Responses Re: Relocatable locale
List 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@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

pgsql-patches by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: Cancel/Kill backend functions
Next
From: Andrew Dunstan
Date:
Subject: Re: Relocatable locale