Unix Technical Forum

libpq messages language

This is a discussion on libpq messages language within the Pgsql General forums, part of the PostgreSQL category; --> Hi, I am using Windows, and pg 8.2.5 When making a connection with libpq, if it fails I would ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > Pgsql General

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-09-2008, 11:13 PM
=?iso-8859-1?Q?Efra=EDn_L=F3pez?=
 
Posts: n/a
Default libpq messages language

Hi,

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?

thanks

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-09-2008, 11:13 PM
Albe Laurenz
 
Posts: n/a
Default Re: libpq messages language

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?


Set the program's locale prior to calling libpq functions.

I did not try it on Windows, but Microsoft seems to work like
UNIX in that respect:

http://msdn2.microsoft.com/en-us/lib...1d(VS.80).aspx

Try something like

setlocale(LC_MESSAGES, "Spanish");

or, if your language environment is Spanish, simply

setlocale(LC_MESSAGES, "");

Yours,
Laurenz Albe

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-09-2008, 11:13 PM
=?iso-8859-1?Q?Efra=EDn_L=F3pez?=
 
Posts: n/a
Default Re: libpq messages language

Thank you for your reply

but I got the error 'LC_MESSAGES' : undeclared identifier

locale.h only defines LC_COLLATE, LC_CTYPE, LC_MONETARY, LC_NUMERIC, LC_TIME

I tried to set a system variable LC_MESSAGES, but didn't work

Then, I tried to find more information


In libpq, when ENABLE_NLS is not defined,
#define libpq_gettext(x) (x)

If I set ENABLE_NLS to 1, then I think I need the gettext library, because
it needs <libintl.h>

so, there is no simple way in windows to get messages in spanish within
libpq before connecting to server, is correct?

thanks


----- Original Message -----
From: "Albe Laurenz" <laurenz.albe@wien.gv.at>
To: "Efraín López *EXTERN*" <tecnomaya@cabsagt.com>;
<pgsql-general@postgresql.org>
Sent: Tuesday, December 04, 2007 5:33 AM
Subject: RE: [GENERAL] libpq messages language


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?


Set the program's locale prior to calling libpq functions.

I did not try it on Windows, but Microsoft seems to work like
UNIX in that respect:

http://msdn2.microsoft.com/en-us/lib...1d(VS.80).aspx

Try something like

setlocale(LC_MESSAGES, "Spanish");

or, if your language environment is Spanish, simply

setlocale(LC_MESSAGES, "");

Yours,
Laurenz Albe



---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-09-2008, 11:13 PM
Usama Dar
 
Posts: n/a
Default Re: libpq messages language

On Dec 6, 2007 8:03 AM, Efraín López <tecnomaya@cabsagt.com> wrote:

> Thank you for your reply
>
> but I got the error 'LC_MESSAGES' : undeclared identifier
>
> locale.h only defines LC_COLLATE, LC_CTYPE, LC_MONETARY, LC_NUMERIC,
> LC_TIME
>
> I tried to set a system variable LC_MESSAGES, but didn't work
>
> Then, I tried to find more information
>
>
> In libpq, when ENABLE_NLS is not defined,
> #define libpq_gettext(x) (x)
>
> If I set ENABLE_NLS to 1, then I think I need the gettext library, because
> it needs <libintl.h>
>
> so, there is no simple way in windows to get messages in spanish within
> libpq before connecting to server, is correct?



Well libpq like rest of postgres uses gettext for i18N , so i think you need
to have your windows locale set to spanish, have the gettext library
installed and spanish message catalogs available on your system, which will
be if you compiled the source with --enable-nls configure option then it
doesn't matter if the connection was made to the server or not, since libpq
has its own translated messages catalog.




--
Usama Munir Dar http://linkedin.com/in/usamadar
Consultant Architect
Cell:+92 321 5020666
Skype: usamadar

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 04-09-2008, 11:14 PM
Albe Laurenz
 
Posts: n/a
Default Re: libpq messages language

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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 04-09-2008, 11:14 PM
=?iso-8859-1?Q?Efra=EDn_L=F3pez?=
 
Posts: n/a
Default Re: libpq messages language

Thank you very much for your help. It worked for me.

I am using Visual C++ 2005 express
I downloaded gettext-runtime-0.13.1.bin.woe32.zip and
libiconv-1.9.1.bin.woe32.zip from
http://sourceforge.net/project/showf...group_id=25167

Then I compiled libpq with ENABLE_NLS, gettext and libiconv libs

They, I just got carefull with PGLOCALEDIR,

again, thank you!

----- Original Message -----
From: "Albe Laurenz" <laurenz.albe@wien.gv.at>
To: "Efraín López *EXTERN*" <tecnomaya@cabsagt.com>;
<pgsql-general@postgresql.org>
Sent: Friday, December 07, 2007 2:52 AM
Subject: RE: [GENERAL] libpq messages language


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 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 12:42 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com