Help:Extension:Translate/Group configuration/ja

From mediawiki.org
This page is a translated version of the page Help:Extension:Translate/Group configuration and the translation is 65% complete.

メッセージ群を翻訳拡張機能に追加する方法はいくつかあります。 ここではメッセージの集合をメッセージ群と呼びます。 通常はソフトウェアのモジュールとファイルに1対1で対応します (また対応は翻訳目的語ごとに1件。) メッセージ群に他のメッセージ群を含ませることも可能です。 例えば特定のソフトウェア内のメッセージをすべてまとめたメッセージ群が作れます。 あるいはまたMediaWiki の最重要なメッセージで必ず最初に翻訳するべきものなど、メッセージの下位セット限定でまとめる方法もあります。 そのような高いレベルのメッセージ群はファイルとのマッピングに固有の形式がないものの、他のメッセージ群同様に他の翻訳ツールへの書き出しを Gettext 形式で実行できます。

翻訳者にとってメッセージ群は高いレベルの作業対象です。どの単一のメッセージを翻訳するか選ぶには、先にメッセージ群を決めるのが手順で、翻訳検索をした場合とは異なります。 メッセージ群単位で固有の識別子が付き、統計の対象にできます。 当然ながらメッセージ群は翻訳者が一度に取り掛かる最小の文の集合です。 メッセージ単位で識別子を与えてあり、これを通常はkey (キー) と呼びます。 キーは複数のメッセージ群で共有しても問題ありません。

標準のメッセージ群の設定形式

YAML 形式を使ったメッセージ群の追加が簡単です。 $wgTranslateGroupFiles に追加する設定ファイルに名前空間を定義すればいいのです。詳細は設定ページを参照してください。 例:

wfAddNamespace( 1218, 'FUDforum' );
$wgTranslateGroupFiles[] = "$IP/messagegroups/FUDforum/FUDforum.yml";

ファイル自体では YAML 構文が使用されます。 ここでは構文の説明はしませんが習得は簡単で、既製のメッセージ群のすべてを例として利用できます。 ただし字下げはタブではなく空きスペースを使用します。 各ファイル内に複数のメッセージ群を定義できます。 メッセージ群定義の区切りは空行にダッシュ 3 個 (---) を記入する形で、これは標準的な YAML の文書区切りです。

定義文は上位項目に分類します。BASIC、​FILES、​MANGLER、​VALIDATORS、​INSERTABLES、​TAGS、​AUTOLOAD、​LANGUAGES に加え、特殊な TEMPLATE を使用します。カスタム メッセージ群には、さらに上位項目を追加する場合があります。すべてのメッセージ群にすべての上位項目を定義する必要はありません。

BASIC (基本)

この節では、一意の ID や名前など、メッセージ群に関する基本的な情報を扱います。 使用できるキー (*印は必須キーを示す):

キー 説明
namespace* Either namespace id, constant or string where the messages are stored. The namespace must be added beforehand. 上記の例を参照してください。
icon メッセージ群のアイコン。 Can support any file that MediaWiki can handle and that is uploaded to MediaWiki. Also supports files from shared media repositories.
id* このメッセージ群を識別するための一意の ID。
label* このメッセージ群の、人間が読みやすい名前。
description このメッセージ群の説明。 Full wiki syntax is used.
class* このメッセージ群の種類 - 通常は FileBasedMessageGroup または AggregateMessageGroup
meta 複数の用途があります。異なるメッセージ群に同一のメッセージ キーがある場合 (通常、ブランチまたは下位集合のメッセージ群の場合)、1 つのメッセージ群のみをプライマリとし、他のメッセージ群では meta に値 yes を設定する必要があります。
sourcelanguage Language code of the source language. Defaults to en (English).
codeBrowser GettextFFS のみで使用されます。 URL pattern of an online viewer for the repository file(s), where %FILE% and %LINE% will be replaced by the relevant file path and line – as stated in PO files comments for a message – to give translators an informative link within the translation aids for that message. 例: https://github.com/lonvia/waymarked-trails-site/blob/master/django/%FILE%#L%LINE%
support Configures where the "Ask help" button will redirect the translator. You must specify either url or page and optionally params to configure the URL parameters. In parameters you can use %MESSAGE% as a placeholder for the name of the message.

例:

BASIC:
  id: out-freecol
  label: FreeCol
  icon: wiki://Freecol.png
  description: "{{int:bw-desc-freecol}}"
  namespace: NS_FREECOL
  class: FileBasedMessageGroup
  support:
    url: 
    params:
      title: "Translation issue with message %MESSAGE%"
      body: "[**URL**](https://translatewiki.net/wiki/%MESSAGE%)"

FILES (ファイル)

この節ではメッセージファイルのメッセージ群種別が FileBasedMessageGroup の場合のファイルシステムのレイアウトとメッセージファイルの書式を解説します。 使用できるキーは以下のとおり (必須のキーは * 印付き):

キー 説明
class* Class which defines the format of message files. 例: YamlFFS, JavaFFS, FlatPhpFFS, ....
codeMap List of language codes that differ from the ones used in MediaWiki. Use the MediaWiki language code as key and the target language code as the value.
sourcePattern* Where to find message files. Path variables are supported.
targetPattern How the exported files are named relative to export directory. Path variables are supported.
definitionFile Use this to define the location of the definition file (with the English source messages) if it does not adhere to the sourcePattern. Path variables are supported.
AppleFFS, AppleInfoPlistFfs
header Custom file header comment.
FlatPhpFFS クラス固有のキー
header Custom file header. If not given, it defaults to <?php
GettextFFS クラス固有のキー
CtxtAsKey Special mode where ctxt is used as message key. Should not be used for normal Gettext files.
header カスタム化したファイル ヘッダーのコメント。
keyAlgorithm Allowed values: legacy and simple. Default: simple. Simple provides shorter message keys.
JavaFFS クラス固有のキー
header カスタム化したファイル ヘッダーのコメント。
keySeparator The character separating key and value. Default is =. Can also be :.
JsonFFS クラス固有のキー
nestingSeparator The character separating levels when nested objects are flattened intro one key string. By default flattening is not done. Example: { "top": { "nested": "content" } } is converted to (assuming / as separator) message with key top/nested and value content.
includeMetadata Whether to include the @metadata key with author information in the exported files. Defaults to true.
parseCLDRPlurals Whether to parse CLDR plural keywords. Defaults to false.
YamlFFS クラス固有のキー
codeAsRoot If set to 1, all messages are under a language code (instead of at the root).
nestingSeparator The character separating levels when nested objects are flattened intro one key string. Default value is .. Example: top: { nested: content } is converted to (assuming . as separator) message with key top.nested and value content.
parseCLDRPlurals Whether to parse CLDR plural keywords. Defaults to false.

The path variables are:

変数 説明
%CODE% Language code (affected by codeMap)
%MWROOT% MediaWiki インストレーションのパス
%GROUPROOT% $wgTranslateGroupRoot で定義されます。
%GROUPID% メッセージ群 ID

例:

FILES:
  class: JavaFFS
  sourcePattern: %GROUPROOT%/commonist/messages_%CODE%.properties
  targetPattern: commonist/messages_%CODE%.properties

MANGLER

キー修飾は複数のメッセージ群間でメッセージ キーの衝突を避けるため、メッセージ キーに修飾をつける方法の 1 つです:

キー 説明
class* 使用する修飾。サンプル StringMatcher
StringMatcher クラス固有のキー
patterns* パターンの一覧。"*"をワインドカードに使用可能。
prefix* 固有のメッセージについて上記のパターンが適合する場合、メッセージ キーにはこの接頭辞を付けて修飾します。

例:

MANGLER:
  class: StringMatcher
  patterns:
    - "*"

VALIDATORS (バリデーター)

This section allows to define pre-defined or custom validators.

VALIDATORS:
  # pre-defined validator
  - id: InsertableRegex
    enforce: true
    insertable: true
    params: /\$[a-z0-9]+/
  # custom validator
  - class: MyCustomValidator
    enforce: true

AUTOLOAD:
  MyCustomValidator: Validator.php

INSERTABLES

This section allows to define a class which suggests insertables or use pre-defined insertables. The classes can be autoloaded as described in the AUTOLOAD section.

INSERTABLES:
  # pre-defined insertable
  - class: HtmlTagInsertablesSuggester
  # custom insertable
  - class: FreeColInsertablesSuggester

AUTOLOAD:
  FreeColInsertablesSuggester: Insertable.php

TAGS (タグ)

メッセージにタグを定義できます。タグはそれぞれ (キー修飾後)メッセージ キーのリストを伴います。"*" (アスタリスク) を使用したワイルドカード指定ができます。サポートするタグは以下の通りです:

キー 説明
optional These messages are not shown by default, and they do not count as untranslated messages when calculating translation percentages.
ignored These messages are not shown at all.

例:

TAGS:
  optional:
    - lang_locale
    - lang_dir
  ignored:
    - charset

AUTOLOAD (自動読み込み)

This item takes list of class names with filenames as values. こうすることで、カスタム クラスをカスタム メッセージ群に簡単にバンドルできます。 このパスは、メッセージ群設定ファイル自体の場所からの相対パスでなければなりません。

例:

AUTOLOAD:
  ShapadoMessageChecker: Checker.php

TEMPLATE (テンプレート)

複数のよく似たメッセージ群を定義する場合は、便利なショートカットが使えます。重複を避けるには、1番目の定義の冒頭にこのキーを書きます。これに対応させて、上位のキーはどれでも下位キーとして使用でき。その他のメッセージ群はこれらの定義を既定値として使用することになります。もちろん、メッセージ群単位でテンプレートの既定値を上書きできます。

例:

TEMPLATE:
  BASIC:
    namespace: NS_SHAPADO
    class: FileBasedMessageGroup
    description: "{{int:bw-desc-shapado}}"

  FILES:
    class: YamlFFS
    codeAsRoot: 1
    codeMap:
      be-tarask: be-TARASK

GROUPS (メッセージ群、AggregateMessageGroup クラス対応)

このキーは、このメッセージ群を構成するメッセージ群 ID のリストのみを取ります。

例:

GROUPS:
  - out-shapado-ads
  - out-shapado-announcements
  - out-shapado-answers
  - out-shapado-badges

Wildcards are supported. この場合、集約群がパターンに合致しても、再帰的に自分自身を含めることはありません。 例:

GROUPS:
  - out-shapado-*

入れ子になった集約群がある場合、ワイルドカードは問題になる場合があります。なぜなら、一部のメッセージ群は、(直接、および含まれる集約群を介して) 複数回含まれることがあるからです。

LANGUAGES (言語)

このキーにより、メッセージ群内で特定の言語への翻訳を許可/不許可できます。 Translation into disallowed languages will be blocked.

LANGUAGES:
  include:
    - en
  exclude:
    - he
    - or
警告 警告: MLEB 2021.10: Below configuration no longer supported
LANGUAGES:
  whitelist:
    - en
  blacklist:
    - he
    - or

Allowed ("include") entries override any values in the disallowed ("exclude") list. If an allowed entry is * that means all languages are allowed. The allowed list is also optional.

ご利用のウィキ固有のインターフェイスメッセージ向けのメッセージ群

そのウィキに固有の、カスタム化したUIのメッセージ群の例として、地域化したサイドバーがあります。 以下のコードをご利用の LocalSetting.php に記入し、wikiname 部分を該当する名称に書き換えます。

$wgHooks['TranslatePostInitGroups'][] = function ( &$list, &$deps, &$autoload ) {
	$id = 'wiki-custom';
	$mg = new WikiMessageGroup( $id, 'wikiname-messages' );
	$mg->setLabel( 'Wikiname User Interface Messages' );
	$mg->setDescription( 'This group contains user interface messages used on Wikiname.' );
	$list[$id] = $mg;
}

MediaWiki 拡張機能のショートカット

MediaWiki の翻訳単位群 (units group for MediaWiki) を参照してください。