Jump to content

Help:Extension:Translate/Group configuration/MediaWiki

From mediawiki.org

This is documentation how to set up MediaWiki extension groups using the simple text configuration file. It is useful if you have hundreds of extensions.

This configuration goes to the LocalSettings.php in the MediaWiki directory.

require "$IP/extensions/Translate/Translate.php";

$wgHooks['TranslatePostInitGroups'][] = function ( &$list, &$deps, &$autoload ) {
	$def = "/path/to/mediawiki-extensions.txt";
	$path = '%GROUPROOT%/extensions/';

	$parser = new PremadeMediawikiExtensionGroups( $def, $path );
	$parser->register( $list, $deps, $autoload );

	return true;
}

Configuration file

Here is an example configuration file:

Simple Extension

Complex Extension
desc = Some text here.
ignored = sidebar, robots.txt
optional = grouppage-recursive-export
prefix = wmf- | sidebar, grouppage-Staff, group-Staff, group-Staff-member
aliasfile = ComplexExtension.alias.php
magicfile = ComplexExtension.magic.php

The general syntax is: Name of the extension followed by list of keys and values and one empty line before next extension.

ExtensionName - Name of the extension with spaces removed.

The available keys are:

aliasfile
Location of file containing special page alias translations for this extension relative to $wgTranslateExtensionDirectory
desc
Description of the extension shown to translators
descmsg
A page in MediaWiki namespace containing the description of the extension shown to translators
file
Location of the file containing messages for this extension. Default value depends on the format:
  • php: ExtensionName/ExtensionName.i18n.php
  • json: ExtensionName/i18n/%CODE%.json
format
File format used by the extension. Supported values are php and json. Default: format = php
id
Message group id. Default value is ExtensionName in lowercase prefixed with ext-. For example, "Complex Extension" has default id of "ext-complexextension"
ignored
List of comma separated message keys which will not be shown for the translators. This key can be present in multiple times to split the list into multiple lines.
magicfile
Location of file containing magic word translations for this extension relative to $wgTranslateExtensionDirectory
optional
List of comma separated message keys which will be shown to translators only if they select to see optional messages. Optional messages are not counted as untranslated messages, but translated optional messages are counted as translated. This key can be present multiple times.
prefix
To handle conflicting message keys, you can prefix given messages. The syntax is first to have the prefix separated by pipe from comma separated list of message keys. This key can be present multiple times.
var
Name of the php variable holding the messages. Defaults to $messages.