Getting translation strings right/ja

From Free Pascal wiki
Jump to navigationJump to search

Deutsch (de) English (en) español (es) français (fr) 日本語 (ja) русский (ru)

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

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

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

一般的事項

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

  • 文字列を翻訳する際には元の文字列を初期値とすることが一般的であるため、未翻訳箇所では元の文字列が表示されることになる。このときに文字列が間違っている場合、悪い印象を与える可能性がある。
  • さらに問題になるのは、元の文字列を翻訳する仕事を無駄に難しくする点があります。 ここでは、「Garbage In, Garbage Out: ゴミを入れると、ゴミが出てくる」原理が完全に当てはまります。

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

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

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

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

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

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

Give (easily) understandable descriptions. Do not try to impress your audience with foreign or very technical words only for telling that the current work has not yet been saved if not really necessary.

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

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

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内の リソース文字列

  • Lazarus には、文字列定数からリソース文字列を簡単に作るツールがある。 リソース文字列の作成を参照してください。
  • FPC は、各リソース文字列の部分に対して .rst ファイルを生成します。 しかし、これらのファイルについての編集ツールはありません。 Lazarusは自動的に .rst ファイルの .po ファイルを生成することができます。 .po ファイルについては多くの編集ツールがあります。(例えば、 kbabel)

パッケージ作成に向けての .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.

  • To create a german translation: copy the unit1.po file to unit1.de.po. Then use a text editor or a .po Editor to translate all strings.
  • The IDE will automatically load .po files for installed packages, if they exists. For example see lazarus/components/projecttemplates/languages/.
  • ToDo: Implement and document updating the translated .po files when new resourcestrings are added.
  • ToDo: Implement and document collecting all .po files of statically linked packages.


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

リソース文字列の翻訳のために .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

  • Try to use indexed placeholders in the original strings, even if they are optional. When used, they allow the translator to move the arguments easily within the sentence allowing him more natural expressions (and actually sometimes moving sentence parts is required to create proper sentences in that language).
  • Never compose a sentence out of more than one string. Always use the format() method from the sysutils unit to construct the correct string using placeholders during runtime. Translators will usually not be able to reconstruct the whole sentence, therefore not able to give a good translation; only consider that there are often hundreds of such strings within a single translation database...
  • Do not format using whitespaces. Simply move your label to the appropriate position in the first place. There may be problems with font changes, and seemingly superfluous spaces will be in danger of being trimmed by the translator.

Note: 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"

English related

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

  • Make sure to reserve enough space where the text is output: English is a language in which texts are almost always shorter (in characters) than their respective translations, so plan ahead by reserving enough space. Experience shows that very short strings of a few characters length often almost double in size; this difference decreases as the strings get longer.
  • Avoid abbreviations in English; in addition to the fact that this shortens the already short strings even more, there are severe problems with e.g. languages that use ideographic characters where these abbreviations simply do not exist at all.
  • Since this is often an issue: In English punctuation marks (full stop, comma, ...) are part of the previous words, or form some sort of words themselves if there is no previous word (in case of an enumeration). Especially after a semicolon there should always be a trailing space.
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.