Translate extension for MediaWiki
 
Loading...
Searching...
No Matches
MediaWiki\Extension\Translate\HookRunner Class Reference

Hook runner for the Translate extension. More...

Inheritance diagram for MediaWiki\Extension\Translate\HookRunner:
MediaWiki\Extension\Translate\FileFormatSupport\GettextFormatHeaderFieldsHook MediaWiki\Extension\Translate\MessageGroupProcessing\EventMessageMembershipChangeHook MediaWiki\Extension\Translate\Utilities\SupportedLanguagesHook MediaWiki\Extension\Translate\MessageGroupProcessing\ProcessAPIMessageGroupsPropertiesHook MediaWiki\Extension\Translate\MessageGroupProcessing\PostInitGroupsHook MediaWiki\Extension\Translate\MessageGroupProcessing\InitGroupLoadersHook MediaWiki\Extension\Translate\MessageGroupProcessing\EventMessageGroupStateChangeHook MediaWiki\Extension\Translate\MessageGroupProcessing\ModifyMessageGroupStatesHook MediaWiki\Extension\Translate\TranslatorInterface\NewTranslationHook MediaWiki\Extension\Translate\TranslatorInterface\GetSpecialTranslateOptionsHook MediaWiki\Extension\Translate\TranslatorInterface\EventTranslationReviewHook MediaWiki\Extension\Translate\TranslatorInterface\BeforeAddModulesHook MediaWiki\Extension\Translate\TranslatorInterface\Aid\PrefillTranslationHook MediaWiki\Extension\Translate\TranslatorSandbox\UserPromotedHook

Public Member Functions

 __construct (HookContainer $hookContainer)
 
 onTranslate_TranslatorSandbox_UserPromoted (UserIdentity $user)
 Event generated when an account inside the translator sandbox is approved.
 
 onTranslatePrefillTranslation (?string &$translation, MessageHandle $handle)
 Provides an opportunity for a new translation to start not from as a carte blanche (the default) but from some prefilled string.
 
 onTranslateBeforeAddModules (array &$modules)
 Provides an opportunity to load extra modules.
 
 onTranslateEventTranslationReview (MessageHandle $handle)
 Event triggered when a translation is proofread.
 
 onTranslateGetSpecialTranslateOptions (array &$defaults, array &$nonDefaults)
 Provides an opportunity for overriding task values.
 
 onTranslate_newTranslation (MessageHandle $handle, int $revisionId, string $text, User $user)
 Event triggered when non-fuzzy translation has been made.
 
 onTranslate_modifyMessageGroupStates (string $groupId, array &$conf)
 Allow hooks to change workflow states depending on the group's ID.
 
 onTranslateEventMessageGroupStateChange (MessageGroup $group, string $code, $oldState, string $newState)
 Event triggered when a message group workflow state is changed in a language.
 
 onTranslateInitGroupLoaders (array &$groupLoader, array $deps)
 Hook to register new message group loaders that can then load MessageGroups for translation purpose.
 
 onTranslatePostInitGroups (array &$groups, array &$deps, array &$autoload)
 Hook to register new message groups to Translate.
 
 onTranslateProcessAPIMessageGroupsProperties (array &$a, array $props, array $params, MessageGroup $g)
 Allows extra property requests to be acted upon, and the new properties returned.
 
 onTranslateSupportedLanguages (array &$list, ?string $language)
 Allows removing languages from language selectors.
 
 onTranslateEventMessageMembershipChange (MessageHandle $handle, array $old, array $new)
 When group gets new messages or loses messages.
 
 onTranslate_GettextFormat_headerFields (array &$headers, MessageGroup $group, string $languageCode)
 Allows per group customization of headers in exported Gettext files per group.
 

Detailed Description

Hook runner for the Translate extension.

This is a hook runner class, see docs/Hooks.md in core.

Definition at line 37 of file HookRunner.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Extension\Translate\HookRunner::__construct ( HookContainer $hookContainer)

Definition at line 55 of file HookRunner.php.

Member Function Documentation

◆ onTranslate_GettextFormat_headerFields()

MediaWiki\Extension\Translate\HookRunner::onTranslate_GettextFormat_headerFields ( array & $headers,
MessageGroup $group,
string $languageCode )

Allows per group customization of headers in exported Gettext files per group.

Certain X-headers and Plural-Forms cannot be customized.

Parameters
array<string,string>&$headers List of prefilled headers. You can remove, change or add new headers.
MessageGroup$group
string$languageCode
Returns
void|bool True or no return value to continue or false to abort

Implements MediaWiki\Extension\Translate\FileFormatSupport\GettextFormatHeaderFieldsHook.

Definition at line 122 of file HookRunner.php.

◆ onTranslate_modifyMessageGroupStates()

MediaWiki\Extension\Translate\HookRunner::onTranslate_modifyMessageGroupStates ( string $groupId,
array & $conf )

Allow hooks to change workflow states depending on the group's ID.

Parameters
string$groupIdID of the current message group
array&$confWorkflow states, can be modified
Returns
bool|void True or no return value to continue or false to abort

Implements MediaWiki\Extension\Translate\MessageGroupProcessing\ModifyMessageGroupStatesHook.

Definition at line 83 of file HookRunner.php.

◆ onTranslate_newTranslation()

MediaWiki\Extension\Translate\HookRunner::onTranslate_newTranslation ( MessageHandle $handle,
int $revisionId,
string $text,
User $user )

Event triggered when non-fuzzy translation has been made.

Parameters
MessageHandle$handle
int$revisionId
string$textContent of the new translation
User$userUser who created or changed the translation
Returns
bool|void True or no return value to continue or false to abort

Implements MediaWiki\Extension\Translate\TranslatorInterface\NewTranslationHook.

Definition at line 79 of file HookRunner.php.

◆ onTranslate_TranslatorSandbox_UserPromoted()

MediaWiki\Extension\Translate\HookRunner::onTranslate_TranslatorSandbox_UserPromoted ( UserIdentity $user)

Event generated when an account inside the translator sandbox is approved.

Implements MediaWiki\Extension\Translate\TranslatorSandbox\UserPromotedHook.

Definition at line 59 of file HookRunner.php.

◆ onTranslateBeforeAddModules()

MediaWiki\Extension\Translate\HookRunner::onTranslateBeforeAddModules ( array & $modules)

Provides an opportunity to load extra modules.

Parameters
string[]&$modulesList of resource loader module names
Returns
bool|void True or no return value to continue or false to abort

Implements MediaWiki\Extension\Translate\TranslatorInterface\BeforeAddModulesHook.

Definition at line 67 of file HookRunner.php.

◆ onTranslateEventMessageGroupStateChange()

MediaWiki\Extension\Translate\HookRunner::onTranslateEventMessageGroupStateChange ( MessageGroup $group,
string $code,
$oldState,
string $newState )

Event triggered when a message group workflow state is changed in a language.

Parameters
MessageGroup$groupMessage group instance
string$codeLanguage code
string | false$oldState
string$newState
Returns
bool|void True or no return value to continue or false to abort

Implements MediaWiki\Extension\Translate\MessageGroupProcessing\EventMessageGroupStateChangeHook.

Definition at line 87 of file HookRunner.php.

◆ onTranslateEventMessageMembershipChange()

MediaWiki\Extension\Translate\HookRunner::onTranslateEventMessageMembershipChange ( MessageHandle $handle,
array $old,
array $new )

When group gets new messages or loses messages.

Parameters
MessageHandle$handle
string[]$oldPrevious groups
string[]$newCurrent groups
Returns
bool|void True or no return value to continue or false to abort

Implements MediaWiki\Extension\Translate\MessageGroupProcessing\EventMessageMembershipChangeHook.

Definition at line 118 of file HookRunner.php.

◆ onTranslateEventTranslationReview()

MediaWiki\Extension\Translate\HookRunner::onTranslateEventTranslationReview ( MessageHandle $handle)

Event triggered when a translation is proofread.

Parameters
MessageHandle$handle
Returns
bool|void True or no return value to continue or false to abort

Implements MediaWiki\Extension\Translate\TranslatorInterface\EventTranslationReviewHook.

Definition at line 71 of file HookRunner.php.

◆ onTranslateGetSpecialTranslateOptions()

MediaWiki\Extension\Translate\HookRunner::onTranslateGetSpecialTranslateOptions ( array & $defaults,
array & $nonDefaults )

Provides an opportunity for overriding task values.

Parameters
array&$defaultsAssociative array of default values
array&$nonDefaultsAssociative array of nondefault (override) values
Returns
bool|void True or no return value to continue or false to abort

Implements MediaWiki\Extension\Translate\TranslatorInterface\GetSpecialTranslateOptionsHook.

Definition at line 75 of file HookRunner.php.

◆ onTranslateInitGroupLoaders()

MediaWiki\Extension\Translate\HookRunner::onTranslateInitGroupLoaders ( array & $groupLoader,
array $deps )

Hook to register new message group loaders that can then load MessageGroups for translation purpose.

Parameters
array&$groupLoaderList of message group loader class names that implement the MessageGroupLoader
array$deps
Returns
bool|void True or no return value to continue or false to abort

Implements MediaWiki\Extension\Translate\MessageGroupProcessing\InitGroupLoadersHook.

Definition at line 97 of file HookRunner.php.

◆ onTranslatePostInitGroups()

MediaWiki\Extension\Translate\HookRunner::onTranslatePostInitGroups ( array & $groups,
array & $deps,
array & $autoload )

Hook to register new message groups to Translate.

Manual cache clear may be needed to have this hook executed.

Parameters
MessageGroup[]&$groupsMap of message group id to message group instance
array&$depsList of dependencies as supported by DependencyWrapper class from MediaWiki
string[]&$autoloadList of autoloaded classes. Key is the name of the class and value is filename
Returns
bool|void True or no return value to continue or false to abort

Implements MediaWiki\Extension\Translate\MessageGroupProcessing\PostInitGroupsHook.

Definition at line 101 of file HookRunner.php.

◆ onTranslatePrefillTranslation()

MediaWiki\Extension\Translate\HookRunner::onTranslatePrefillTranslation ( ?string & $translation,
MessageHandle $handle )

Provides an opportunity for a new translation to start not from as a carte blanche (the default) but from some prefilled string.

Parameters
string | null&$translationThe translation string as it stands, or null for new translations
MessageHandle$handleThe current MessageHandle object
Returns
bool|void True or no return value to continue or false to abort

Implements MediaWiki\Extension\Translate\TranslatorInterface\Aid\PrefillTranslationHook.

Definition at line 63 of file HookRunner.php.

◆ onTranslateProcessAPIMessageGroupsProperties()

MediaWiki\Extension\Translate\HookRunner::onTranslateProcessAPIMessageGroupsProperties ( array & $a,
array $props,
array $params,
MessageGroup $g )

Allows extra property requests to be acted upon, and the new properties returned.

Parameters
array&$aAssociative array of the properties of $group that will be returned
array$propsAssociative array ($name => true) of properties the user has specifically requested
array$paramsParameter input by the user (unprefixed name => value)
MessageGroup$gThe group in question
Returns
bool|void True or no return value to continue or false to abort

Implements MediaWiki\Extension\Translate\MessageGroupProcessing\ProcessAPIMessageGroupsPropertiesHook.

Definition at line 105 of file HookRunner.php.

◆ onTranslateSupportedLanguages()

MediaWiki\Extension\Translate\HookRunner::onTranslateSupportedLanguages ( array & $list,
?string $language )

Allows removing languages from language selectors.

For adding $wgExtraLanguage names is recommended.

Parameters
string[]&$listList of languages indexed by language code
string | null$languageLanguage code of the language of which language names are in
Returns
bool|void True or no return value to continue or false to abort

Implements MediaWiki\Extension\Translate\Utilities\SupportedLanguagesHook.

Definition at line 114 of file HookRunner.php.


The documentation for this class was generated from the following file: