how to specify the locale that psql uses

Started by Kent Tongabout 17 years ago11 messagesgeneral
Jump to latest
#1Kent Tong
kent@cpttm.org.mo

Hi,

I am running a Chinese edition of XP. When I start psql, it is probably
trying to display Chinese and
maybe it gets the encoding wrong, it displays garbage in its console. Is
there any way to tell it to
just use English instead? In Linux, one can do something like "LC_ALL=en
psql" but it doesn't seem
to work on the Windows port of PostgreSQL.

Thanks for any help!

-----
--
Kent Tong
Wicket tutorials freely available at http://www.agileskills2.org/EWDW
Axis2 tutorials freely available at http://www.agileskills2.org/DWSAA
--
View this message in context: http://www.nabble.com/how-to-specify-the-locale-that-psql-uses-tp21599904p21599904.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.

#2Reg Me Please
regmeplease@gmail.com
In reply to: Kent Tong (#1)
Re: how to specify the locale that psql uses

On Thursday 22 January 2009 09:36:53 Kent Tong wrote:

Hi,

I am running a Chinese edition of XP. When I start psql, it is probably
trying to display Chinese and
maybe it gets the encoding wrong, it displays garbage in its console. Is
there any way to tell it to
just use English instead? In Linux, one can do something like "LC_ALL=en
psql" but it doesn't seem
to work on the Windows port of PostgreSQL.

Thanks for any help!

-----
--
Kent Tong
Wicket tutorials freely available at http://www.agileskills2.org/EWDW
Axis2 tutorials freely available at http://www.agileskills2.org/DWSAA
--
View this message in context:
http://www.nabble.com/how-to-specify-the-locale-that-psql-uses-tp21599904p2
1599904.html Sent from the PostgreSQL - general mailing list archive at
Nabble.com.

psql --help ?

--
Fahrbahn ist ein graues Band
weisse Streifen, grüner Rand

#3Kent Tong
kent@cpttm.org.mo
In reply to: Reg Me Please (#2)
Re: how to specify the locale that psql uses

Reg Me Please wrote:

psql --help ?

which option you're referring to? I tried --locale but it had no effect.

-----
--
Kent Tong
Wicket tutorials freely available at http://www.agileskills2.org/EWDW
Axis2 tutorials freely available at http://www.agileskills2.org/DWSAA
--
View this message in context: http://www.nabble.com/how-to-specify-the-locale-that-psql-uses-tp21599904p21600296.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.

#4Reg Me Please
regmeplease@gmail.com
In reply to: Kent Tong (#3)
Re: how to specify the locale that psql uses

On Thursday 22 January 2009 10:04:58 Kent Tong wrote:

Reg Me Please wrote:

psql --help ?

which option you're referring to? I tried --locale but it had no effect.

-----
--
Kent Tong
Wicket tutorials freely available at http://www.agileskills2.org/EWDW
Axis2 tutorials freely available at http://www.agileskills2.org/DWSAA
--
View this message in context:
http://www.nabble.com/how-to-specify-the-locale-that-psql-uses-tp21599904p2
1600296.html Sent from the PostgreSQL - general mailing list archive at
Nabble.com.

Weel, you have two locales: one on the client and one the server.
The former is needed for "translations" to the server whenver the two don't
match.
The latter is chosen at the CREATE DATABASE <dbname> ENCODING <encoding>.

--
Fahrbahn ist ein graues Band
weisse Streifen, grüner Rand

#5Kent Tong
kent@cpttm.org.mo
In reply to: Reg Me Please (#4)
Re: how to specify the locale that psql uses

Reg Me Please wrote:

Weel, you have two locales: one on the client and one the server.
The former is needed for "translations" to the server whenver the two
don't
match.
The latter is chosen at the CREATE DATABASE <dbname> ENCODING <encoding>.

I am referring to the locale on the client that determines the text prompts
it
outputs.

-----
--
Kent Tong
Wicket tutorials freely available at http://www.agileskills2.org/EWDW
Axis2 tutorials freely available at http://www.agileskills2.org/DWSAA
--
View this message in context: http://www.nabble.com/how-to-specify-the-locale-that-psql-uses-tp21599904p21601001.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.

#6Reg Me Please
regmeplease@gmail.com
In reply to: Kent Tong (#5)
Re: how to specify the locale that psql uses

On Thursday 22 January 2009 10:51:41 Kent Tong wrote:

Reg Me Please wrote:

Weel, you have two locales: one on the client and one the server.
The former is needed for "translations" to the server whenver the two
don't
match.
The latter is chosen at the CREATE DATABASE <dbname> ENCODING <encoding>.

I am referring to the locale on the client that determines the text prompts
it
outputs.

-----
--
Kent Tong
Wicket tutorials freely available at http://www.agileskills2.org/EWDW
Axis2 tutorials freely available at http://www.agileskills2.org/DWSAA
--
View this message in context:
http://www.nabble.com/how-to-specify-the-locale-that-psql-uses-tp21599904p2
1601001.html Sent from the PostgreSQL - general mailing list archive at
Nabble.com.

In general, refer to "8.13.2. Encoding Handling" and "Chapter 22.
Localization" on v8.3.5 documentation.

Then you could use either the "\encoding" or the "SET client_encoding
TO ..." into psql, the "PGCLIENTENCODING" environment variable or
the "client_encoding" main configuration argument.

Moreover you can check from psql and pl/pgsql the current client encoding
with SELECT * FROM pg_client_encoding();

I hope any of these will help.

--
Fahrbahn ist ein graues Band
weisse Streifen, grüner Rand

#7Kent Tong
kent@cpttm.org.mo
In reply to: Reg Me Please (#6)
Re: how to specify the locale that psql uses

Reg Me Please wrote:

In general, refer to "8.13.2. Encoding Handling" and "Chapter 22.
Localization" on v8.3.5 documentation.

Thanks for your replies. However, as I said before, I am asking for the
locale controlling the text
prompts printed by psql. I've read the chapter you quoted before posting for
help and it didn't
apply to the issue.

-----
--
Kent Tong
Wicket tutorials freely available at http://www.agileskills2.org/EWDW
Axis2 tutorials freely available at http://www.agileskills2.org/DWSAA
--
View this message in context: http://www.nabble.com/how-to-specify-the-locale-that-psql-uses-tp21599904p21605547.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.

#8Laurenz Albe
laurenz.albe@cybertec.at
In reply to: Kent Tong (#5)
Re: how to specify the locale that psql uses

Kent Tong wrote:

I am referring to the locale on the client that determines the text prompts it outputs.

I think "Reg me Please" got you wrong, here's the answer:

To set the locale for server messages, set the server configuration
parameter "lc_messages" to the appropriate value.

You can either do this for the current session with the SQL command:
SET lc_messages='....';
or you can change the default in postgresql.conf and reload.

To change the locale of messages *by* psql, libpq and other client
programs, change the current locale where you start the client.

How you do this depends on the operating system; on UNIX you do
it by setting the LANG environment variable.

Yours,
Laurenz Albe

#9Dhaval Jaiswal
bablu_postgres@yahoo.com
In reply to: Kent Tong (#1)
Re: how to specify the locale that psql uses

When you install postgreSQL over XP at the same time it asks for encoding & locale.
Set at the same time. Follow the below link will give you more idea.

http://www.postgresql.org/docs/7.2/static/multibyte.html

If you want to change the locale of existing database. You can't..
The workaround for that you can create another cluster with initdb command with supported locale.

If you want to create database with different encoding. You can.
You can execute the following command.

Command:     CREATE DATABASE
Description: create a new database
Syntax:
CREATE DATABASE name
    [ [ WITH ] [ OWNER [=] dbowner ]
           [ TEMPLATE [=] template ]
           [ ENCODING [=] encoding ]
           [ TABLESPACE [=] tablespace ]
           [ CONNECTION LIMIT [=] connlimit ] ]

--
Thanks & Regards,
Dhaval Jaiswal
EnterpriseDB
www.enterprisedb.com

________________________________
From: Kent Tong <kent@cpttm.org.mo>
To: pgsql-general@postgresql.org
Sent: Thursday, January 22, 2009 2:06:53 PM
Subject: [GENERAL] how to specify the locale that psql uses

Hi,

I am running a Chinese edition of XP. When I start psql, it is probably
trying to display Chinese and
maybe it gets the encoding wrong, it displays garbage in its console. Is
there any way to tell it to
just use English instead? In Linux, one can do something like "LC_ALL=en
psql" but it doesn't seem
to work on the Windows port of PostgreSQL.

Thanks for any help!

-----
--
Kent Tong
Wicket tutorials freely available at http://www.agileskills2.org/EWDW
Axis2 tutorials freely available at http://www.agileskills2.org/DWSAA
--
View this message in context: http://www.nabble.com/how-to-specify-the-locale-that-psql-uses-tp21599904p21599904.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#10Shoaib Mir
shoaibmir@gmail.com
In reply to: Dhaval Jaiswal (#9)
Re: how to specify the locale that psql uses

On Fri, Mar 27, 2009 at 9:35 AM, Dhaval Jaiswal <bablu_postgres@yahoo.com>wrote:

When you install postgreSQL over XP at the same time it asks for encoding &
locale.
Set at the same time. Follow the below link will give you more idea.

http://www.postgresql.org/docs/7.2/static/multibyte.html

Please updates yourself with the latest version as its 8.3.7 these days and
you are still like years and years behind with version 7.2 documentation :)

If you want to change the locale of existing database. You can't.
The workaround for that you can create another cluster with initdb command
with supported locale.

I dont think so the person asking the question ever asked for changing
encoding for the database. Please make sure to read the question atleast, as
it was about changing locale for psql.

In order to do that

For server messages:
-------------------------------

set the configuration parameter "lc_messages" to a value you like to have
for getting messages back from server.

It can done in both ways, for the session and permanently.

In order to do for a session use:

set lc_message = ....

and otherwise set it in your postgresql.conf file and reload.

For Client messages:
-----------------------------

For client programs like psql, change the current locale where you are
starting up psql. I am not sure about windows but in Linux you can do this
by setting LANG environment variable.

--
Shoaib Mir
http://shoaibmir.wordpress.com/

#11Dhaval Jaiswal
bablu_postgres@yahoo.com
In reply to: Shoaib Mir (#10)
Re: how to specify the locale that psql uses

I had given reply abt windows

 

________________________________
From: Shoaib Mir <shoaibmir@gmail.com>
To: Dhaval Jaiswal <bablu_postgres@yahoo.com>
Cc: Kent Tong <kent@cpttm.org.mo>; pgsql-general@postgresql.org
Sent: Friday, March 27, 2009 4:47:43 AM
Subject: Re: [GENERAL] how to specify the locale that psql uses

On Fri, Mar 27, 2009 at 9:35 AM, Dhaval Jaiswal <bablu_postgres@yahoo.com> wrote:

When you install postgreSQL over XP at the same time it asks for encoding & locale.
Set at the same time. Follow the below link will give you more idea.

http://www.postgresql.org/docs/7.2/static/multibyte.html

Please updates yourself with the latest version as its 8.3.7 these days and you are still like years and years behind with version 7.2 documentation :)
 

If you want to change the locale of existing database. You can't.
The workaround for that you can create another cluster with initdb command with supported locale.

I dont think so the person asking the question ever asked for changing encoding for the database. Please make sure to read the question atleast, as it was about changing locale for psql.

In order to do that

For server messages:
-------------------------------

set the configuration parameter "lc_messages" to a value you like to have for getting messages back from server.

It can done in both ways, for the session and permanently.

In order to do for a session use:

set lc_message = ....

and otherwise set it in your postgresql.conf file and reload.

For Client messages:
-----------------------------
 
For client programs like psql, change the current locale where you are starting up psql. I am not sure about windows but in Linux you can do this by setting LANG environment variable.

--
Shoaib Mir
http://shoaibmir.wordpress.com/