Translate extension for MediaWiki
 
Loading...
Searching...
No Matches
HookRunner.php
1<?php
2declare( strict_types = 1 );
3
4// phpcs:disable MediaWiki.NamingConventions.LowerCamelFunctionsName.FunctionName
5
6namespace MediaWiki\Extension\Translate;
7
23use MediaWiki\HookContainer\HookContainer;
24use MediaWiki\User\UserIdentity;
25use MessageGroup;
27use User;
28
38class HookRunner implements
54{
55 private HookContainer $hookContainer;
56
57 public function __construct( HookContainer $hookContainer ) {
58 $this->hookContainer = $hookContainer;
59 }
60
61 public function onTranslate_TranslatorSandbox_UserPromoted( UserIdentity $user ): void {
62 $this->hookContainer->run( 'Translate:TranslatorSandbox:UserPromoted', [ $user ], [ 'abortable' => false ] );
63 }
64
65 public function onTranslatePrefillTranslation( ?string &$translation, MessageHandle $handle ) {
66 return $this->hookContainer->run( 'TranslatePrefillTranslation', [ &$translation, $handle ] );
67 }
68
69 public function onTranslateBeforeAddModules( array &$modules ) {
70 return $this->hookContainer->run( 'TranslateBeforeAddModules', [ &$modules ] );
71 }
72
74 return $this->hookContainer->run( 'TranslateEventTranslationReview', [ $handle ] );
75 }
76
77 public function onTranslateGetSpecialTranslateOptions( array &$defaults, array &$nonDefaults ) {
78 return $this->hookContainer->run( 'TranslateGetSpecialTranslateOptions', [ &$defaults, &$nonDefaults ] );
79 }
80
81 public function onTranslate_newTranslation( MessageHandle $handle, int $revisionId, string $text, User $user ) {
82 return $this->hookContainer->run( 'Translate:newTranslation', [ $handle, $revisionId, $text, $user ] );
83 }
84
85 public function onTranslate_modifyMessageGroupStates( string $groupId, array &$conf ) {
86 return $this->hookContainer->run( 'Translate:modifyMessageGroupStates', [ $groupId, &$conf ] );
87 }
88
90 MessageGroup $group,
91 string $code,
92 $oldState,
93 string $newState
94 ) {
95 return $this->hookContainer->run( 'TranslateEventMessageGroupStateChange',
96 [ $group, $code, $oldState, $newState ] );
97 }
98
99 public function onTranslateGetAPIMessageGroupsParameterList( array &$params ) {
100 return $this->hookContainer->run( 'TranslateGetAPIMessageGroupsParameterList', [ &$params ] );
101 }
102
103 public function onTranslateGetAPIMessageGroupsPropertyDescs( array &$properties ) {
104 return $this->hookContainer->run( 'TranslateGetAPIMessageGroupsPropertyDescs', [ &$properties ] );
105 }
106
107 public function onTranslateInitGroupLoaders( array &$groupLoader, array $deps ) {
108 return $this->hookContainer->run( 'TranslateInitGroupLoaders', [ &$groupLoader, $deps ] );
109 }
110
111 public function onTranslatePostInitGroups( array &$groups, array &$deps, array &$autoload ) {
112 return $this->hookContainer->run( 'TranslatePostInitGroups', [ &$groups, &$deps, &$autoload ] );
113 }
114
116 array &$a,
117 array $props,
118 array $params,
119 MessageGroup $g
120 ) {
121 return $this->hookContainer->run( 'TranslateProcessAPIMessageGroupsProperties', [ &$a, $props, $params, $g ] );
122 }
123
124 public function onTranslateSupportedLanguages( array &$list, ?string $language ) {
125 return $this->hookContainer->run( 'TranslateSupportedLanguages', [ &$list, $language ] );
126 }
127
128 public function onTranslateEventMessageMembershipChange( MessageHandle $handle, array $old, array $new ) {
129 return $this->hookContainer->run( 'TranslateEventMessageMembershipChange', [ $handle, $old, $new ] );
130 }
131}
Hook runner for the Translate extension.
onTranslateGetAPIMessageGroupsPropertyDescs(array &$properties)
Allows extra properties to be added to captured by action=query&meta=messagegroups&mgprop=foo|bar|bat...
onTranslateGetSpecialTranslateOptions(array &$defaults, array &$nonDefaults)
Provides an opportunity for overriding task values.
onTranslatePrefillTranslation(?string &$translation, MessageHandle $handle)
Provides an opportunity for a new translation to start not from as a carte blanche (the default) but ...
onTranslateGetAPIMessageGroupsParameterList(array &$params)
Allows extra parameters to be added to the action=query&meta=messagegroups module.
onTranslateSupportedLanguages(array &$list, ?string $language)
Allows removing languages from language selectors.
onTranslateEventMessageGroupStateChange(MessageGroup $group, string $code, $oldState, string $newState)
Event triggered when a message group workflow state is changed in a language.
onTranslate_newTranslation(MessageHandle $handle, int $revisionId, string $text, User $user)
Event triggered when non-fuzzy translation has been made.
onTranslateProcessAPIMessageGroupsProperties(array &$a, array $props, array $params, MessageGroup $g)
Allows extra property requests to be acted upon, and the new properties returned.
onTranslateEventTranslationReview(MessageHandle $handle)
Event triggered when a translation is proofread.
onTranslateBeforeAddModules(array &$modules)
Provides an opportunity to load extra modules.
onTranslate_TranslatorSandbox_UserPromoted(UserIdentity $user)
Event generated when an account inside the translator sandbox is approved.
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.
onTranslate_modifyMessageGroupStates(string $groupId, array &$conf)
Allow hooks to change workflow states depending on the group's ID.
onTranslateEventMessageMembershipChange(MessageHandle $handle, array $old, array $new)
When group gets new messages or loses messages.
Class for pointing to messages, like Title class is for titles.
This is a hook handler interface, see docs/Hooks.md in core.
This is a hook handler interface, see docs/Hooks.md in core.
This is a hook handler interface, see docs/Hooks.md in core.
This is a hook handler interface, see docs/Hooks.md in core.
This is a hook handler interface, see docs/Hooks.md in core.
This is a hook handler interface, see docs/Hooks.md in core.
This is a hook handler interface, see docs/Hooks.md in core.
Interface for message groups.