Getting translation strings right/ja

This is an old revision of Getting translation strings right/ja, edited by Miyatakejiro at . The current revision is 57403.

/* 一般的事項 */

このページは、原作者(例えばプログラマ)の観点に立ち、翻訳文字列を白紙から作成するための基礎的な注釈を記載しています。

この文章での "To get it right: うまくやる" とは、翻訳文字列が適切に準備されており、簡単に翻訳に修正を加えられたり、それらを用いることで基礎的な要求に合ったオリジナル版が作成できることを意味します。

このページを書くに当たり、できるだけ言語に中立であろうと勤めていますが、英語を主言語とするものとしての偏りがある可能性もあります。 あなたの状況へ当てはまらないものは、自由に修正してください。(また、[Getting_translation_strings_right オリジナルページ] へのフィードバックもお願いします。)

一般的事項

問題を避けるために、元の文字列は正しい ことをまず確認してください。 この理由は、

したがって、つづり、語句を正確に 、不安であれば辞書を使用してください。

ある状況に対しては、分かりやすくよく知られた、 一貫した記述 を用いてください。 何か共通なことの記述について確信が持てない場合は、同じ状況の元での他のプログラムの反応を参考にしてください。 何かのアプリケーションのヘルプファイルも、正確な特殊用語や説明の仕方についてのよい資料となります。 (訳注:私はwindows環境ですので、officeを参考に文字列リソースを記述しています。)

句の選定についても一貫したやり方をしてください。 例えば、

ファイルを削除(Delete)する?
ファイルを消去(Erase)する?
ファイルを除外(Remove)する?
ファイルを拭い去る(Wipe)?
ファイルを抹殺(Zap)する?

意味は似ていますが、特に理由が無いのに表現を変えた場合、ユーザーまたは翻訳者が間違った解釈をすることがあります。 翻訳者はこの間違いを犯しやすく、特別なメッセージ(例えば、メッセージの出自についての情報)の正確な文脈を知らなかったり、言葉のちょっとした違いを重要な差異として捉え、適切ではない翻訳を選びがちになります。

エラーメッセージを出すときは、問題点 それ自身を適切に記述しましょう。 問題点の記述とは、エラーメッセージが出たプログラムの状態ではありません(ファイルエラー, 不正な入力など)。 この内容は、プログラムのデバッグには役立ちますが、ユーザには意味を持ちません。 肩をすくめて無視されるだけならいいですが、他のアプリケーションを探して、あなたの意味不明なアプリケーションはアンインストールされるかもしれません。 適切な問題解決に結びつくメッセージを表示しましょう。

また、簡単な分かりやすい書き方をお願いします。 外国語や非常に技術的な用語は、本当の本当に必要なときにのみ使いましょう。

多重否定は分かりにくいので、使わないようにしましょう。 例えば、

This component can not be dropped on non-TControls.

 このコンポーネントは、非Tcontolにはドロップできます。

これは、否定しない文章で書き換えられます。

This component can only be dropped on TControls.

 このコンポーネントは、TControlにのみドロップできます。

こちらのほうが分かりやすいですね。

技術的項目

In this section a short overview of technical issues, basically an overview of existing possibilites are given. These include the resourcestring construct, GNU gettext() and the format() function.

リソース文字列と GNU gettext

Free Pascal has some built-in language constructs for providing a way of handling constant strings. There is a special section of a unit called "resourcestring" which was specifically introduced for this reason. See the appropriate section of the FPC manual (prog.pdf, pg. 89ff or here) for the details.

GNU gettext is a special set of utilities to provide translations for your programs, see the FPC manual once more (prog.pdf, pg. 91ff or here).

注記: GNU gettext has a conceptual flaw which does not allow mapping of a single original string to multiple translated strings, be aware of that.

IDE内の リソース文字列

パッケージ作成に向けての .po ファイルの生成について、下記の作業を行ってください:

 * 'languages' や 'local' といった副ディレクトリを生成してください。
 * パッケージを開き、Options -> IDE Integration -> Directory of .po files set to languages

The next time you compile the package, the IDE will create the .po files. Note: The .rst files must belong to package units. Otherwise the IDE ignores foreign .rst files.

The same works for projects. The directory is set in Project -> Project Options -> IDE Integration -> Directory of .po files.

アプリケーションのリソース文字列

リソース文字列の翻訳のために .po ファイルを読み込むことができる。 この機能を .lpr ファイルに実装するには:

<Delphi> ... uses

 ...
 Translations, gettext;

procedure TranslateLCL; var

 PODirectory, Lang, FallbackLang: String;

begin

 PODirectory:='/path/to/lazarus/lcl/languages/';
 Lang:=;
 FallbackLang:=;
 GetLanguageIDs(Lang,FallbackLang); // in unit gettext
 Translations.TranslateUnitResourceStrings('LCLStrConsts',
                     PODirectory+'lclstrconsts.%s.po',Lang,FallbackLang);
 // ... ここに、全ての .po ファイルに対する TranslateUnitResourceStrings 呼び出しを追加する ...

end;

begin

 TranslateLCL;
 Application.Initialize;
 Application.CreateForm(TForm1, Form1);
 Application.Run;

end. </Delphi>

The format() function

To not only allow completely static strings in translations, you can use the format() method of the sysutils unit. It is able to replace placeholders within a given text by their actual value given as secondary parameter in a set. Example:

format('Tomorrow on %0:s there will be %1:s.', ['Sunday', 'sunshine']);

returns

Tomorrow on Sunday there will be sunshine.

In this case the %0:s is a placeholder for the first (index 0) argument in the set of actual values (Sunshine), and likewise %1:s. For an exact definition of the allowed placeholders and their syntax see the FPC reference manual.

Some guidelines for the usage of the format() function

:span[Note:]{.underline} Since format() does not interpret escaped control characters (e.g. like C's "\n", "\t", etc) and GNU gettext for any reason being the translation system of choice (and the tools based on it not being able to interpret non-escaped control characters), it is required to programmatically insert linebreaks.In the current lazarus version, "\n" and "\t" in translated strings are replaced by newline and tab.

Converting the translation into the right character set

For example: converting a file from ISO-8859-1 to UTF-8:

 iconv --from-code=ISO-8859-1 --to-code=UTF-8 oldfile.po > newfile.po

Do not forget to change the line

 "Content-Type: text/plain; charset=ISO-8859-1\n"

to

 "Content-Type: text/plain; charset=UTF8\n"

This section contains notes which particularly apply when using English as the base language for translations.

There was an error ! Please check file settings , compiler settings,... to fix this issue.

has horrible punctuation and therefore simply looks bad and is harder to read than usual. Consider that common line break algorithms break the line on whitespaces, possibly resulting in a single stop at the beginning of a line...

There was an error! Please check file settings, compiler settings, ... to fix this issue.

would probably be okay only considering punctuation.