52

Is it possible to change the language of system messages from PostgreSQL?

In MSSQL for instance this is possible with the SQL statement SET LANGUAGE.

Benno Richters
  • 15,378
  • 14
  • 42
  • 45

7 Answers7

52
SET lc_messages TO 'en_US.UTF-8';

More info on requirements and limitations here.

Milen A. Radev
  • 60,241
  • 22
  • 105
  • 110
  • 7
    Unfortunately this does not seem to have any effect when the database server is installed on Windows. – Benno Richters Oct 13 '08 at 11:05
  • 5
    According to this bug report - http://archives.postgresql.org/pgsql-bugs/2008-05/msg00134.php, you're right. Have you tried to change the 'lc_messages' setting directly in the postgresql.conf and to restart? – Milen A. Radev Oct 13 '08 at 21:16
  • 1
    Now, after reading the mentioned thread in the archives, the only way to change the language of the system messages seems to be to change the OS locale. – Milen A. Radev Oct 13 '08 at 21:23
  • 2
    Appears to have been fixed. Command now works on Windows (Server 2008 R2, PostgreSQL 9.0.3) – dirkb Aug 29 '11 at 17:51
  • 1
    Note that "Only superusers can change this setting", so it may be worth reminding one can log as superuser e.g. with `sudo -u postgres psql`. – Skippy le Grand Gourou Sep 15 '14 at 17:21
  • 1
    This might not work for some installations as `en_US.UTF-8` locale might not be available. Safer solution is to use `SET lc_messages TO 'C';` (which also means English). Use `locale -l` in shell to test for available locale. – Nux Mar 21 '16 at 18:38
  • 4
    It doesn't seem to make it permanent to me on PostgreSQL 9.4, I had to change this setting in the postgresql.conf – Bruno Medeiros Mar 29 '16 at 23:31
  • Just want to add that Postgres should be built with NLS support. – ololobus Mar 06 '19 at 09:29
37

For me neither Milen A. Radev's nor user1's answer worked - editing PostgreSQL\11\data\postgresql.conf had absolutely no effect. Even after setting lc_messages = 'random value' PostgreSQL would still start.

What helped was to delete PostgreSQL\11\share\locale\*\LC_MESSAGES, after that I finally got English messages.

AndreKR
  • 32,613
  • 18
  • 106
  • 168
24

Milen's answer didn't work for me.

I got it working by modifying a file postgresql.conf. If you're on Linux, write:

sudo find / -iname postgresql.conf

I had mine in /var/lib/pgsql/data. Then edit the file and search for a variable lc_messages and change it to your preferred language, e.g. 'en_US.UTF-8'.

If PostgreSQL stops working and you check in its log that you have an error that looks like this:

invalid value for parameter "lc_messages": "en_US.UTF-8"

You have to edit /etc/locale.gen and uncomment line with encoding from the error message (e.g. en_US.UTF-8). Then you have to run locale-gen (as root) to update the locales. Finally, to check if the locale is set you can run locale -a.

Or, if you want the language to be English, you can just set lc_messages = 'C'.

user1
  • 945
  • 2
  • 13
  • 37
  • 3
    Mine was in `/etc/postgresql/9.5/main/postgresql.conf` on an Ubuntu 14.04 with postgresql installed from the official PostgreSQL PPA. Leaving it here for the benefit of others. – LeoRochael Sep 29 '16 at 13:30
  • 7
    On `windows` e.g. `C:\Program Files\PostgreSQL\9.5\data` – Beat Nov 11 '16 at 10:44
  • 1
    `lc_messages = 'C'` works great :-). Seems like most universal (working on Windows and Linux). – Nux Apr 21 '21 at 11:16
6

In my case (on Windows Server 2019) I managed to change language by creating a system environment variable "LC_MESSAGES" with value "English":

setx LC_MESSAGES English /m

(Solution taken from here)

  • 1
    I tried this solution first since it was fast and easy to verify. I can say it worked and I didn't need to try the other solutions. I'm working on Windows 10. – OmriYaHoo Jul 18 '20 at 20:47
1

I've reproduced the same issue with naming of PostgreSQL error messages which were specifically displayed in Intellij IDEA similar to:

enter image description here

the only solution for me was renaming C:\Program Files\PostgreSQL\13\share\locale folder to another default name.

then as result changed to:

enter image description here

To be noticed: it wasn't related to Intellij Idea configurations at all, because I tested different answers (and other non-related to IDE answers), e.g., like:

  1. Help | Edit custom VM options
  2. Setting of Environments variables
  3. Using specific commands
invzbl3
  • 5,872
  • 9
  • 36
  • 76
0

only change postgresql.conf is not working on windows10,the following method is fine for me,is very simple but work:

  1. change lc_message = en_US.UTF-8, in postgresql.conf;
  2. delete all files in fold: \share\locale, expect es fold or the language you want to keep;
  3. restart pg service and then you will find that is what you want!
huangzhuohua
  • 127
  • 1
  • 1
  • 9
0

I simply deleted the LC_MESSAGE folder from

C:\Program Files\PostgreSQL\14\share\locale\<LANGUAGE YOU WANT TO GET RID OF>\LC_MESSAGE

and re-log in to psql

27P
  • 1,183
  • 16
  • 22