Search Postgresql Archives

Re: libpq messages language

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Efraín López wrote:
>>> I am using Windows, and pg 8.2.5
>>>
>>> When making a connection with libpq, if it fails I would like
>>> to get the errors messages in spanish (PQerrorMessage  )
>>>
>>> Is this possible? How can this be done?

I got it to work with this program:

#include <stdlib.h>
#include <stdio.h>
#include <locale.h>
#include <libpq-fe.h>

int main(int argc, char **argv) {
        PGconn *conn;

        setlocale(LC_ALL, "");
        putenv("PGLOCALEDIR=C:\\Programme\\postgres\\share\\locale");

        conn = PQconnectdb("port=4711");
        if (CONNECTION_OK != PQstatus(conn)) {
                fprintf(stderr, "%s\n", PQerrorMessage(conn));
                PQfinish(conn);
                return 1;
        }

        PQfinish(conn);
        return 0;
}

Instead of setting PGLOCALEDIR in the code, you can also define
it as environment variable on your system, that is maybe better.

It must point to the directory where your message files are installed
(you have spanish message files installed, haven't you?).

The above program assumes that there is no database running
on port 4711, so you get an error message from libpq.

Yours,
Laurenz Albe

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
       choose an index scan if your joining column's datatypes do not
       match


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux