Help:Extension:Translate/Translation aids/ja

Translation aids (or translation helpers) are modules that provide helpful and necessary information for the translator when translating. Different aids can provide suggestions from translation memory and machine translation, documentation about the message or even such a basic thing as the message definition – the text that needs to be translated.

There is some overlap between the data provided by message collection and the aids, but the rule of thumb is that message collection only provides information that is absolutely needed to present the list of messages: definition, translation, status of translation, last translator (because one can only review translations made by someone else) etc.

Translate comes with many aid classes. Each class that extends the TranslationAid class only needs to implement one method called. It should return the information in structured format (nested arrays). These modules can be called either directly from PHP or via the WebAPI.

MediaWiki 内での翻訳支援の使用方法
メッセージの説明文書を利用できる場合にそれを取得する、単純な例です.

翻訳支援 API の使用方法
As already seen above, translation aids are available via a WebAPI, which is using the MediaWiki WebAPI framework. Getting translation aids is as simple as doing HTTP GET for the URL http://translatewiki.net/w/api.php?action=translationaids&title=MediaWiki%3AJan%2Fde. It provides various different formats, but JSON and XML are the most popular ones. This API does not need authentication, but some translation aids like "inotherlanguages" uses user preferences to determine which languages to use. To use that aid you should log in first, as described in the MediaWiki WebAPI documentation.

以下のようなデータが返ってくるはずです (読みやすく整形した JSON 形式です): Every requested aid is guaranteed to have a key here (until the request fails miserably), but while we use exceptions in the PHP side, in the JavaScript side each aid may have the key "error" set with the error message set as value. You can see an example of this above with. It signals that it cannot display a diff, because there have been no changes to the definition since last translation.

JavaScript の例
Here is the same thing for JavaScript. By default the API returns all aids, but you can request specific ones with the  param. In the example we are using jsonp to work around cross site request limitations. Be aware that you cannot execute any write actions with jsonp, so if you are using this API from JavaScript you will need: to have a proxy; to run the script on the same host; or to load a little helper (not yet implemented) from the target site.

命名規則と戻り値
各翻訳支援には唯一の識別子文字列があります. 識別子では特殊文字、特に JavaScript の識別子として有効ではない文字 ( 、 など) を避けるべきです.

The array that is returned by each translation aid is up to the developer, but should follow some general recommendations.

If only one text value is returned, it should use  as the key of the field. Language should be provided in field. Users of this data should ensure that in HTML and elsewhere the text is tagged properly with the provided language and directionality (not provided here). If there is HTML output, it should be available with key. Examples of this are message documentation and diffs.

Various kinds of translation suggestions like machine translation and translation memories should use these keys when they make sense:


 * ,  and   (target language is implicitly the same as the language of the translation)
 * : identifier of the service used
 * : value in range [0,1], higher value means that the quality of the suggestions is very good.

Note: When returning arrays, you must set the  field to contain an element name. For machine translation and translation memory this is. This is mandated by the MediaWiki WebAPI framework. It is visible in the XML format, but in JSON format the output is just a list.

標準の支援の一覧
[フィールド名] は、戻り値がリストであることを意味しています. PHP では、添字が整数の配列にキー  が追加されたものです. これが必要な理由は前述の通りです.