在 PostgreSQL 中更改系统语言和错误消息
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/191428/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Change language of system and error messages in PostgreSQL
提问by Benno Richters
Is it possible to change the language of system messages from PostgreSQL?
是否可以从 PostgreSQL 更改系统消息的语言?
In MSSQL for instance this is possible with the SQL statement SET LANGUAGE.
例如,在 MSSQL 中,这可以通过 SQL 语句SET LANGUAGE 实现。
回答by Milen A. Radev
回答by user1
Milen's answer didn't work for me.
米伦的回答对我不起作用。
I got it working by modifying a file postgresql.conf
. If you're on Linux, write:
我通过修改文件让它工作postgresql.conf
。如果您使用的是 Linux,请编写:
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'
.
我有我的/var/lib/pgsql/data
。然后编辑文件并搜索变量lc_messages
并将其更改为您的首选语言,例如'en_US.UTF-8'
.
If PostgreSQL stops working and you check in its log that you have an error that looks like this:
如果 PostgreSQL 停止工作并且您在其日志中检查您有如下错误:
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
.
您必须/etc/locale.gen
使用错误消息中的编码编辑和取消注释行(例如en_US.UTF-8
)。然后您必须locale-gen
(以 root 身份)运行以更新语言环境。最后,要检查是否设置了语言环境,您可以运行locale -a
.
Or, if you want the language to be English, you can just set lc_messages = 'C'
.
或者,如果您希望语言为英语,则只需设置lc_messages = 'C'
.
回答by AndreKR
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.
对我来说,Milen A. Radev 和 user1 的回答PostgreSQL\11\data\postgresql.conf
都没有奏效——编辑绝对没有效果。即使在设置后lc_messages = 'random value'
PostgreSQL 仍然会启动。
What helped was to delete PostgreSQL\11\share\locale\*\LC_MESSAGES
, after that I finally got English messages.
有帮助的是删除PostgreSQL\11\share\locale\*\LC_MESSAGES
,之后我终于收到了英文信息。