Note: Written by Oleg Bartunov. See Oleg's web page for additional information on locale and Russian language support.
作者:Oleg Bartunov。 ロケールとロシア語サポートに関する詳細は、 Oleg の Web ページを参照のこと。
People often complain that locale doesn't work for them. There are several common mistakes:
時々、自分たちの言語に関するロケールがうまく動かないと文句を 言う人がいますが、これは以下のミスに起因することが多いのです:
Didn't properly configure postgresql before compilation. You must run configure with --enable-locale option to enable locale support. Didn't setup environment correctly when starting postmaster. You must define environment variables LC_CTYPE and LC_COLLATE before running postmaster because backend gets information about locale from environment. I use following shell script (runpostgres):
コンパイルする前に postgresql を適切に構成していない。 ロケールサポートを有効にするために、--enable-locale オプショ ン付きで configure を実行してやらなければなりません。 postmaster を起動する際に、きちんと環境変数を設定していない。 postmaster を起動する前に、LC_CTYPE および LC_COLLATE 環境変数を定義してやり、バックエン ドが環境変数からロケール情報を取得できるようにしてやる必要が あります。私は以下のようなシェルスクリプト(runpostgres)を使っ ています:
#!/bin/sh export LC_CTYPE=koi8-r export LC_COLLATE=koi8-r postmaster -B 1024 -S -D/usr/local/pgsql/data/ -o '-Fe'and run it from rc.local as そしてこれを rc.local で以下のように起動します。
/bin/su - postgres -c "/home/postgres/runpostgres"
Broken locale support in OS (for example, locale support in libc under Linux several times has changed and this caused a lot of problems). Latest perl has also support of locale and if locale is broken perl -v will complain something like:
OS におけるロケールのサポートは正しくないことがあります。例 をあげると、Linux 上の libc によるロケールのサポートはしばし ば変更され、これが多大な混乱を引き起こしています。perl の最 新版でもロケールがサポートされており、これがただしく設定され ないと、perl -v で以下の警告メッセージが 表示されます:
8:17[mira]:~/WWW/postgres>setenv LC_CTYPE not_exist 8:18[mira]:~/WWW/postgres>perl -v perl: warning: Setting locale failed. perl: warning: Please check that your locale settings: LC_ALL = (unset), LC_CTYPE = "not_exist", LANG = (unset) are supported and installed on your system. perl: warning: Falling back to the standard locale ("C").
Wrong location of locale files!
誤った位置にあるロケールファイル! Possible locations include: 一般に、以下の位置になります: /usr/lib/locale (Linux, Solaris), /usr/share/locale (Linux), /usr/lib/nls/loc (DUX 4.0). Check man locale to find the correct location. Under Linux I did a symbolic link between /usr/lib/locale and /usr/share/locale to be sure that the next libc will not break my locale. 正しい位置に関しては man locale に書いて あります。私は Linux では /usr/lib/locale と /usr/share/locale の間にシンボリック リンクを張って、次のバージョンの libc でも正しく動くようにし ました。
You can use ~* and order by operators for strings contain characters from national alphabets. Non-english users definitely need that. If you won't use locale stuff just undefine the USE_LOCALE variable.
自国語アルファベットを含む文字列に対して ~* や order by 演算子が使えます。非英語圏のユーザにとっては必須の機能でしょ う。ロケール機能を使いたくなければ、USE_LOCALE 環境変数を未 定義にするだけですみます。
There is one evident drawback of using locale - its speed! So, use locale only if you really need it.
ロケールには明らかな欠点があります。その速度です!このため、 本当に使いたいときにのみロケールを使うようにしてください。