Change language of system and error messages in PostgreSQL

Postgresql

Postgresql Problem Overview


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.

Postgresql Solutions


Solution 1 - Postgresql

SET lc_messages TO 'en_US.UTF-8';

More info on requirements and limitations here.

Solution 2 - Postgresql

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'.

Solution 3 - Postgresql

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.

Solution 4 - Postgresql

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)

Solution 5 - Postgresql

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionBenno RichtersView Question on Stackoverflow
Solution 1 - PostgresqlMilen A. RadevView Answer on Stackoverflow
Solution 2 - Postgresqluser1View Answer on Stackoverflow
Solution 3 - PostgresqlAndreKRView Answer on Stackoverflow
Solution 4 - PostgresqlBirgit Vera SchmidtView Answer on Stackoverflow
Solution 5 - Postgresqlinvzbl3View Answer on Stackoverflow