Differences between revisions 11 and 12
Revision 11 as of 2011-11-15 15:26:21
Size: 13076
Comment: sync with TranslatingMercurial@84
Revision 12 as of 2012-06-21 15:35:46
Size: 13009
Comment: sync with TranslatingMercurial@85
Deletions are marked like this. Additions are marked like this.
Line 170: Line 170:
 * German (TobiasBell) -- Development takes place at http://bitbucket.org/FabianKreutz/hg-i18n-de/  * [[GermanTranslation|German]]

Mercurial の国際化

このページでは、 Mercurial のメッセージを得意な言語に翻訳することで Mercurial の国際化を手伝う方法を説明しています。 Mercurial では標準的な国際化ライブラリ Gettext を利用しており、ここでその詳細は説明しません。 ソフトウェアの翻訳に不慣れな方は、Gettext のマニュアルをご覧ください。

1. 翻訳を始める

Mercurial が使い慣れた言葉に訳されていないと分かれば、翻訳を始めるチャンスです。 まず、その言語への翻訳が進行していないことを、このページの最後を見るか、開発用 MailingList に問い合わせるかして確認しましょう。 Transifex リストもあります。

翻訳メッセージは i18n/ ディレクトリの xx.poxx_yy.po というファイルに保存されます。 xx は言語コードに、 yy は国コード(省略可)に対応しています。言語コードは ISO 639-1 一覧 から、また、国コードは必要であれば ISO 3166 list から取得できます。

翻訳を新規に始めるには、まず i18n/hg.pot ファイルを作成します。 Makefile で作成しましょう:

% make update-pot

次に、 hg.pot から翻訳メッセージファイルを作成します。 msginit コマンドを使うか、 hg.pot ファイルを適当な xx.po にコピーするかして翻訳を始めます。

それでは、 xx.po ファイルを好みの PO エディタ(Poedit や Emacs など)で編集しましょう。 xx.po ファイルは普通のテキストエディタ(WordPad など)でも編集できますが、その場合はフォーマットを崩さないように注意しなければなりません。

翻訳メッセージを適用するには、 xx.po ファイルを xx.mo へコンパイルする必要があります。 msgfmt コマンドがインストールされていれば、次のようにしてコンパイルできます:

% python setup.py build_mo

別の方法として、 Poedit などの PO エディタでコンパイルすることも可能です。その場合、hg.mo というファイルが生成されるはずですので、それを次の場所に保存してください。

locale/xx/LC_MESSAGES/hg.mo

setup.py は自動的にこの作業を行います。 xx.po を手動でコンパイルした場合は、ディレクトリ構造を自分で準備しなければなりません。

では、 LANGUAGE 環境変数を確実に 'xx' へセットしましょう。 Bash系のシェルであれば、次のようにしてください:

% export LANGUAGE=xx

それから、 hg コマンドを実行し、翻訳メッセージが選択されているか確かめます。

2. 翻訳を更新する

Mercurial のソースコードに変更が加わると、翻訳すべきメッセージが出てきます。 これらは現状の翻訳メッセージへ簡単に反映できます: 前述の方法で hg.pot を再生成し、 msgmerge コマンドで新しく加わったメッセージを翻訳メッセージへマージするだけです:

msgmerge --no-location --update i18n/xx.po i18n/hg.pot

po ファイルを make しても同じです。

make i18n/xx.po

hg.pot の再生成と msgmerge を一続きに実行しています。

それでは、新規のメッセージを訳して、 xx.mo ファイルを作りますか。 When you commit the updated translation, use

i18n-xx: synchronized with NODE

where NODE is either the changeset hash of your working copy parent revision before the commit or (better) the hash of its most recent ancestor that changed a translated message.

翻訳中にファイル名と行番号を残しておきたい場合は、上記コマンドを --no-location フラグなしで実行してください。 ファイル名と行番号が hg.pot から xx.po` へマージされ、ソースコードの特定箇所にジャンプし易くなります。

ただし、ムダな差分ができてしまうため、翻訳のコミット前にはファイル名と行番号を取り除かなければなりません。

msgcat --no-location -o xx.po xx.po

パッチに不要な変更が含まれていないか、 hg diff でチェックする習慣をつけてください。

3. 提出

If you are making a new translation, then please notify MartinGeisler. irc.freenode.net#mercurial (contact mg) へ参加し、翻訳を pull 可能な URL を提供するのが簡単です。 そうすると、変更点は彼の手で i18n queue へ push され、ゆくゆくはメインリポジトリへ pull されます。

Your commit messages should have this format:

i18n-xx: short description

For a new translation, the first changesets could look like this:

i18n-xx: new translation
i18n-xx: translated add, log, diff
i18n-xx: translated status

If your change concerns the stable branch, then please remember to update to that branch. It is then imperative that you merge the stable branch into the default branch. The rule is that your xx repository must always be a superset of your xx-stable repository. That will ensure that i18n remains a superset of i18n-stable and so no merges will be necessary later.

Please rebase your changesets to the tip of the target repository before pushing them to the hg-i18n repository (use hg rebase). That will keep the number of merges to a minimum and simplify the history graph.

In general, your working cycle can look like this:

  • modify xx.po and commit it (in your xx repository)

  • once in a while (especially before pushing), do a hg pull --rebase

  • run make local to rebuild the .mo files

  • test your translation with ./hg (make sure first that $LANGUAGE equals xx)

  • run make test-gendoc.t to make sure that you don't introduce reStructuredText syntax errors (you will need docutils for that, e.g. package python-docutils in Debian/Ubuntu)

  • when you are happy with your translation push it to hg-i18n

4. フォーマット

コマンドヘルプを翻訳する時は、半角78文字で折り返す必要があります。次のパターンに従ってください:

簡単な説明、小文字始まり

    コマンドの詳しい説明。各段落は4文字分インデントし、半角70文字で折り返す
    必要があります。

    段落は空行1つで区切ります。 文の区切りには半角空白を1文字を入れます。

5. アドバイス

便利なワザをここに載せてください。

5.1. Possible repository setup

Although you can use any repository to keep track of your translation progress, the following setup may prove handy:

  • create a Bitbucket repository by forking the i18n queue; you need a Bitbucket account for that

  • clone that repository on your machine
  • work on the clone: edit, commit, pull changes from the i18n queue with hg pull --rebase (that also updates your local repository)

  • push your changes to the fork repository
  • let MartinGeisler know where your fork lies, and he'll push the changes to the i18n queue

When you will have the rights to do it, you will be able to push your changes directly to i18n queue (and you may discontinue your fork, if you wish so).

5.2. TortoiseHg から文字列を取り込む

TortoiseHg プロジェクトでは多数の翻訳がなされており、その文字列のうち50個ほどが Mercurial と重複しています。 メッセージを流用するには、まず、最新の翻訳をダウンロードします。 URL は次の形式です:

http://bitbucket.org/tortoisehg/stable/raw/tip/i18n/tortoisehg/xx.po

wget かブラウザでダウンロードし、 ファイルを i18n フォルダーに保存します。その後、共通な翻訳メッセージを抽出します。

msgcomm tortoisehg-xx.po hg.pot -o common-xx.po

tortoisehg-xx.po を間違いなく前側に指定してください。翻訳メッセージは前側に指定したファイルから取り出されます。最後に、msgcat でファイルを一つにまとめます。

msgcat --no-location hg.pot common-xx.po xx.po -o xx.po

hg.pot を指定することで、メッセージの順番が変わらないようにしています。

翻訳の一部がプロジェクト同士で衝突することがあります。衝突は xx.po ファイルへ次のように記録されます。 (ドイツ語訳の例)

msgid "unrecognized response\n"
msgstr ""
"#-#-#-#-#  de.po (Mercurial)  #-#-#-#-#\n"
"Unbekannte Antwort\n"
"#-#-#-#-#  tortoisehg-de.po (tortoisehg)  #-#-#-#-#\n"
"nicht erkannte antwort\n"

xx.po を読んで衝突を解消する必要があります。上記の例では、Mercurial 側で "Unbekannte Antword" と訳したメッセージを、 TortoiseHg では "nicht erkannte antwort" と訳しています。 "#-#-#-#-#" とマークされた行を削除し、どちらか好きな方の翻訳のみを残してください。 TortoiseHg の訳者と連絡を取り、訳語を揃える努力をしましょう。今後の流用がお互い楽になります。

5.3. 頻度の高いメッセージから訳す

重要なメッセージから翻訳したい場合は、 i18nstat エクステンションを使ってみるといいかもしれません。 このエクステンションでは翻訳メッセージのログを取り、未翻訳のメッセージが使われた回数を数えています。

必要なことは、このエクステンションを有効にし、普通に Mercurial を使うだけです。累積データをダンプするには hg i18nstat コマンドを使います。 未翻訳のメッセージを翻訳すると、次にそのメッセージが使われた時に累積データから取り除かれます。(メッセージが使われるまで、このエクステンションは翻訳されたことを検知しません。)

6. 既存の翻訳

Mercurial と一緒に配布されている翻訳メッセージ (Transifex リストもご覧ください):

まだ Mercurial と一緒に配布されていない翻訳:

特定の言語の翻訳に参加したい時は、上記の方に連絡してください。別の翻訳を始めたい場合は、その言語とあなたの名前をリストに追加してから進めてください。


CategoryJapanese CategoryTranslations

English

JapaneseTranslatingMercurial (last edited 2014-05-08 14:12:11 by YuyaNishihara)