On Oracle I have set:

export NLS_LANG=Italian_ITALY.UTF8

.. on Unix shell and now I get status and error message in Italian.

How to set in Postgres shell (psql)? I have set:

SET lc_messages TO 'it_IT.UTF-8';

But it is all in English:

video-# ;
ERROR:  syntax error at or near "prova"
LINE 1: prova
video=# select count(*) from generale ;
(1 row)

I'm afraid it's not possible - at least according to the documentation

Check this out here.

To enable messages to be translated to the user's preferred language, NLS must have been selected at build time (configure --enable-nls). All other locale support is built in automatically.

You have to configure the database when you install it. Is your machine an Italian one, or is it configured in English? I must say that I'm surprised by this - I thought PostgreSQL was more flexible than this.

  • This is a misunderstanding. Quoting the manual about that setting here: If you do not specify a list, then all available translations are installed. It is enabled in any standard distribution of modern Postgres. – Erwin Brandstetter May 19 '15 at 1:22
  • Probably this is the solution (configure --enable-nls) i try now – elbarna May 19 '15 at 1:23

First of all, this is an error message from PostgreSQL, which is not the same as psql (the command-line client). The SET command sets run-time parameters of the Postgres server, which is completely independent from the client (psql in this case).

Either way, it works for me. Testing the standard distribution of Postgres 9.4.1 on a Windows client set to a German locale (German_Germany.1252):

test=# SET LC_MESSAGES TO 'it_IT.UTF-8';
test=# SELECT 1/0;
ERRORE:  divisione per zero

test=# SET lc_messages  = 'C';
test=# SELECT 1/0;
ERROR:  division by zero

test=# RESET lc_messages;
test=# SELECT 1/0;
FEHLER:  Division durch Null

The same works on a Debian machine (where the respective locales are available!). And I can reproduce the same from any other client (like pgAdmin).

Maybe you are not running both commands in the same session? Either way, Postgres uses locale support from the underlying OS. Per documentation:

What locales are available on your system under what names depends on what was provided by the operating system vendor and what was installed. On most Unix systems, the command locale -a will provide a list of available locales. Windows uses more verbose locale names, such as German_Germany or Swedish_Sweden.1252, but the principles are the same.

And natural language support (--enable-nls) must be enabled at compile time which is the default and is the case for standard distributions. Details in the manual here.
Are you running a non-standard version? Compiled it yourself maybe?

  • Wich version is? I have the 9.4.1 i try and give me only english messages – elbarna May 19 '15 at 1:18
  • @elbarna: Sorry, provided the tested version. This has been working with any other standard distribution of Postgres since at leas Postgres 9.1 (probably longer). – Erwin Brandstetter May 19 '15 at 1:20
  • The solution was onfigure --enable-nls,configured and compiled now works fine,yes was compiled by me but using an old slackbuild, without nls – elbarna May 19 '15 at 1:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.