バージョンごとのドキュメント一覧

57.1. 翻訳者へ #

<title>For the Translator</title>

<productname>PostgreSQL</productname> programs (server and client) can issue their messages in your favorite language &mdash; if the messages have been translated. Creating and maintaining translated message sets needs the help of people who speak their own language well and want to contribute to the <productname>PostgreSQL</productname> effort. You do not have to be a programmer at all to do this. This section explains how to help. PostgreSQLプログラムは(サーバ、クライアントともに)メッセージが翻訳されていれば、使い慣れた言語でそのメッセージを出すことができます。 翻訳メッセージセットの作成と保守は、自分の言語を上手に話しPostgreSQLの成果に貢献したい人々の協力が必要です。 この作業にはプログラマである必要はまったくありません。 本節ではお手伝いの仕方を説明します。

57.1.1. 必要条件 #

<title>Requirements</title>

We won't judge your language skills &mdash; this section is about software tools. Theoretically, you only need a text editor. But this is only in the unlikely event that you do not want to try out your translated messages. When you configure your source tree, be sure to use the <option>&#45;-enable-nls</option> option. This will also check for the <application>libintl</application> library and the <filename>msgfmt</filename> program, which all end users will need anyway. To try out your work, follow the applicable portions of the installation instructions. 協力者の言語の熟練度については判断しません。 本節ではソフトウェアツールについて説明します。 理論的には、テキストエディタのみが必要です。 しかし、これは自分で作成した翻訳メッセージを試そうとはしないという、あまりあり得ない場合のみです。 ソースツリーを構築する際に、--enable-nlsオプションを使用していることを確認してください。 これにより、全てのエンドユーザがとにかく必要とする、libintlライブラリとmsgfmtプログラムも同時に検査されます。 作業を試す際には、インストール手順の適切な部分に従ってください。

If you want to start a new translation effort or want to do a message catalog merge (described later), you will need the programs <filename>xgettext</filename> and <filename>msgmerge</filename>, respectively, in a GNU-compatible implementation. Later, we will try to arrange it so that if you use a packaged source distribution, you won't need <filename>xgettext</filename>. (If working from Git, you will still need it.) <application>GNU Gettext 0.10.36</application> or later is currently recommended. 新規に翻訳作業を始めるか、(後述の)メッセージカタログのマージを行いたい場合、GNU版と互換性を持った実装のxgettextmsgmergeという2つのプログラムがそれぞれ必要です。 将来はパッケージ化されたソース配布物を使用する場合にxgettextを必要としないように変更する予定です (Git版で作業をしているのであれば、まだこれが必要です)。 現在GNU Gettext 0.10.36以上を推奨します。

Your local gettext implementation should come with its own documentation. Some of that is probably duplicated in what follows, but for additional details you should look there. 使用するマシンのgettextの実装については、文書が一緒に付いてくると思います。 以下のいくつかはおそらく重複していますが、追補すべき詳細についてはその文書を参照してください。

57.1.2. 概念 #

<title>Concepts</title>

The pairs of original (English) messages and their (possibly) translated equivalents are kept in <firstterm>message catalogs</firstterm>, one for each program (although related programs can share a message catalog) and for each target language. There are two file formats for message catalogs: The first is the <quote>PO</quote> file (for Portable Object), which is a plain text file with special syntax that translators edit. The second is the <quote>MO</quote> file (for Machine Object), which is a binary file generated from the respective PO file and is used while the internationalized program is run. Translators do not deal with MO files; in fact hardly anyone does. 英語による元のメッセージとそれを基に(場合によって)翻訳されたメッセージの組み合わせはメッセージカタログに、(関連するプログラムはメッセージカタログを共有することができますが)各プログラム、対象とする言語に対して一つずつ保持されます。 メッセージカタログには2つのファイル形式があります。 1つはPOファイル(移植可能オブジェクト-Portable Object-を意味します)で翻訳者が編集する特別な構文を持った平文ファイルです。 2番目はMOファイル(マシンオブジェクト-Machine Object-を意味します)で対応するPOファイルから生成され、国際化プログラムの実行の際に使用されるバイナリファイルです。 翻訳者は、MOファイルを扱いません。 実際に扱うことは困難です。

The extension of the message catalog file is to no surprise either <filename>.po</filename> or <filename>.mo</filename>. The base name is either the name of the program it accompanies, or the language the file is for, depending on the situation. This is a bit confusing. Examples are <filename>psql.po</filename> (PO file for psql) or <filename>fr.mo</filename> (MO file in French). メッセージカタログファイルの拡張子は想像していたかもしれませんが.poもしくは.moです。 基本名(拡張子を除いた部分)は、プログラムが伴っている名前、もしくは翻訳目的とする言語の名前のいずれかで、状況によって変わります。 少し混乱するかもしれません。 例えば、psql.po(psql用のPOファイル)、もしくはfr.mo(フランス語用のMOファイル)です。

The file format of the PO files is illustrated here: POファイルの書式を以下に示します。

# comment

msgid "original string"
msgstr "translated string"

msgid "more original"
msgstr "another translated"
"string can be broken up like this"

...

The msgid lines are extracted from the program source. (They need not be, but this is the most common way.) The msgstr lines are initially empty and are filled in with useful strings by the translator. The strings can contain C-style escape characters and can be continued across lines as illustrated. (The next line must start at the beginning of the line.) msgid行はプログラムのソースから抽出されます。 (これは必要はありませんが最も一般的な方法です。) msgstr行は初期状態では空であり、翻訳者によって有益な文字列が埋め込まれます。 この文字列には、C言語形式のエスケープ文字を含めることも、上に示したように複数行にまたがって続けることもできます。 (継続行は必ず行の先頭から始まらなければなりません。)

The # character introduces a comment. If whitespace immediately follows the # character, then this is a comment maintained by the translator. There can also be automatic comments, which have a non-whitespace character immediately following the #. These are maintained by the various tools that operate on the PO files and are intended to aid the translator. #文字はコメントの開始を示します。 #文字の直後に空白文字があった場合、それは翻訳者によって保守されるコメントです。 #の直後に非空白文字が付く、自動的に付与されるコメントもあります。 これらは、POファイルに対する操作を行う各種ツールによって保守され、翻訳者の補助を意図しています。

#. automatic comment
#: filename.c:1023
#, flags, flags

The #. style comments are extracted from the source file where the message is used. Possibly the programmer has inserted information for the translator, such as about expected alignment. The #: comments indicate the exact locations where the message is used in the source. The translator need not look at the program source, but can if there is doubt about the correct translation. The #, comments contain flags that describe the message in some way. There are currently two flags: <literal>fuzzy</literal> is set if the message has possibly been outdated because of changes in the program source. The translator can then verify this and possibly remove the fuzzy flag. Note that fuzzy messages are not made available to the end user. The other flag is <literal>c-format</literal>, which indicates that the message is a <function>printf</function>-style format template. This means that the translation should also be a format string with the same number and type of placeholders. There are tools that can verify this, which key off the c-format flag. #.スタイルのコメントはそのメッセージが使用されているソースファイルから抽出されます。 おそらくプログラマが、翻訳者のために追加した、そのようにしてほしいと考える体裁についてなどの情報です。 #:コメントは、ソース内でそのメッセージが使用される正確な場所を示します。 翻訳者はプログラムソースを参照する必要はありませんが、翻訳の正確さに疑問がある場合にソースを参照することができます。 #,コメントは何らかの方法でメッセージを説明するフラグです。 現在、2つのフラグがあります。 そのメッセージがプログラムソースの変更によって古いものとなった可能性がある場合、fuzzyが設定されます。 翻訳者はこれを検証し、fuzzyフラグを削除できます。 fuzzyメッセージはエンドユーザからは利用できないことに注意してください。 もう1つのフラグはc-formatで、そのメッセージがprintf形式の書式テンプレートであることを示します。 これは、翻訳側もプレースホルダの型と同じ番号を持った書式文字列でなければならないことを意味します。 これを検証するツールがあり、それらはc-formatフラグを入力として受け取ります。

57.1.3. メッセージカタログの作成と保守 #

<title>Creating and Maintaining Message Catalogs</title>

OK, so how does one create a <quote>blank</quote> message catalog? First, go into the directory that contains the program whose messages you want to translate. If there is a file <filename>nls.mk</filename>, then this program has been prepared for translation. さて、空のメッセージカタログをどうやって作成するのでしょうか。 まず、翻訳したいメッセージを持つプログラムが存在するディレクトリに移動します。 nls.mkファイルがあればこのプログラムは翻訳の準備が整っています。

If there are already some <filename>.po</filename> files, then someone has already done some translation work. The files are named <filename><replaceable>language</replaceable>.po</filename>, where <replaceable>language</replaceable> is the <ulink url="https://www.loc.gov/standards/iso639-2/php/English_list.php"> ISO 639-1 two-letter language code (in lower case)</ulink>, e.g., <filename>fr.po</filename> for French. If there is really a need for more than one translation effort per language then the files can also be named <filename><replaceable>language</replaceable>_<replaceable>region</replaceable>.po</filename> where <replaceable>region</replaceable> is the <ulink url="https://www.iso.org/iso-3166-country-codes.html"> ISO 3166-1 two-letter country code (in upper case)</ulink>, e.g., <filename>pt_BR.po</filename> for Portuguese in Brazil. If you find the language you wanted you can just start working on that file. もし、.poファイルが数個既にあれば、誰かがある翻訳作業を行っています。 そのファイルはlanguage.po と名前が付けられています。 ここで、languageISO 639-1の2文字言語コード(小文字)を表します。 例えば、fr.poはフランス語用です。 1つの言語に複数の翻訳成果が必要である場合そのファイルの名前はlanguage_region.poのようになります。 ここで、regionISO 3166-1の2文字国コード(大文字)を表します。 例えば、pt_BR.poはブラジルでのポルトガル語用を示します。 翻訳対象とする言語用のファイルがあれば、それを基に作業を始めることができます。

If you need to start a new translation effort, then first run the command: 新規に翻訳を始める必要がある場合、以下のコマンドを最初に実行してください。

make init-po

This will create a file <filename><replaceable>progname</replaceable>.pot</filename>. (<filename>.pot</filename> to distinguish it from PO files that are <quote>in production</quote>. The <literal>T</literal> stands for <quote>template</quote>.) Copy this file to <filename><replaceable>language</replaceable>.po</filename> and edit it. To make it known that the new language is available, also edit the file <filename>po/LINGUAS</filename> and add the language (or language and country) code next to languages already listed, like: これは、progname.potファイルを作成します。 (.pot実用のPOファイルと区別するためのものです。 Tテンプレートを意味します。) このファイルをlanguage.poにコピーして編集します。 新規の言語が利用可能になったことを知らせるために、po/LINGUASを編集し、言語(もしくは言語と国)コードを既存の言語リストの後に以下のように追加してください。

de fr

(Other languages can appear, of course.) (もちろん他の言語があるかもしれません。)

As the underlying program or library changes, messages might be changed or added by the programmers. In this case you do not need to start from scratch. Instead, run the command: 対象のプログラムやライブラリの変更に伴い、メッセージはプログラマによって変更、追加されます。 この場合は始めからやり直す必要はありません。 その代わりに以下のコマンドを実行してください。

make update-po

which will create a new blank message catalog file (the pot file you started with) and will merge it with the existing PO files. If the merge algorithm is not sure about a particular message it marks it <quote>fuzzy</quote> as explained above. The new PO file is saved with a <filename>.po.new</filename> extension. そうすると新しい空のメッセージカタログファイル(最初に使用したpotファイル)が作成され、既存のPOファイルにマージされます。 このマージのアルゴリズムが特定のメッセージに関して確実でない場合、それは上で説明したfuzzyとなります。 新規POファイルは.po.newという拡張子付きで保存されます。

57.1.4. POファイルの編集 #

<title>Editing the PO Files</title>

The PO files can be edited with a regular text editor. There are also several specialized editors for PO files which can help the process with translation specific features. There is (unsurprisingly) a PO mode for Emacs, which can be quite useful. POファイルは普通のテキストエディタで編集できます。 翻訳に特化した機能で作業を補助する、POファイルに特化したエディタもいくつかあります。 Emacsには(予想通り)POモードがあり、非常に使いやすいものです。

The translator should only change the area between the quotes after the msgstr directive, add comments, and alter the fuzzy flag. 翻訳者はmsgstrディレクティブの後の引用符の間の部分の変更、コメントの追加、fuzzyフラグの変更のみを行えばよいのです。

The PO files need not be completely filled in. The software will automatically fall back to the original string if no translation (or an empty translation) is available. It is no problem to submit incomplete translations for inclusions in the source tree; that gives room for other people to pick up your work. However, you are encouraged to give priority to removing fuzzy entries after doing a merge. Remember that fuzzy entries will not be installed; they only serve as reference for what might be the right translation. POファイルを完全に埋めることは必要ありません。 ソフトウェアは使用できる翻訳がない(もしくは翻訳が空の)場合自動的に元の文字列に戻します。 他の人が作業を引き継ぐことができますので、ソースツリー内に不完全な翻訳を含めることにも問題はありません。 しかし、マージの後のfuzzyフラグを削除することを優先に考えることが推奨されています。 fuzzyエントリはインストールされないことを忘れないでください。 これらは何が正しい翻訳になり得るかの参照のためにのみ提供されています。

Here are some things to keep in mind while editing the translations: 以下に、翻訳の編集を行う際に注意すべき点を示します。

  • Make sure that if the original ends with a newline, the translation does, too. Similarly for tabs, etc. 元の文字列の終端が改行の場合、翻訳も同様になっていることを確認してください。 タブなども同様です。

  • If the original is a <function>printf</function> format string, the translation also needs to be. The translation also needs to have the same format specifiers in the same order. Sometimes the natural rules of the language make this impossible or at least awkward. In that case you can modify the format specifiers like this: 元がprintf書式文字列の場合、翻訳も同じでなければなりません。 また、翻訳は同じ書式識別子を同じ順番で持たなければなりません。 言語固有の規則によっては不可能な場合や扱いづらい場合も起こります。 このような場合は、以下の書式指定子を使用することができます。

    msgstr "Die Datei %2$s hat %1$u Zeichen."
    

    Then the first placeholder will actually use the second argument from the list. The <literal><replaceable>digits</replaceable>$</literal> needs to follow the % immediately, before any other format manipulators. (This feature really exists in the <function>printf</function> family of functions. You might not have heard of it before because there is little use for it outside of message internationalization.) そして、リストの最初のプレースホルダが実際にはこのリストの2番目の引数に使用されます。 digits$は%の直後に続く必要があり、他の書式の操作の前に使用する必要があります。 (この機能はprintf系の関数に本当に存在するものです。 メッセージ国際化以外ではほとんど使用されませんので、聞いたことがないかもしれません。)

  • If the original string contains a linguistic mistake, report that (or fix it yourself in the program source) and translate normally. The corrected string can be merged in when the program sources have been updated. If the original string contains a factual mistake, report that (or fix it yourself) and do not translate it. Instead, you can mark the string with a comment in the PO file. 元の文字列に言語上の間違いがある場合、それを報告し(もしくはプログラムソースを直して)、普通に翻訳してください。 修正された文字列は、プログラムのソースが修正された時にマージ可能になります。 元の文字列が事実と異なる場合、それを報告し(もしくは自ら直して)、翻訳を行わないでください。 その代わりに、POファイルのその文字列にコメントを付けてください。

  • Maintain the style and tone of the original string. Specifically, messages that are not sentences (<literal>cannot open file %s</literal>) should probably not start with a capital letter (if your language distinguishes letter case) or end with a period (if your language uses punctuation marks). It might help to read <xref linkend="error-style-guide"/>. 元の文字列のスタイルや調子を維持してください。 特に、(cannot open file %sなど)文章になっていないメッセージは、(翻訳する言語が大文字小文字を区別するのであれば)おそらく最初の文字を大文字にしてはなりませんし、(翻訳する言語が句読点として使用しているのであれば)ピリオドを終わりに付けてはいけません。 56.3を読むと参考になります。

  • If you don't know what a message means, or if it is ambiguous, ask on the developers' mailing list. Chances are that English speaking end users might also not understand it or find it ambiguous, so it's best to improve the message. メッセージの意味がわからない時や、曖昧な場合は、開発者用のメーリングリストに問い合わせてください。 英語を話すエンドユーザも理解できない、または曖昧であると判断することができる機会となり、メッセージの改良を行う最善のものです。