• Showing Page History #60624

NVDAの他言語への翻訳(NVDAのLocalization)

注意: エディットフィールドに文字を入力したり、ファイルを保存したり、フォルダを作成したりする際は、大文字や小文字をこのチュートリアルの文字にあわせてください。

このドキュメントを読んでいるということは、あなたはおそらくNVDAのソースコードバージョンのインストールを終了し、そのNVDAはコンピューター上でちゃんと動いていることと思います。このインストラクションでは、Python 2.7はc:\python27にインストールされており、NVDAのソースファイルはc:\NVDA\sourceにインストールされているものとして説明していきます。

NVDAの翻訳

利用可能な翻訳方法

少なくとも今、NVDAを翻訳する方法は二つあります。一つ目は、いくつかのコマンドを使って翻訳すべき文字列を含んだファイルを生成し、それをテキストエディタを使って翻訳し、最後に翻訳済みのデータを別のコマンドを使ってコンパイルするという方法です。 もうひとつの方法は、 PoEditというGUI環境を使用する方法で、このツールを使用した場合、オリジナルのテキストと翻訳済みのテキストを並べて表示できます。このドキュメントでは、こちらを先に紹介します。

PoEditのインストールと実行

PoEdit'sのホームページは http://www.poedit.net/です。

最新のWindows版のPoEditは、いつでもhttp://sourceforge.net/projects/poedit/files/からダウンロードできます。

画面上の指示に従ってインストールしてください。2番目の画面で"同意"のチェックボックスをチェックする以外、特にコンポーネント画面でフルインストールを選択することをはじめとして、すべてのオプションをデフォルトのままにすることをお勧めします。

PoEditを最初に起動したとき、最初の画面ではプログラムのメニューやウインドウ、オプションの中で使用されるデフォルトの言語を選択できます。お使いのシステムのデフォルトの言語になっているかもしれません。このチュートリアルでは、PoEditのメニューとオプションの名称を、英語で参照することにします。

次のステップは、PoEditの文字列カタログファイルのヘッダー部分に入力される、名前と電子メールの情報を正確に入力することです。表示されたダイアログウインドウのそれぞれのフィールドに入力してください。次に、 "パーサ"に到達するまで、Ctrl+Tabを何度か押し、プログラム言語の一覧でPythonを選択します。TabキーでEditボタンに移動し、スペースキーを押し、Tabキーで"list of extensions(拡張子の一覧)"フィールドに移動し、セミコロンに続けて*.pywと入力します。すると、フィールドは次のようになるはずです:

次に、Pythonパーサウインドウを閉じるためにOKボタンを押し、さらにOKボタンを押して設定ウインドウの他の部分はデフォルトの設定のままにして閉じます。

=== NVDAの翻訳カタログの作成 ===

ファイルメニューの中の、"新規カタログ..."を開きます。ここではさらに、このプロジェクトに固有のいくつかの情報を入力する必要があります。すべてのフィールドへの入力は任意ですが、常に正しい情報を入力することが望ましいです。

プロジェクト名とバージョン"には、"NVDA R"に続いて、あなたが最後にチェックアウトしたディビジョン番号を入力すると良いでしょう。例えば、次のような感じです:

{{{ NVDA R3461 }}}

"翻訳チーム"フィールドには、例えば"<あなたの言語コード>言語チーム"のような情報を入力するか、翻訳者があなただけの場合はご自身のお名前を入力すると良いでしょう。"翻訳チームのメールアドレス"にはあなたのメールアドレスまたは翻訳チームのアドレスを入力してください。次に、プロジェクトの言語と国を、コンボボックスから選択してください。NVDAはUnicodeで書かれているので、文字符号化法とソースコードの文字符号化法のコンボボックスではUTF-8を指定します。

次に、Ctrl+Tabキーを押してパスタブに移動し、ベースのパスエディットフィールドにNVDAのソースをダウンロードしたフォルダの絶対パスを"c:\nvda"のように入力します。次のボタンにTabキーで移動し、ボタンを押して出てきたエディットフィールドに"source"と入力してEnterキーを押します。これは、!PoEditがソースコードの中から翻訳可能なテキストを探す基点になります。OKボタンにTabキーで移動して押してください。

通常の"名前を付けて保存..."ダイアログが表示されます。ファイル名のフィールドに、"nvda.po"と入力し、保存先フォルダとして"NVDA\source\locale\<言語コード>\LC_MESSAGES"というフォルダを選択します。なお、<言語コード>はあなたがNVDAを翻訳しようとしている言語のISO-639形式の名称になります。もしこのようなフォルダー構造がない場合は作成してください。

!PoEditは今後、そのフォルダーに二つのファイルを保存します。"nvda.po"にはオリジナルと翻訳済みの文字列がテキスト形式で保存されています。必要に応じて、お好みのテキストエディターで確認できます。
"nvda.mo"はバイナリー版のnvda.poで、NVDA自身が実行時に読みこんで使用します。

余談ですが、もしあなたが!PoEditの代わりに、本チュートリアルの公判で紹介するpygettextというコマンドラインツールを利用する場合は、nvda.potというオリジナルの文字列を含んだもうひとつのファイルがあります。このファイルは翻訳終了後に、nvda.poとして保存する必要があります。!PoEditはソースコードをスキャンして自動的にpoカタログを更新することができるので、potファイルを生成する必要はありません。

ダイアログが閉じると、Tabキーでフィールド間を移動できる空のリストビューとエディットボックスが表示されます。
Go to the catalog menu and enter "update from source". This option instructs !PoEdit to scan the entire NVDA source code for translatable strings. You must run it everytime you want to check whether there are new untranslatable strings to be added or obsolete strings to be removed from your project, no matter if it is or is not the first time you translate it.

After scanning the code, it may happen to appear a window giving some errors related to incorrectly terminated strings. You may simply ignore it and press OK, as they are just warnings without relevance. Next, !PoEdit will present the list of new strings that are to be added to your catalog file, and the obsolete strings, that is, strings that are not part of the program anymore, most likely because some option had its name changed or had been replaced with one or more similar options. If it's the first time you scan the sources for strings, the new strings list will probably contain hundreds of strings. You need not to walk through all the list; simply hit OK.

=== Translating in !PoEdit ===

You have now landed on the same list as before, but now fulfilled with all of NVDA strings to be translated. Read the status bar to see how many strings are translated already, how many are not, and how many are fuzzy. A fuzzy string is one that !PoEdit has tried to automatically guess the translation, thus it may be wrong. To insert or correct the translation for a string, first select it with the arrows, then tab to the blank edit field and type its translation.

You may want to spell the original string to be aware of any punctuation mark, capital letters, etc. !PoEdit has a keystroke you may press while on an original string, alt+C, that copies the original string to the edit field when pressed. You may then replace it with your translation normally.

Press control+s at any moment to save your work. Each time you press this key, !PoEdit saves NVDA.po and also re-compiles NVDA.mo with the latest strings you translated and just saved.

=== Second Method: using Pygettext directly ===

If you are confortable using !PoEdit, you may skip the rest of this page.

Open a command prompt and change to NVDA's source directory by typing:
{{{ cd \NVDA\source }}}

Now enter the following command:
{{{ \python26\tools\i18n\pygettext.py -d nvda *.py *\*.py *\*\*.py *\*\*\*.py }}}

This will generate a file called "nvda.pot" in your current directory, \NVDA\source. This generated file is a plain text which contains all of the specified strings to be translated.

Each line beginning with "msgid" contains an original English message surrounded by quotes. Each line beginning with "msgstr" contains empty quotes which should be filled in with the translation that corresponds to the original English message at the above line or lines.
You should also fill in the first lines of the file, which hold the program's title, author, translator, language, etc. You should put an iso 639 alpha2 code of your language , e.g. de, en, fr, it. If the language is used in various countries and you would like to specify that you shal append an underscore and country code E.G. pt_BR, pt_PT, es_ES etc. You can look up your language code [http://en.wikipedia.org/wiki/List_of_ISO_639-2_codes here] if you are not sure. In addition, don't forget to specify UTF-8 in the charset field and 8bit in the Content-Transfer-Encoding field.

Once you have prepared the file, save it with the name "nvda.po" in the NVDA's source directory.

Enter a command prompt, change to source directory and type this:
{{{ \python26\tools\i18n\msgfmt.py nvda }}}

This will generate a file called "nvda.mo" in your current directory, \NVDA\source.

Change to the locale directory under \NVDA\source and create a directory. Its name must correspond with the language code discussed above.

Inside this new xx_XX directory, create another one called "LC_MESSAGES" and place nvda.mo into it.

To run NVDA in your language go to the user interface settings and change the language. You will be asked to restart NVDA. Alternatively you can edit nvda.ini within the source directory, search for the line beginning with "language", and change the language letters from "enu" to the language code of your translation.

Now you are ready to run nvda.pyw and it should present the translated messages already.

=== Updating an Existing Translation ===

To merge an old translation with a new one, first generate an updated nvda.pot file.

Then download msgmerge.py from: http://www.jantrid.net/misc_files/msgmerge.py and Place it in any directory. Here I have put it into \python26\tools\i18n.

Then go to a command prompt, change to the source directory and type:
{{{ \python26\tools\i18n\msgmerge.py -U nvda.po nvda.pot }}}
You may like to create a batch file including these commands to speed it up.

This will update the translated nvda.po with the new messages from nvda.pot which are not translated yet of course.

Edit nvda.po and check it for misupdated lines, especially the first lines at the header, where MSGMerge doesn't do a perfect work. Then look for untranslated messages and translate them. Also make sure the strings which are translated properly don't have #, fuzzy comment in fromt of them.