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
25use MediaWiki\HookContainer\HookContainer;
26use MediaWiki\User\UserIdentity;
27use MessageGroup;
28use User;
29
39class HookRunner implements
56{
57 private HookContainer $hookContainer;
58
59 public function __construct( HookContainer $hookContainer ) {
60 $this->hookContainer = $hookContainer;
61 }
62
63 public function onTranslate_TranslatorSandbox_UserPromoted( UserIdentity $user ): void {
64 $this->hookContainer->run( 'Translate:TranslatorSandbox:UserPromoted', [ $user ], [ 'abortable' => false ] );
65 }
66
67 public function onTranslatePrefillTranslation( ?string &$translation, MessageHandle $handle ) {
68 return $this->hookContainer->run( 'TranslatePrefillTranslation', [ &$translation, $handle ] );
69 }
70
71 public function onTranslateBeforeAddModules( array &$modules ) {
72 return $this->hookContainer->run( 'TranslateBeforeAddModules', [ &$modules ] );
73 }
74
76 return $this->hookContainer->run( 'TranslateEventTranslationReview', [ $handle ] );
77 }
78
79 public function onTranslateGetSpecialTranslateOptions( array &$defaults, array &$nonDefaults ) {
80 return $this->hookContainer->run( 'TranslateGetSpecialTranslateOptions', [ &$defaults, &$nonDefaults ] );
81 }
82
83 public function onTranslate_newTranslation( MessageHandle $handle, int $revisionId, string $text, User $user ) {
84 return $this->hookContainer->run( 'Translate:newTranslation', [ $handle, $revisionId, $text, $user ] );
85 }
86
87 public function onTranslate_modifyMessageGroupStates( string $groupId, array &$conf ) {
88 return $this->hookContainer->run( 'Translate:modifyMessageGroupStates', [ $groupId, &$conf ] );
89 }
90
92 MessageGroup $group,
93 string $code,
94 $oldState,
95 string $newState
96 ) {
97 return $this->hookContainer->run( 'TranslateEventMessageGroupStateChange',
98 [ $group, $code, $oldState, $newState ] );
99 }
100
101 public function onTranslateGetAPIMessageGroupsParameterList( array &$params ) {
102 return $this->hookContainer->run( 'TranslateGetAPIMessageGroupsParameterList', [ &$params ] );
103 }
104
105 public function onTranslateGetAPIMessageGroupsPropertyDescs( array &$properties ) {
106 return $this->hookContainer->run( 'TranslateGetAPIMessageGroupsPropertyDescs', [ &$properties ] );
107 }
108
109 public function onTranslateInitGroupLoaders( array &$groupLoader, array $deps ) {
110 return $this->hookContainer->run( 'TranslateInitGroupLoaders', [ &$groupLoader, $deps ] );
111 }
112
113 public function onTranslatePostInitGroups( array &$groups, array &$deps, array &$autoload ) {
114 return $this->hookContainer->run( 'TranslatePostInitGroups', [ &$groups, &$deps, &$autoload ] );
115 }
116
118 array &$a,
119 array $props,
120 array $params,
121 MessageGroup $g
122 ) {
123 return $this->hookContainer->run( 'TranslateProcessAPIMessageGroupsProperties', [ &$a, $props, $params, $g ] );
124 }
125
126 public function onTranslateSupportedLanguages( array &$list, ?string $language ) {
127 return $this->hookContainer->run( 'TranslateSupportedLanguages', [ &$list, $language ] );
128 }
129
130 public function onTranslateEventMessageMembershipChange( MessageHandle $handle, array $old, array $new ) {
131 return $this->hookContainer->run( 'TranslateEventMessageMembershipChange', [ $handle, $old, $new ] );
132 }
133
135 array &$headers,
136 MessageGroup $group,
137 string $languageCode
138 ) {
139 return $this->hookContainer->run(
140 'Translate:GettextFormat:headerFields',
141 [ &$headers, $group, $languageCode ]
142 );
143 }
144}
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_GettextFormat_headerFields(array &$headers, MessageGroup $group, string $languageCode)
Allows per group customization of headers in exported Gettext files per group.
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.