"gettext" — 多言語対応に関する国際化サービス
********************************************

**ソースコード:** Lib/gettext.py

======================================================================

"gettext" モジュールは、 Python によるモジュールやアプリケーションの国
際化 (I18N, I-nternationalizatio-N) および地域化  (L10N,
L-ocalizatio-N) サービスを提供します。このモジュールは GNU "gettext"
メッセージカタログへの API と、より高水準で Python ファイルに適してい
るクラスに基づいた API の両方をサポートしてます。以下で述べるインタフ
ェースを使うことで、モジュールやアプリケーションのメッセージをある自然
言語で記述しておき、翻訳されたメッセージのカタログを与えて他の異なる自
然言語の環境下で動作させることができます。

ここでは Python のモジュールやアプリケーションを地域化するためのいくつ
かのヒントも提供しています。


GNU **gettext** API
===================

"gettext" モジュールでは、以下の GNU **gettext** API に非常に良く似た
API を提供しています。この API を使う場合、メッセージ翻訳の影響はアプ
リケーション全体に及ぼすことになります。アプリケーションが単一の言語し
か扱わず、各言語に依存する部分をユーザのロケール情報によって選ぶのなら
、ほとんどの場合この方法でやりたいことを実現できます。Python モジュー
ルを地域化していたり、アプリケーションの実行中に言語を切り替えたい場合
、おそらくクラスに基づいた API を使いたくなるでしょう。

gettext.bindtextdomain(domain[, localedir])

   *domain* をロケール辞書 *localedir* に結び付け (bind) ます。具体的
   には、 "gettext" は与えられたドメインに対するバイナリ形式の ".mo"
   ファイルを、(Unixでは) "localedir/language/LC_MESSAGES/domain.mo"
   から探します。ここで *languages* はそれぞれ環境変数 "LANGUAGE" 、
   "LC_ALL" 、 "LC_MESSAGES" 、および "LANG" の中から検索されます。

   *localedir* が省略されるか "None" の場合、現在 *domain* に結び付け
   られている内容が返されます。 [1]

gettext.bind_textdomain_codeset(domain[, codeset])

   *domain* を *codeset* に結び付けて、 "gettext()" ファミリの関数が返
   す文字列のエンコード方式を変更します。 *codeset* を省略すると、現在
   結び付けられているコードセットを返します。

   バージョン 2.4 で追加.

gettext.textdomain([domain])

   現在のグローバルドメインを調べたり変更したりします。 *domain* が
   "None" の場合、現在のグローバルドメインが返されます。それ以外の場合
   にはグローバルドメインは *domain* に設定され、設定されたグローバル
   ドメインを返します。

gettext.gettext(message)

   現在のグローバルドメイン、言語、およびロケール辞書に基づいて、
   *message* の特定地域向けの翻訳を返します。通常、ローカルな名前空間
   ではこの関数に "_()" という別名をつけます (下の例を参照してください
   )。

gettext.lgettext(message)

   "gettext()" と同じですが、 "bind_textdomain_codeset()" で特にエンコ
   ードを指定しない限り、翻訳結果を優先システムエンコーディング
   (preferred system encoding) で返します。

   バージョン 2.4 で追加.

gettext.dgettext(domain, message)

   "gettext()" と同様ですが、指定された *domain* からメッセージを探し
   ます。

gettext.ldgettext(domain, message)

   "dgettext()" と同じですが、 "bind_textdomain_codeset()" で特にエン
   コードを指定しない限り、翻訳結果を優先システムエンコーディング
   (preferred system encoding) で返します。

   バージョン 2.4 で追加.

gettext.ngettext(singular, plural, n)

   "gettext()" と同様ですが、複数形の場合を考慮しています。翻訳文字列
   が見つかった場合、 *n* の様式を適用し、その結果得られたメッセージを
   返します (言語によっては二つ以上の複数形があります)。翻訳文字列が見
   つからなかった場合、 *n* が 1 なら *singular* を返します; そうでな
   い場合 *plural* を返します。

   The Plural formula is taken from the catalog header. It is a C or
   Python expression that has a free variable *n*; the expression
   evaluates to the index of the plural in the catalog. See the GNU
   gettext documentation for the precise syntax to be used in ".po"
   files and the formulas for a variety of languages.

   バージョン 2.3 で追加.

gettext.lngettext(singular, plural, n)

   "ngettext()" と同じですが、 "bind_textdomain_codeset()" で特にエン
   コードを指定しない限り、翻訳結果を優先システムエンコーディング
   (preferred system encoding) で返します。

   バージョン 2.4 で追加.

gettext.dngettext(domain, singular, plural, n)

   "ngettext()" と同様ですが、指定された *domain* からメッセージを探し
   ます。

   バージョン 2.3 で追加.

gettext.ldngettext(domain, singular, plural, n)

   "dngettext()" と同じですが、 "bind_textdomain_codeset()" で特にエン
   コードを指定しない限り、翻訳結果を優先システムエンコーディング
   (preferred system encoding) で返します。

   バージョン 2.4 で追加.

GNU **gettext** では "dcgettext()" も定義していますが、このメソッドは
あまり有用ではないと思われるので、現在のところ実装されていません。

以下にこの API の典型的な使用法を示します:

   import gettext
   gettext.bindtextdomain('myapplication', '/path/to/my/language/directory')
   gettext.textdomain('myapplication')
   _ = gettext.gettext
   # ...
   print _('This is a translatable string.')


クラスに基づいた API
====================

The class-based API of the "gettext" module gives you more flexibility
and greater convenience than the GNU **gettext** API.  It is the
recommended way of localizing your Python applications and modules.
"gettext" defines a 「translations」 class which implements the
parsing of GNU ".mo" format files, and has methods for returning
either standard 8-bit strings or Unicode strings. Instances of this 「
translations」 class can also install themselves  in the built-in
namespace as the function "_()".

gettext.find(domain[, localedir[, languages[, all]]])

   この関数は標準的な ".mo" ファイル検索アルゴリズムを実装しています。
   "textdomain()" と同じく、 *domain* を引数にとります。オプションの
   *localedir* は "bindtextdomain()" と同じです。またオプションの
   *languages* は文字列を列挙したリストで、各文字列は言語コードを表し
   ます。

   *localedir* が与えられていない場合、標準のシステムロケールディレク
   トリが使われます。 [2] *languages* が与えられなかった場合、以下の環
   境変数: "LANGUAGE" 、 "LC_ALL" 、 "LC_MESSAGES" 、および "LANG" が
   検索されます。空でない値を返した最初の候補が *languages* 変数として
   使われます。この環境変数は言語名をコロンで分かち書きしたリストを含
   んでいなければなりません。 "find()" はこの文字列をコロンで分割し、
   言語コードの候補リストを生成します。

   "find()" は次に言語コードを展開および正規化し、リストの各要素につい
   て、以下のパス構成:

   "localedir/language/LC_MESSAGES/domain.mo"

   からなる実在するファイルの探索を反復的に行います。 "find()" は上記
   のような実在するファイルで最初に見つかったものを返します。該当する
   ファイルが見つからなかった場合、 "None" が返されます。 *all* が与え
   られていれば、全ファイル名のリストが言語リストまたは環境変数で指定
   されている順番に並べられたものを返します。

gettext.translation(domain[, localedir[, languages[, class_[, fallback[, codeset]]]]])

   Return a "Translations" instance based on the *domain*,
   *localedir*, and *languages*, which are first passed to "find()" to
   get a list of the associated ".mo" file paths.  Instances with
   identical ".mo" file names are cached.  The actual class
   instantiated is either *class_* if provided, otherwise
   "GNUTranslations".  The class’s constructor must take a single file
   object argument. If provided, *codeset* will change the charset
   used to encode translated strings.

   複数のファイルが発見された場合、後で見つかったファイルは前に見つか
   ったファイルの代替でと見なされ、後で見つかった方が利用されます。代
   替の設定を可能にするには、 "copy.copy()" を使ってキャッシュから翻訳
   オブジェクトを複製します; こうすることで、実際のインスタンスデータ
   はキャッシュのものと共有されます。

   If no ".mo" file is found, this function raises "IOError" if
   *fallback* is false (which is the default), and returns a
   "NullTranslations" instance if *fallback* is true.

   バージョン 2.4 で変更: Added the *codeset* parameter.

gettext.install(domain[, localedir[, unicode[, codeset[, names]]]])

   This installs the function "_()" in Python’s builtins namespace,
   based on *domain*, *localedir*, and *codeset* which are passed to
   the function "translation()".  The *unicode* flag is passed to the
   resulting translation object’s "install()" method.

   *names* パラメータについては、翻訳オブジェクトの "install()" メソッ
   ドの説明を参照ください。

   以下に示すように、通常はアプリケーション中の文字列を関数 "_()" の呼
   び出しで包み込んで翻訳対象候補であることを示します:

      print _('This string will be translated.')

   利便性を高めるためには、 "_()" 関数を Python の組み込み名前空間に組
   み入れる必要があります。こうすることで、アプリケーション内の全ての
   モジュールからアクセスできるようになります。

   バージョン 2.4 で変更: Added the *codeset* parameter.

   バージョン 2.5 で変更: Added the *names* parameter.


"NullTranslations" クラス
-------------------------

Translation classes are what actually implement the translation of
original source file message strings to translated message strings.
The base class used by all translation classes is "NullTranslations";
this provides the basic interface you can use to write your own
specialized translation classes.  Here are the methods of
"NullTranslations":

class gettext.NullTranslations([fp])

   Takes an optional file object *fp*, which is ignored by the base
   class. Initializes 「protected」 instance variables *_info* and
   *_charset* which are set by derived classes, as well as
   *_fallback*, which is set through "add_fallback()".  It then calls
   "self._parse(fp)" if *fp* is not "None".

   _parse(fp)

      基底クラスでは何もしない (no-op) ようになっています。このメソッ
      ドの役割はファイルオブジェクト *fp* を引数に取り、ファイルからデ
      ータを読み出し、メッセージカタログを初期化することです。サポート
      されていないメッセージカタログ形式を使っている場合、その形式を解
      釈するためにはこのメソッドを上書きしなくてはなりません。

   add_fallback(fallback)

      *fallback* を現在の翻訳オブジェクトの代替オブジェクトとして追加
      します。翻訳オブジェクトが与えられたメッセージに対して翻訳メッセ
      ージを提供できない場合、この代替オブジェクトに問い合わせることに
      なります。

   gettext(message)

      If a fallback has been set, forward "gettext()" to the fallback.
      Otherwise, return the translated message.  Overridden in derived
      classes.

   lgettext(message)

      If a fallback has been set, forward "lgettext()" to the
      fallback. Otherwise, return the translated message.  Overridden
      in derived classes.

      バージョン 2.4 で追加.

   ugettext(message)

      If a fallback has been set, forward "ugettext()" to the
      fallback. Otherwise, return the translated message as a Unicode
      string. Overridden in derived classes.

   ngettext(singular, plural, n)

      If a fallback has been set, forward "ngettext()" to the
      fallback. Otherwise, return the translated message.  Overridden
      in derived classes.

      バージョン 2.3 で追加.

   lngettext(singular, plural, n)

      If a fallback has been set, forward "lngettext()" to the
      fallback. Otherwise, return the translated message.  Overridden
      in derived classes.

      バージョン 2.4 で追加.

   ungettext(singular, plural, n)

      If a fallback has been set, forward "ungettext()" to the
      fallback. Otherwise, return the translated message as a Unicode
      string. Overridden in derived classes.

      バージョン 2.3 で追加.

   info()

      「protected」 の "_info" 変数を返します。

   charset()

      Return the 「protected」 "_charset" variable.

   output_charset()

      Return the 「protected」 "_output_charset" variable, which
      defines the encoding used to return translated messages.

      バージョン 2.4 で追加.

   set_output_charset(charset)

      翻訳メッセージとして返す文字列のエンコードを決める、 「protected
      」 の変数 "_output_charset" を変更します。

      バージョン 2.4 で追加.

   install([unicode[, names]])

      If the *unicode* flag is false, this method installs
      "self.gettext()" into the built-in namespace, binding it to "_".
      If *unicode* is true, it binds "self.ugettext()" instead.  By
      default, *unicode* is false.

      If the *names* parameter is given, it must be a sequence
      containing the names of functions you want to install in the
      builtins namespace in addition to "_()".  Supported names are
      "'gettext'" (bound to "self.gettext()" or "self.ugettext()"
      according to the *unicode* flag), "'ngettext'" (bound to
      "self.ngettext()" or "self.ungettext()" according to the
      *unicode* flag), "'lgettext'" and "'lngettext'".

      この方法はアプリケーションで "_()" 関数を利用できるようにするた
      めの最も便利な方法ですが、唯一の手段でもあるので注意してください
      。この関数はアプリケーション全体、とりわけ組み込み名前空間に影響
      するので、地域化されたモジュールで "_()" を組み入れることができ
      ないのです。その代わりに、以下のコードを使って "_()" を使えるよ
      うにしなければなりません。:

         import gettext
         t = gettext.translation('mymodule', ...)
         _ = t.gettext

      この操作は "_()" をモジュール内だけのグローバル名前空間に組み入
      れるので、モジュール内の "_()" の呼び出しだけに影響します。

      バージョン 2.5 で変更: Added the *names* parameter.


"GNUTranslations" クラス
------------------------

The "gettext" module provides one additional class derived from
"NullTranslations": "GNUTranslations".  This class overrides
"_parse()" to enable reading GNU **gettext** format ".mo" files in
both big-endian and little-endian format. It also coerces both message
ids and message strings to Unicode.

"GNUTranslations" parses optional meta-data out of the translation
catalog.  It is convention with GNU **gettext** to include meta-data
as the translation for the empty string.  This meta-data is in **RFC
822**-style "key: value" pairs, and should contain the "Project-Id-
Version" key.  If the key "Content-Type" is found, then the "charset"
property is used to initialize the 「protected」 "_charset" instance
variable, defaulting to "None" if not found.  If the charset encoding
is specified, then all message ids and message strings read from the
catalog are converted to Unicode using this encoding.  The
"ugettext()" method always returns a Unicode, while the "gettext()"
returns an encoded 8-bit string.  For the message id arguments of both
methods, either Unicode strings or 8-bit strings containing only US-
ASCII characters are acceptable.  Note that the Unicode version of the
methods (i.e. "ugettext()" and "ungettext()") are the recommended
interface to use for internationalized Python programs.

key/value ペアの集合全体は辞書型データ中に配置され、」保護された」
"_info" インスタンス変数に設定されます。

If the ".mo" file’s magic number is invalid, or if other problems
occur while reading the file, instantiating a "GNUTranslations" class
can raise "IOError".

以下のメソッドは基底クラスの実装からオーバライドされています:

GNUTranslations.gettext(message)

   Look up the *message* id in the catalog and return the
   corresponding message string, as an 8-bit string encoded with the
   catalog’s charset encoding, if known.  If there is no entry in the
   catalog for the *message* id, and a fallback has been set, the look
   up is forwarded to the fallback’s "gettext()" method. Otherwise,
   the *message* id is returned.

GNUTranslations.lgettext(message)

   Equivalent to "gettext()", but the translation is returned in the
   preferred system encoding, if no other encoding was explicitly set
   with "set_output_charset()".

   バージョン 2.4 で追加.

GNUTranslations.ugettext(message)

   Look up the *message* id in the catalog and return the
   corresponding message string, as a Unicode string.  If there is no
   entry in the catalog for the *message* id, and a fallback has been
   set, the look up is forwarded to the fallback’s "ugettext()"
   method.  Otherwise, the *message* id is returned.

GNUTranslations.ngettext(singular, plural, n)

   Do a plural-forms lookup of a message id.  *singular* is used as
   the message id for purposes of lookup in the catalog, while *n* is
   used to determine which plural form to use.  The returned message
   string is an 8-bit string encoded with the catalog’s charset
   encoding, if known.

   メッセージ id がカタログ中に見つからず、フォールバックオブジェクト
   が指定されている場合、メッセージ検索要求はフォールバックオブジェク
   トの "ngettext()" メソッドに転送されます。そうでない場合、 *n* が 1
   ならば *singular* が返され、それ以外に対しては *plural* が返されま
   す。

   バージョン 2.3 で追加.

GNUTranslations.lngettext(singular, plural, n)

   Equivalent to "gettext()", but the translation is returned in the
   preferred system encoding, if no other encoding was explicitly set
   with "set_output_charset()".

   バージョン 2.4 で追加.

GNUTranslations.ungettext(singular, plural, n)

   メッセージ id に対する複数形を検索します。カタログに対する検索では
   *singular* がメッセージ id として用いられ、 *n* にはどの複数形を用
   いるかを指定します。返されるメッセージ文字列は Unicode 文字列です。

   If the message id is not found in the catalog, and a fallback is
   specified, the request is forwarded to the fallback’s "ungettext()"
   method.  Otherwise, when *n* is 1 *singular* is returned, and
   *plural* is returned in all other cases.

   以下に例を示します。:

      n = len(os.listdir('.'))
      cat = GNUTranslations(somefile)
      message = cat.ungettext(
          'There is %(num)d file in this directory',
          'There are %(num)d files in this directory',
          n) % {'num': n}

   バージョン 2.3 で追加.


Solaris メッセージカタログ機構のサポート
----------------------------------------

Solaris オペレーティングシステムでは、独自の ".mo" バイナリファイル形
式を定義していますが、この形式に関するドキュメントが手に入らないため、
現時点ではサポートされていません。


Catalog コンストラクタ
----------------------

GNOME では、James Henstridge によるあるバージョンの "gettext" モジュー
ルを使っていますが、このバージョンは少し異なった API を持っています。
ドキュメントに書かれている利用法は:

   import gettext
   cat = gettext.Catalog(domain, localedir)
   _ = cat.gettext
   print _('hello world')

となっています。過去のモジュールとの互換性のために、 "Catalog()" は前
述の "translation()" 関数の別名になっています。

このモジュールと Henstridge のバージョンとの間には一つ相違点があります
: 彼のカタログオブジェクトはマップ型の API を介したアクセスがサポート
されていましたが、この API は使われていないらしく、現在はサポートされ
ていません。


プログラムやモジュールを国際化する
==================================

国際化 (I18N, I-nternationalizatio-N) とは、プログラムを複数の言語に対
応させる操作を指します。地域化 (L10N, L-ocalizatio-N) とは、すでに国際
化されているプログラムを特定地域の言語や文化的な事情に対応させることを
指します。Python プログラムに多言語メッセージ機能を追加するには、以下
の手順を踏む必要があります:

1. プログラムやモジュールで翻訳対象とする文字列に特殊なマークをつけ
   て 準備します

2. マークづけをしたファイルに一連のツールを走らせ、生のメッセージカ
   タ ログを生成します

3. 特定の言語へのメッセージカタログの翻訳を作成します

4. メッセージ文字列を適切に変換するために "gettext" モジュールを使
   いま す

ソースコードを I18N 化する準備として、ファイル内の全ての文字列を探す必
要があります。翻訳を行う必要のある文字列はどれも "_('...')" — すなわち
関数 "_()" の呼び出しで包むことでマーク付けしなくてはなりません。例え
ば以下のようにします:

   filename = 'mylog.txt'
   message = _('writing a log message')
   fp = open(filename, 'w')
   fp.write(message)
   fp.close()

この例では、文字列 "'writing a log message'" が翻訳対象候補としてマー
ク付けされており、文字列 "'mylog.txt'" および "'w'" はされていません。

The Python distribution comes with two tools which help you generate
the message catalogs once you’ve prepared your source code.  These may
or may not be available from a binary distribution, but they can be
found in a source distribution, in the "Tools/i18n" directory.

The **pygettext** [3] program scans all your Python source code
looking for the strings you previously marked as translatable.  It is
similar to the GNU **gettext** program except that it understands all
the intricacies of Python source code, but knows nothing about C or
C++ source code.  You don’t need GNU "gettext" unless you’re also
going to be translating C code (such as C extension modules).

**pygettext** generates textual Uniforum-style human readable message
catalog ".pot" files, essentially structured human readable files
which contain every marked string in the source code, along with a
placeholder for the translation strings. **pygettext** is a command
line script that supports a similar command line interface as
**xgettext**; for details on its use, run:

   pygettext.py --help

Copies of these ".pot" files are then handed over to the individual
human translators who write language-specific versions for every
supported natural language.  They send you back the filled in
language-specific versions as a ".po" file.  Using the **msgfmt.py**
[4] program (in the "Tools/i18n" directory), you take the ".po" files
from your translators and generate the machine-readable ".mo" binary
catalog files. The ".mo" files are what the "gettext" module uses for
the actual translation processing during run-time.

"gettext" モジュールをソースコード中でどのように使うかは単一のモジュー
ルを国際化するのか、それともアプリケーション全体を国際化するのかにより
ます。次のふたつのセクションで、それぞれについて説明します。


モジュールを地域化する
----------------------

モジュールを地域化する場合、グローバルな変更、例えば組み込み名前空間へ
の変更を行わないように注意しなければなりません。GNU "gettext" API では
なく、クラスベースの API を使うべきです。

仮に対象のモジュール名を 「spam」 とし、モジュールの各言語における翻訳
が収められた ".mo" ファイルが "/usr/share/locale" に GNU **gettext**
形式で置かれているとします。この場合、モジュールの最初で以下のようにし
ます:

   import gettext
   t = gettext.translation('spam', '/usr/share/locale')
   _ = t.lgettext

If your translators were providing you with Unicode strings in their
".po" files, you’d instead do:

   import gettext
   t = gettext.translation('spam', '/usr/share/locale')
   _ = t.ugettext


アプリケーションを地域化する
----------------------------

アプリケーションを地域化するのなら、関数 "_()" をグローバルな組み込み
名前空間に組み入れなければならず、これは通常アプリケーションの主ドライ
バ (main driver) ファイルで行います。この操作によって、アプリケーショ
ン独自のファイルは明示的に各ファイルで "_()" の組み入れを行わなくても
単に "_('...')" を使うだけで済むようになります。

単純な場合では、単に以下の短いコードをアプリケーションの主ドライバファ
イルに追加するだけです:

   import gettext
   gettext.install('myapplication')

If you need to set the locale directory or the *unicode* flag, you can
pass these into the "install()" function:

   import gettext
   gettext.install('myapplication', '/usr/share/locale', unicode=1)


動作中 (on the fly) に言語を切り替える
--------------------------------------

多くの言語を同時にサポートする必要がある場合、複数の翻訳インスタンスを
生成して、例えば以下のコードのように、インスタンスを明示的に切り替えて
もかまいません。:

   import gettext

   lang1 = gettext.translation('myapplication', languages=['en'])
   lang2 = gettext.translation('myapplication', languages=['fr'])
   lang3 = gettext.translation('myapplication', languages=['de'])

   # start by using language1
   lang1.install()

   # ... time goes by, user selects language 2
   lang2.install()

   # ... more time goes by, user selects language 3
   lang3.install()


翻訳処理の遅延解決
------------------

コードを書く上では、ほとんどの状況で文字列はコードされた場所で翻訳され
ます。しかし場合によっては、翻訳対象として文字列をマークはするが、その
後実際に翻訳が行われるように遅延させる必要が生じます。古典的な例は以下
のようなコートです:

   animals = ['mollusk',
              'albatross',
              'rat',
              'penguin',
              'python', ]
   # ...
   for a in animals:
       print a

ここで、リスト "animals" 内の文字列は翻訳対象としてマークはしたいが、
文字列が出力されるまで実際に翻訳を行うのは避けたいとします。

こうした状況を処理する一つの方法を以下に示します:

   def _(message): return message

   animals = [_('mollusk'),
              _('albatross'),
              _('rat'),
              _('penguin'),
              _('python'), ]

   del _

   # ...
   for a in animals:
       print _(a)

ダミーの "_()" 定義が単に文字列をそのまま返すようになっているので、上
のコードはうまく動作します。かつ、このダミーの定義は、組み込み名前空間
に置かれた "_()" の定義で ("del" 命令を実行するまで) 一時的に上書きす
ることができます。もしそれまでに "_()" をローカルな名前空間に持ってい
たら注意してください。

Note that the second use of "_()" will not identify 「a」 as being
translatable to the **pygettext** program, since it is not a string.

もう一つの処理法は、以下の例のようなやり方です:

   def N_(message): return message

   animals = [N_('mollusk'),
              N_('albatross'),
              N_('rat'),
              N_('penguin'),
              N_('python'), ]

   # ...
   for a in animals:
       print _(a)

In this case, you are marking translatable strings with the function
"N_()", [5] which won’t conflict with any definition of "_()".
However, you will need to teach your message extraction program to
look for translatable strings marked with "N_()". **pygettext** and
**xpot** both support this through the use of command line switches.


"gettext()" vs. "lgettext()"
----------------------------

In Python 2.4 the "lgettext()" family of functions were introduced.
The intention of these functions is to provide an alternative which is
more compliant with the current implementation of GNU gettext. Unlike
"gettext()", which returns strings encoded with the same codeset used
in the translation file, "lgettext()" will return strings encoded with
the preferred system encoding, as returned by
"locale.getpreferredencoding()". Also notice that Python 2.4
introduces new functions to explicitly choose the codeset used in
translated strings. If a codeset is explicitly set, even "lgettext()"
will return translated strings in the requested codeset, as would be
expected in the GNU gettext implementation.


謝辞
====

以下の人々が、このモジュールのコード、フィードバック、設計に関する助言
、過去の実装、そして有益な経験談による貢献をしてくれました:

* Peter Funk

* James Henstridge

* Juan David Ibáñez Palomar

* Marc-André Lemburg

* Martin von Löwis

* François Pinard

* Barry Warsaw

* Gustavo Niemeyer

-[ 脚注 ]-

[1] 標準でロケールが収められているディレクトリはシステム依存です;
    例え ば、RedHat Linux では "/usr/share/locale" ですが、 Solaris で
    は "/usr/lib/locale" です。 "gettext" モジュールはこうしたシステム
    依 存の標準設定をサポートしません; その代わりに
    "sys.prefix/share/locale" を標準の設定とします。この理由から、常に
    アプリケーションの開始時に絶対パスで明示的に指定して
    "bindtextdomain()" を呼び出すのが最良のやり方ということになります
    。

[2] 上の "bindtextdomain()" に関する脚注を参照してください。

[3] François Pinard has written a program called **xpot** which
    does a similar job.  It is available as part of his po-utils
    package.

[4] **msgfmt.py** is binary compatible with GNU **msgfmt** except
    that it provides a simpler, all-Python implementation.  With this
    and **pygettext.py**, you generally won’t need to install the GNU
    **gettext** package to internationalize your Python applications.

[5] The choice of "N_()" here is totally arbitrary; it could have
    just as easily been "MarkThisStringForTranslation()".
