Help:Extension:Translate/環境設定
MediaWiki 言語拡張機能群には翻訳拡張機能の設定に不可欠なコード類とインストールの手順が揃っています。このページでは追加の機能を求めている利用者で、インストール手順の紹介と必須条件のページがお役に立たなかった人向けに利用できるオプションの詳細を説明します。
サンプルの設定
この環境設定は MediaWiki のディレクトリLocalSettings.php配下に入ります。
wfLoadExtension( 'Translate' );
$wgGroupPermissions['translator']['translate'] = true;
$wgGroupPermissions['translator']['skipcaptcha'] = true; // T36182: ConfirmEdit で必要
$wgTranslateDocumentationLanguageCode = 'qqq';
# ページ翻訳へのアクセスを許すにはこれを追加
$wgGroupPermissions['sysop']['pagetranslation'] = true;
# 機械翻訳サービス用の個人 API キー
#$wgTranslateTranslationServices['Apertium']['key'] = '';
利用者権限
Translate 拡張機能は、以下の利用者権限を新たに導入します:
| 利用者権限 | 定義 | 説明 |
|---|---|---|
translate
|
翻訳用インターフェイスを使用して編集 | 利用者が翻訳を編集できるようにします。 |
translate-manage
|
メッセージ群を管理 | 利用者が Web インターフェイスでメッセージ群の更新や管理をできるようにします。 |
translate-import
|
オフラインでの翻訳を取り込み | ウェブのインターフェースを使い、利用者自身がオフラインツールから翻訳の更新をインポートできるようにします(まだ安定版ではありません)。 このグループはオプションです。外部のソースから翻訳をインポーする必要がない場合は不用です。 |
pagetranslation
|
ページの版を翻訳対象に指定 | 利用者が本文ページの翻訳を管理できるようにします。 |
translate-messagereview
|
翻訳を査読 | 利用者が翻訳を査読済みにできるようにします。 |
translate-proofr
|
- | このグループには、translate-messagereview の権限と、他の利用者を translate-proofr グループに追加する権限があります。
|
translate-groupreview
|
メッセージ群のワークフローの状態を変更 | グループのワークフローの状態を変更できるようにします。 このグループはオプションで、$wgTranslateWorkflowStates が既定で無効な場合には不要です。 有効にするとワークフローの状態は $wgTranslateWorkflowStates の変数に設定されます。 |
環境設定の変数
下記の説明文書は利便性のために Translate.php から転記したものです。
構成オプションは時間の経過で変化するため、何かおかしいと感じた場合にはインストールされた Translate.php の説明文書が最適です。
参考までに下記は 2016-04-21 時点の記録です。
基本的な設定
| 展開すると表示されるコンテンツ |
|---|
/**
* メッセージの説明文書の言語コード。 推奨値は qqq または info です。
* false (既定値) に設定すると、メッセージの説明文書機能は無効になります。
*/
$wgTranslateDocumentationLanguageCode = false;
/**
* ページ翻訳機能の翻訳を無効化し、メンテナンスを行うボットの名前。
* 外部ソースからのメッセージのインポートにも使用されます。
*/
$wgTranslateFuzzyBotName = 'FuzzyBot';
/**
* 翻訳時の補助として翻訳者に表示する言語の一覧 (補助言語) の既定値。
* 各利用者は個人設定でこの設定を上書きできます。
* MediaWiki コアの Messages*.php にこの言語のフォールバックが設定されている場合は、そのフォールバック言語が使用されます。そのため、この変数はフォールバックに言語を追加したい場合にのみ使用してください。
* この機能は、補助言語の個人設定 ('translate-editlangs') の値が文字列 'default' の場合にのみ機能します。
* 例:
* $wgTranslateLanguageFallbacks['fi'] = 'sv';
* $wgTranslateLanguageFallbacks['sv'] = [ 'da', 'no', 'nn' ];
*/
$wgTranslateLanguageFallbacks = array();
/**
* 翻訳が古くなっている場合に翻訳内に表示されるテキスト。
* 実際の内容と競合しないものにする必要があります。
*/
if ( !defined( 'TRANSLATE_FUZZY' ) ) {
define( 'TRANSLATE_FUZZY', '!!FUZZY!!' );
}
/**
* 翻訳候補を提供する各種ウェブ サービスを定義します。
*
* 翻訳メモリについては、メイン説明文書で説明しています。
* @see https://www.mediawiki.org/wiki/Help:Extension:Translate/Translation_memories
*
* Apertium を使用するには、API キーを取得する必要があります。
* @see http://wiki.apertium.org/wiki/Apertium_web_service
*
* Microsoft Azure AI Translator を使用するには、インスタンスを「global」リージョンに設定する必要があります。そうしないと機能しません。
*
* Yandex 翻訳ヘルパーには、候補の総数を制限する langlimit オプション (0 に設定すると、可能なすべての翻訳を取得) と、言語を並べ替える langorder 配列もあります。
* 翻訳エンジンは検索インデックスから生成された Yandex Wordnet に基づいているため、インデックスに登録されているウェブサイトの数は、既定の言語順序を決めるための適切な目安になります。
*
* 機械翻訳サービスには、以下の情報が提供されます:
* - サーバーの IP アドレス
* - MediaWiki と Translate の拡張機能のバージョン
* - クライアントの IP アドレスが $wgProxyKeyで暗号化されている
* - 翻訳するソース テキスト
* - 提供された場合、非公開の API キー
*/
$wgTranslateTranslationServices = array();
$wgTranslateTranslationServices['TTMServer'] = array(
'database' => false, // Passed to wfGetDB
'cutoff' => 0.75,
'type' => 'ttmserver',
'public' => false,
);
$wgTranslateTranslationServices['Microsoft'] = array(
'url' => 'https://api.cognitive.microsofttranslator.com/',
'key' => null,
'timeout' => 3,
'type' => 'microsoft',
);
$wgTranslateTranslationServices['Apertium'] = array(
'url' => 'http://api.apertium.org/json/translate',
'pairs' => 'http://api.apertium.org/json/listPairs',
'key' => null,
'timeout' => 3,
'type' => 'apertium',
);
$wgTranslateTranslationServices['Yandex'] = array(
'url' => 'https://translate.yandex.net/api/v1.5/tr.json/translate',
'key' => null,
'pairs' => 'https://translate.yandex.net/api/v1.5/tr.json/getLangs',
'timeout' => 3,
'langorder' => array( 'en', 'ru', 'uk', 'de', 'fr', 'pl', 'it', 'es', 'tr' ),
'langlimit' => 1,
'type' => 'yandex',
);
/**
* Special:Translate のタスク一覧。ページ翻訳機能のみを使用する場合は、「optional」タスクを無効にすることをお勧めします。
* 例:
* unset($wgTranslateTasks['optional']);
*/
$wgTranslateTasks = array(
'view' => 'ViewMessagesTask',
'untranslated' => 'ViewUntranslatedTask',
'optional' => 'ViewOptionalTask',
'acceptqueue' => 'AcceptQueueMessagesTask',
'reviewall' => 'ReviewAllMessagesTask',
'export-as-po' => 'ExportasPoMessagesTask',
'export-to-file' => 'ExportToFileMessagesTask',
'custom' => 'CustomFilteredMessagesTask',
);
/**
* Experimental support for an "Ask" help button.
* Might change into a hook later on.
* This is an array with keys page, url and params.
* – page is a title of a local wiki page
* – url is an URL to use as is (e.g. an issue tracker submission form) which will override the page if set
* – params is an array of key-value pairs of request params
* –– each param value can contain the variable %MESSAGE% which will be replaced with the full page name.
* @since 2011-03-11
*/
$wgTranslateSupportUrl = false;
/**
* Like $wgTranslateSupportUrl, but for a specific namespace.
* Each $wgTranslateSupportUrl-like array needs to be the value assigned to the numerical ID of a namespace of the wiki.
* @since 2015.09
*/
$wgTranslateSupportUrlNamespace = array();
/**
* When unprivileged users open a translation editor, they will see a message stating that a special permission is needed for translating messages. If this variable is defined, there is a button which will take the user to that page to ask for permission.
* The target needs to be reiterated with the second variable to have the same result with sandbox enabled where users can't enter the sandbox.
*/
$wgTranslatePermissionUrl = 'Project:Translator';
$wgTranslateSecondaryPermissionUrl = 'Project:Translator';
/**
* If set, displays a warning and does not allow user to move translatable pages having more subpages than this value
*/
$wgTranslatePageMoveLimit = 500;
|
ページ翻訳機能
| 展開すると表示されるコンテンツ |
|---|
/**
* Enable page translation feature.
*
* Page translation feature allows structured translation of wiki pages with simple markup and automatic tracking of changes.
*
* @defgroup PageTranslation Page Translation
* @see https://www.mediawiki.org/wiki/Help:Extension:Translate/Page_translation_administration
*/
$wgEnablePageTranslation = true;
/**
* Number for the Translations namespace.
* Change this if it conflicts with other namespace in your wiki.
*/
$wgPageTranslationNamespace = 1198;
/**
* If set to true, when a user selects an interface language via ULS (Universal Language Selector), if the current page is a translatable page or a translation page then the user is also redirected to the corresponding translation page in the selected language.
*
* The language of the translation pages visited afterwards will still depend on the links followed (it will be the interface language only if the links use the Special:MyLanguage syntax).
* @since 2013-03-10
*/
$wgTranslatePageTranslationULS = false;
|
メッセージ群の環境設定
以下の設定変数名は変更されました:
TranslateBlacklist-->TranslateDisabledTargetLanguagesTranslateAuthorBlacklist-->TranslateAuthorExclusionListTranslateCheckBlacklist-->TranslateValidationExclusionFile
古い変数はMLEB 2021.07版までサポートされ、MLEB 2021.10版で除去されます。
| 展開すると表示されるコンテンツ |
|---|
/**
* Two-dimensional array of languages that cannot be translated.
* Input can be exact group name, first part before '-' or '*' for all.
* Second dimension should be language code mapped to reason for disabling.
* Reason is parsed as wikitext.
*
* Example:
* $wgTranslateDisabledTargetLanguages = array(
* '*' => array( // All groups
* 'en' => 'English is the source language.',
* ),
* 'core' => array( // Exact group
* 'mul' => 'Not a real language.',
* ),
* 'ext' => array( // Wildcard-like group
* 'mul' => 'Not a real language',
* ),
* );
*/
$wgTranslateDisabledTargetLanguages = array();
/**
* File containing checks that are to be skipped.
* See the following page for example:
* https://gerrit.wikimedia.org/r/plugins/gitiles/translatewiki/+/refs/heads/master/groups/validation-exclusion-list.php
*/
$wgTranslateValidationExclusionFile = false;
/**
* Two-dimensional array of rules that exclude certain authors from appearing in the exports.
* This is useful for keeping bots and people doing maintenance work in translations not to appear besides real translators everywhere.
*
* Rules are arrays, where first element is type: white or black. Inclusion always overrules exclusion.
* Second element should be a valid pattern that can be given a preg_match().
* It will be matched against string of format "group-id;language;author name", without quotes.
* As an example by default we have rule that ignores all authors whose name ends in a bot for all languages and all groups.
*/
$wgTranslateAuthorExclusionList = array();
$wgTranslateAuthorExclusionList[] = array( 'black', '/^.*;.*;.*Bot$/Ui' );
/**
* List of namespace that contain messages.
* No talk namespaces.
* @see https://www.mediawiki.org/wiki/Help:Extension:Translate/Group_configuration
*/
$wgTranslateMessageNamespaces = array();
/**
* CC = Custom classes.
* Custom classes can register themselves here.
* Key is always the group id, while the value is an message group object or callable function.
* @deprecated Use TranslatePostInitGroups hook instead.
*/
$wgTranslateCC = array();
/**
* Location in the filesystem to which paths are relative in custom groups.
*/
$wgTranslateGroupRoot = '/var/www/externals';
/**
* The newest and recommended way of adding custom groups is YAML files.
* See examples under Translate/groups
* Usage example:
* $wgTranslateGroupFiles[] = "$IP/extensions/Translate/groups/Shapado/Shapado.yml";
*/
$wgTranslateGroupFiles = array();
/**
* List of possible message group review workflow states and properties for each state.
* The currently supported properties are:
* * color: the color that is used for displaying the state in the tables.
* * right: additional right that is needed to set the state.
* Users who have the translate-groupreview right can set this in Special:Translate.
* The state is visible in Special:Translate, Special:MessageGroupStats and Special:LanguageStats.
* If the value is false, the workflow states feature is disabled.
* State name can be up to 32 characters maximum.
* Example:
* $wgTranslateWorkflowStates = array(
* 'new' => array( 'color' => 'FF0000' ), // red
* 'needs_proofreading' => array( 'color' => '0000FF' ), // blue
* 'ready' => array( 'color' => 'FFFF00' ), // yellow
* 'published' => array(
* 'color' => '00FF00', // green
* 'right' => 'centralnotice-admin',
* ),
* );
*/
$wgTranslateWorkflowStates = false;
/**
* Map from deprecated group IDs to their current ID
* Example value: array( 'core' => 'mediawiki-core' )
*/
$wgTranslateGroupAliases = array();
|
環境設定に関連するシステム設定
| 展開すると表示されるコンテンツ |
|---|
/**
* Set location of cache files. Defaults to $wgCacheDirectory.
*/
$wgTranslateCacheDirectory = false;
/**
* Configures how the message index is stored.
* The other backends need $wgCacheDirectory to be functional.
*/
$wgTranslateMessageIndex = array( 'DatabaseMessageIndex' );
// $wgTranslateMessageIndex = array( 'SerializedMessageIndex' );
// $wgTranslateMessageIndex = array( 'CDBMessageIndex' );
/**
* If you have lots of message groups, especially file based ones, and the message index rebuilding gets slow, set this to true to delay the rebuilding via JobQueue.
* This only makes sense if you have configured jobs to be processed outside of requests via cron or similar.
* @since 2012-05-03
* @deprecated Since MLEB 2021.10. Always inserted into the JobQueue
*/
$wgTranslateDelayedMessageIndexRebuild = false;
|
PHPlot
| 展開すると表示されるコンテンツ |
|---|
/**
* For Special:TranslationStats PHPlot is needed to produce graphs.
* Set this the location of phplot.php.
*/
$wgTranslatePHPlot = false;
/**
* The default font for PHPlot for drawing text. Only used if the automatic best font selection fails.
* The automatic best font selector uses language code to call fc-match program.
* If you have open_basedir restriction or safe-mode, using the found font is likely to fail.
* In this case you need to change the code to use hard-coded font, or copy fonts to location PHP can access them, and make sure fc-match returns only those fonts.
*/
$wgTranslatePHPlotFont = '/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf';
|
YAML ドライバー
| 展開すると表示されるコンテンツ |
|---|
/**
* Currently supported YAML drivers are: phpyaml, spyc, syck
*
* For phpyaml see https://php.net/book.yaml
*
* For syck we're shelling out to perl. So you need:
*
* * At least perl 5.8 (find out what you have by running "perl -v")
* * Install these modules from CPAN
* * YAML::Syck
* * PHP::Serialization.
* * File::Slurp
*
* You should be able to do this with for module in 'YAML::Syck' 'PHP::Serialization' 'File::Slurp'; do cpanp -i $module; done
*
* For the shell to work, you also need an en.UTF-8 locale installed on your system.
* add a line "en.UTF-8" to your /etc/locale.gen or uncomment an existing one and run locale-gen if you do not have it already.
*
* phpyaml is the fastest and based on libyaml so the output should be most compatible.
* spyc output format is least compatible. syck is slowest but almost as good as phpyaml.
*/
$wgTranslateYamlLibrary = 'spyc';
|
サンドボックス
| 展開すると表示されるコンテンツ |
|---|
/**
* Whether to allow users to sign up via a sandbox. Sandboxed users cannot do much until approved and thus they can be get rid of easily.
* @since 2013.04
*/
$wgTranslateUseSandbox = false;
/**
* To which group the translators are promoted. If left at false, they will just be removed from sandbox and become normal users.
* @since 2013.04
*/
$wgTranslateSandboxPromotedGroup = false;
/**
* List of page names to always suggest for sandboxed users.
* @since 2013.10
*/
$wgTranslateSandboxSuggestions = array();
/**
* Maximum number of translations a user can make in the sandbox.
* @since 2013.10
*/
$wgTranslateSandboxLimit = 20;
|
未整理の注記
| 展開すると表示されるコンテンツ |
|---|
/**
* Pre-save transform for message pages. MediaWiki does this by default (including for pages in the MediaWiki-namespace).
* By setting this to false it allows users to put untransformed syntax such as "~~~~" into a page without having them be transformed upon save.
*/
$wgTranslateUsePreSaveTransform = false;
/**
* Default action for the RecentChanges filter, which makes it possible to filter translations away or show them only.
* Possible values: ('noaction', 'only', 'filter', 'site')
*/
$wgTranslateRcFilterDefault = 'filter';
/**
* Set this to config like $wgTranslateTranslationServices if you want to run SolrTTMServer tests.
* @since 2013-01-04
*/
$wgTranslateTestTTMServer = null;
/**
* List of user names that are allowed to alter their privileges and do other things. Used for supporting integration testing.
* @since 2013.10
*/
$wgTranslateTestUsers = array();
|
トラブルシューティング
翻訳ページが空白もしくはエラー表示'Unbalanced <translate> tag' が出る
終了タグ </translate> が存在する場合は、翻訳元ページが長大すぎます。
特定の翻訳でこの問題発生のきっかけは、翻訳元ページがおよそ50KB以上だった場合です。
対象ページを短くするか、pcre.backtrack_limit を拡張するため、LocalSettings.php 内の
ini_set( 'pcre.backtrack_limit', 400000 );
か、ご利用の PHP 環境設定 (php.ini) の
pcre.backtrack_limit=400000
を設定します。
失敗した翻訳をUnknown error: "tpt-unknown-page"で保存
この問題の原因は、ページの翻訳指定は終わったのにバックグラウンドのジョブが未処理だからです。 その場合、主導でジョブキューを実行するか、さらに適した対策としてManual:ジョブ キューに記述のあるとおりジョブの連続実行を設定します。それでも解決しない場合はphp extensions/Translate/scripts/createMessageIndex.phpの実行を試します。