Translate.php File Reference

An extension to ease the translation of Mediawiki and other projects. More...

Go to the source code of this file.

Enumerations

enum  TRANSLATE_VERSION
 

Version number used in extension credits and in other places where needed.

More...

Functions

 wfAddNamespace ($id, $name)
 Helper function for adding namespace for message groups.

Variables

 $wgExtensionCredits ['specialpage'][]
 Extension credits properties.
 $wgTranslateDocumentationLanguageCode = false
 Registering various resources.
 $wgTranslateFuzzyBotName = 'FuzzyBot'
 Name of the bot which will invalidate translations and do maintenance for page translation feature.
 $wgTranslateNewsletterPreference = false
 Add a preference "Do not send me email newsletters" in the email preferences.
 $wgTranslateLanguageFallbacks = array()
 Default values for list of languages to show translators as an aid when translating.
if(!defined( 'TRANSLATE_FUZZY')) $wgTranslateTranslationServices = array()
 Text that will be shown in translations if the translation is outdated.
 $wgTranslateTranslationServices ['TTMServer']
 $wgTranslateTranslationServices ['Microsoft']
 $wgTranslateTranslationServices ['Apertium']
 $wgTranslateTranslationServices ['Yandex']
 $wgTranslateTasks
 List of tasks in Special:Translate.
 $wgTranslateSupportUrl = false
 Experimental support for Ask help button.
 $wgTranslatePermissionUrl = 'Project:Translator'
 When unprivileged users opens a translation editor, he will see message stating that special permission is needed for translating messages.
 $wgEnablePageTranslation = true
 $wgPageTranslationNamespace = 1198
 Number for the Translations namespace.
 $wgTranslatePageTranslationULS = false
 When user changes interface language via ULS, should we also switch the language of the translatable page.
 $wgTranslateBlacklist = array()
 Two-dimensional array of languages that cannot be translated.
 $wgTranslateCheckBlacklist = false
 File containing checks that are to be skipped.
 $wgTranslateAuthorBlacklist = array()
 Two-dimensional array of rules that blacklists certain authors from appearing in the exports.
 $wgTranslateAuthorBlacklist [] = array( 'black', '/^.*;.*;.*Bot$/Ui' )
 $wgTranslateMessageNamespaces = array( NS_MEDIAWIKI )
 List of namespace that contain messages.
 $wgTranslateCC = array()
 CC = Custom classes.
 $wgTranslateGroupRoot = '/var/www/externals'
 Location in the filesystem to which paths are relative in custom groups.
 $wgTranslateGroupFiles = array()
 The newest and recommended way of adding custom groups is YAML files.
 $wgTranslateWorkflowStates = false
 List of possible message group review workflow states and properties for each state.
 $wgTranslateExtensionDirectory = "$IP/extensions/"
 Location of your extensions, if not the default.
 $wgTranslateCacheDirectory = false
 Set location of cache files.
 $wgTranslateMessageIndex = array( 'DatabaseMessageIndex' )
 Configures how the message index is stored.
 $wgTranslateDelayedMessageIndexRebuild = false
 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.
 $wgTranslatePHPlot = false
 For Special:TranslationStats PHPlot is needed to produce graphs.
 $wgTranslatePHPlotFont = '/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf'
 The default font for PHPlot for drawing text.
 $wgTranslateYamlLibrary = 'spyc'
 Currently supported YAML drivers are spyc and syck and sycl-pecl.
 $wgTranslateUseSandbox = false
 Whether to allow users to sign up via a sandbox.
 $wgTranslateSandboxPromotedGroup = false
 To which group the translators are promoted.
 $wgTranslateSandboxSuggestions = array()
 List of page names to always suggest for sandboxed users.
 $wgTranslateSandboxLimit = 20
 Maximum number of translations a user can make in the sandbox.
 $wgTranslateUsePreSaveTransform = false
 Pre-save transform for message pages.
 $wgTranslateRcFilterDefault = 'filter'
 Default action for the RecentChanges filter, which makes it possible to filter translations away or show them only.
 $wgTranslateTestTTMServer = null
 Set this to config like $wgTranslateTranslationServices if you want to run SolrTTMServer tests.
 $wgTranslateUseTux = true
 Whether to use the TUX interface by default.
 $wgTranslateTestUsers = array()
 List of user names that are allowed to alter their privileges and do other things.

Detailed Description

An extension to ease the translation of Mediawiki and other projects.

Author:
Niklas Laxström
Siebrand Mazeland
Note:
Copyright © 2006-2013, Niklas Laxström, Siebrand Mazeland
GPL-2.0+

Definition in file Translate.php.


Enumeration Type Documentation

Version number used in extension credits and in other places where needed.

Definition at line 20 of file Translate.php.


Function Documentation

wfAddNamespace ( id,
name 
)

Helper function for adding namespace for message groups.

It defines constants for the namespace (and talk namespace) and sets up restrictions and some other configuration.

Parameters:
$id   Integer   Namespace number
$name   String   Name of the namespace

Definition at line 648 of file Translate.php.


Variable Documentation

$wgEnablePageTranslation = true
$wgExtensionCredits['specialpage'][]
Initial value:
 array(
    'path' => __FILE__,
    'name' => 'Translate',
    'version' => TRANSLATE_VERSION,
    'author' => array( 'Niklas Laxström', 'Siebrand Mazeland' ),
    'descriptionmsg' => 'translate-desc',
    'url' => 'https://www.mediawiki.org/wiki/Extension:Translate',
)

Extension credits properties.

Definition at line 25 of file Translate.php.

$wgPageTranslationNamespace = 1198

Number for the Translations namespace.

Change this if it conflicts with other namespace in your wiki.

Definition at line 381 of file Translate.php.

Referenced by TranslateHooks::setupNamespaces(), and TranslateHooks::setupTranslate().

$wgTranslateAuthorBlacklist[] = array( 'black', '/^.*;.*;.*Bot$/Ui' )

Definition at line 438 of file Translate.php.

$wgTranslateAuthorBlacklist = array()

Two-dimensional array of rules that blacklists 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. Whitelisting always overrules blacklisting. 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.

Definition at line 437 of file Translate.php.

Referenced by SimpleFormatWriter::filterAuthors(), and SimpleFFS::filterAuthors().

$wgTranslateBlacklist = array()

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: $wgTranslateBlacklist = 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', ), );

Definition at line 414 of file Translate.php.

Referenced by SpecialTranslate::execute(), and StatsTable::isBlacklisted().

$wgTranslateCacheDirectory = false

Set location of cache files.

Defaults to $wgCacheDirectory.

Definition at line 505 of file Translate.php.

Referenced by TranslateUtils::cacheFile().

$wgTranslateCC = 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.

Definition at line 453 of file Translate.php.

Referenced by MessageGroups::loadGroupDefinitions().

$wgTranslateCheckBlacklist = false

File containing checks that are to be skipped.

See https://gerrit.wikimedia.org/r/gitweb?p=translatewiki.git;a=blob;f=check-blacklist.php;hb=HEAD for example.

Since:
2012-10-15

Definition at line 423 of file Translate.php.

Referenced by MessageChecker::__construct().

$wgTranslateDelayedMessageIndexRebuild = false

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

Definition at line 522 of file Translate.php.

Referenced by MessageIndexRebuildJob::insert(), MessageIndexRebuildJobTest::testInsertDelayed(), and MessageIndexRebuildJobTest::testInsertImmediate().

$wgTranslateDocumentationLanguageCode = false
$wgTranslateExtensionDirectory = "$IP/extensions/"

Location of your extensions, if not the default.

Only matters if you are localising your own extensions with this extension.

Definition at line 500 of file Translate.php.

Referenced by MagicWordsCM::__construct(), SpecialPageAliasesCM::__construct(), PremadeMediawikiExtensionGroups::loadConfigureExtensionData(), and MagicExport::openHandles().

$wgTranslateFuzzyBotName = 'FuzzyBot'

Name of the bot which will invalidate translations and do maintenance for page translation feature.

Also used for importing messages from external sources.

Definition at line 242 of file Translate.php.

Referenced by LanguageEditStats::execute(), ChangeSyncer::getLastGoodChange(), FuzzyBot::getName(), and TranslateHooks::setupTranslate().

$wgTranslateGroupFiles = array()

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";

Definition at line 466 of file Translate.php.

Referenced by YamlTests::execute(), and MessageGroups::loadGroupDefinitions().

$wgTranslateGroupRoot = '/var/www/externals'

Location in the filesystem to which paths are relative in custom groups.

Definition at line 458 of file Translate.php.

Referenced by FileBasedMessageGroup::replaceVariables().

$wgTranslateLanguageFallbacks = array()

Default values for list of languages to show translators as an aid when translating.

Each user can override this setting in their preferences. Example: $wgTranslateLanguageFallbacks['fi'] = 'sv'; $wgTranslateLanguageFallbacks['sv'] = array( 'da', 'no', 'nn' );

Definition at line 256 of file Translate.php.

Referenced by TranslationHelpers::getFallbacks(), InOtherLanguagesAid::getFallbacks(), and SpecialFirstSteps::getHelpers().

$wgTranslateMessageIndex = array( 'DatabaseMessageIndex' )

Configures how the message index is stored.

The other backends need $wgCacheDirectory to be functional.

Definition at line 511 of file Translate.php.

Referenced by MessageIndex::singleton().

$wgTranslateMessageNamespaces = array( NS_MEDIAWIKI )
$wgTranslateNewsletterPreference = false

Add a preference "Do not send me email newsletters" in the email preferences.

Definition at line 247 of file Translate.php.

Referenced by TranslatePreferences::onGetPreferences().

$wgTranslatePageTranslationULS = false

When user changes interface language via ULS, should we also switch the language of the translatable page.

Since:
2013-03-10

Definition at line 388 of file Translate.php.

Referenced by PageTranslationHooks::injectCss().

$wgTranslatePermissionUrl = 'Project:Translator'

When unprivileged users opens a translation editor, he will see message stating that 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.

Definition at line 361 of file Translate.php.

Referenced by TranslateHooks::addConfig(), and TranslationEditPage::getPermissionPageButton().

$wgTranslatePHPlot = false

For Special:TranslationStats PHPlot is needed to produce graphs.

Set this the location of phplot.php.

Definition at line 531 of file Translate.php.

Referenced by TranslateHooks::setupTranslate().

$wgTranslatePHPlotFont = '/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf'

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.

Definition at line 541 of file Translate.php.

Referenced by SpecialTranslationStats::draw().

$wgTranslateRcFilterDefault = 'filter'

Default action for the RecentChanges filter, which makes it possible to filter translations away or show them only.

Possible values: ('noaction', 'only', 'filter', 'site')

Definition at line 615 of file Translate.php.

Referenced by TranslateRcFilter::translationFilter().

$wgTranslateSandboxLimit = 20

Maximum number of translations a user can make in the sandbox.

Since:
2013.10

Definition at line 597 of file Translate.php.

Referenced by SpecialTranslationStash::execute(), and SandboxMessageGroup::getDefinitions().

$wgTranslateSandboxPromotedGroup = 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

Definition at line 585 of file Translate.php.

Referenced by TranslateSandbox::promoteUser().

$wgTranslateSandboxSuggestions = array()

List of page names to always suggest for sandboxed users.

Since:
2013.10

Definition at line 591 of file Translate.php.

Referenced by SandboxMessageGroup::getDefinitions().

$wgTranslateSupportUrl = false

Experimental support for Ask help button.

Might change into hook later on. This is an array with keys page and params.

  • page is a title of a local wiki page
  • params is an array of key-value pairs of request params -- param value can contain variable MESSAGE% which will be replaced with full page name.
    Since:
    2011-03-11

Definition at line 353 of file Translate.php.

Referenced by TranslateEditAddons::buttonHack(), SupportAid::getData(), and TranslationEditPage::getSupportButton().

$wgTranslateTasks
Initial value:
 array(
    'view' => 'ViewMessagesTask',
    'untranslated' => 'ViewUntranslatedTask',
    'optional' => 'ViewOptionalTask',
    'acceptqueue' => 'AcceptQueueMessagesTask',
    'reviewall' => 'ReviewAllMessagesTask',
    'export-as-po' => 'ExportasPoMessagesTask',
    'export-to-file' => 'ExportToFileMessagesTask',
    'custom' => 'CustomFilteredMessagesTask',
)

List of tasks in Special:Translate.

If you are only using page translation feature, you might want to disable 'optional' task. Example: unset($wgTranslateTasks['optional']);

Definition at line 332 of file Translate.php.

Referenced by TranslateTasks::getTask(), TranslateTasks::getTasks(), and SpecialTranslate::tabify().

$wgTranslateTestTTMServer = null

Set this to config like $wgTranslateTranslationServices if you want to run SolrTTMServer tests.

Since:
2013-01-04

Definition at line 622 of file Translate.php.

Referenced by SolrTTMServerTest::setUp(), and SolrTTMServerTest::testSearchableTTMServer().

$wgTranslateTestUsers = array()

List of user names that are allowed to alter their privileges and do other things.

Used for supporting integration testing.

Since:
2013.10

Definition at line 636 of file Translate.php.

Referenced by SpecialTranslationStash::hasPermissionToUse().

$wgTranslateTranslationServices['Yandex']
Initial value:
 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',
)

Definition at line 305 of file Translate.php.

$wgTranslateTranslationServices['Apertium']
Initial value:
 array(
    'url' => 'http://api.apertium.org/json/translate',
    'pairs' => 'http://api.apertium.org/json/listPairs',
    'key' => null,
    'timeout' => 3,
    'type' => 'apertium',
)

Definition at line 298 of file Translate.php.

$wgTranslateTranslationServices['Microsoft']
Initial value:
 array(
    'url' => 'http://api.microsofttranslator.com/V2/Http.svc/Translate',
    'key' => null,
    'timeout' => 3,
    'type' => 'microsoft',
)

Definition at line 292 of file Translate.php.

$wgTranslateTranslationServices['TTMServer']
Initial value:
 array(
    'database' => false, 
    'cutoff' => 0.75,
    'type' => 'ttmserver',
    'public' => false,
)

Definition at line 286 of file Translate.php.

if (!defined( 'TRANSLATE_FUZZY')) $wgTranslateTranslationServices = array()

Text that will be shown in translations if the translation is outdated.

Must be something that does not conflict with actual content. Define various web services that provide translation suggestions.

For Apertium, you should get an API key.

See also:
http://wiki.apertium.org/wiki/Apertium_web_service

Yandex translation helper also provides langlimit option to limit total number of suggestions (set to 0 to get all possible translations) and langorder array to sort languages. Yandex translate engine is based on wordnet, generated from search index, so number of indexed websites should be a good heuristic to define the default language order.

The machine translation services are provided with the following information:

  • server ip address
  • versions of MediaWiki and Translate extension
  • clients ip address encrypted with $wgProxyKey
  • source text to translate
  • private API key if provided

Definition at line 285 of file Translate.php.

Referenced by ApiTTMServer::execute(), ApiTTMServer::getAvailableTranslationServices(), TTMServerAid::getData(), MachineTranslationAid::getData(), TranslationHelpers::getSuggestionBox(), TTMServer::primary(), TTMServerTest::setUp(), SolrTTMServerTest::setUp(), TTMServerTest::tearDown(), and TTMServerTest::testConstruct().

$wgTranslateUsePreSaveTransform = false

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.

Definition at line 608 of file Translate.php.

Referenced by TranslateEditAddons::disablePreSaveTransform().

$wgTranslateUseSandbox = false

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. Only works with MediaWiki 1.22 or newer.

Since:
2013.04

Definition at line 578 of file Translate.php.

Referenced by SpecialTranslateSandbox::__construct(), TranslateSandbox::enforcePermissions(), and ApiTranslateSandbox::execute().

$wgTranslateUseTux = true

Whether to use the TUX interface by default.

tux=1 and tux=0 in the url can be used to switch between old and new. This variable will be removed after transition time.

Definition at line 629 of file Translate.php.

Referenced by SpecialTranslate::isBeta().

$wgTranslateWorkflowStates = false

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', ), );

Definition at line 491 of file Translate.php.

Referenced by SpecialLanguageStats::addWorkflowStatesColumn(), MessageGroupOld::getWorkflowConfiguration(), MessageGroupBase::getWorkflowConfiguration(), and MessageGroups::loadGroupDefinitions().

$wgTranslateYamlLibrary = 'spyc'

Currently supported YAML drivers are spyc and syck and sycl-pecl.

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 'YAMLSyck' 'PHPSerialization' 'FileSlurp'; 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.

For syck-pecl you need libsyck and pecl install syck-beta

Definition at line 566 of file Translate.php.

Referenced by YamlFFS::doHeader(), TranslateYaml::dump(), YamlTests::execute(), and TranslateYaml::loadString().

Generated on Tue Oct 29 00:00:26 2013 for MediaWiki Translate Extension by  doxygen 1.6.3