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\User;
25use MediaWiki\User\UserIdentity;
26use MessageGroup;
27
37class HookRunner implements
52{
53 private HookContainer $hookContainer;
54
55 public function __construct( HookContainer $hookContainer ) {
56 $this->hookContainer = $hookContainer;
57 }
58
59 public function onTranslate_TranslatorSandbox_UserPromoted( UserIdentity $user ): void {
60 $this->hookContainer->run( 'Translate:TranslatorSandbox:UserPromoted', [ $user ], [ 'abortable' => false ] );
61 }
62
63 public function onTranslatePrefillTranslation( ?string &$translation, MessageHandle $handle ) {
64 return $this->hookContainer->run( 'TranslatePrefillTranslation', [ &$translation, $handle ] );
65 }
66
67 public function onTranslateBeforeAddModules( array &$modules ) {
68 return $this->hookContainer->run( 'TranslateBeforeAddModules', [ &$modules ] );
69 }
70
72 return $this->hookContainer->run( 'TranslateEventTranslationReview', [ $handle ] );
73 }
74
75 public function onTranslateGetSpecialTranslateOptions( array &$defaults, array &$nonDefaults ) {
76 return $this->hookContainer->run( 'TranslateGetSpecialTranslateOptions', [ &$defaults, &$nonDefaults ] );
77 }
78
79 public function onTranslate_newTranslation( MessageHandle $handle, int $revisionId, string $text, User $user ) {
80 return $this->hookContainer->run( 'Translate:newTranslation', [ $handle, $revisionId, $text, $user ] );
81 }
82
83 public function onTranslate_modifyMessageGroupStates( string $groupId, array &$conf ) {
84 return $this->hookContainer->run( 'Translate:modifyMessageGroupStates', [ $groupId, &$conf ] );
85 }
86
88 MessageGroup $group,
89 string $code,
90 $oldState,
91 string $newState
92 ) {
93 return $this->hookContainer->run( 'TranslateEventMessageGroupStateChange',
94 [ $group, $code, $oldState, $newState ] );
95 }
96
97 public function onTranslateInitGroupLoaders( array &$groupLoader, array $deps ) {
98 return $this->hookContainer->run( 'TranslateInitGroupLoaders', [ &$groupLoader, $deps ] );
99 }
100
101 public function onTranslatePostInitGroups( array &$groups, array &$deps, array &$autoload ) {
102 return $this->hookContainer->run( 'TranslatePostInitGroups', [ &$groups, &$deps, &$autoload ] );
103 }
104
106 array &$a,
107 array $props,
108 array $params,
109 MessageGroup $g
110 ) {
111 return $this->hookContainer->run( 'TranslateProcessAPIMessageGroupsProperties', [ &$a, $props, $params, $g ] );
112 }
113
114 public function onTranslateSupportedLanguages( array &$list, ?string $language ) {
115 return $this->hookContainer->run( 'TranslateSupportedLanguages', [ &$list, $language ] );
116 }
117
118 public function onTranslateEventMessageMembershipChange( MessageHandle $handle, array $old, array $new ) {
119 return $this->hookContainer->run( 'TranslateEventMessageMembershipChange', [ $handle, $old, $new ] );
120 }
121
123 array &$headers,
124 MessageGroup $group,
125 string $languageCode
126 ) {
127 return $this->hookContainer->run(
128 'Translate:GettextFormat:headerFields',
129 [ &$headers, $group, $languageCode ]
130 );
131 }
132}
Hook runner for the Translate extension.
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 ...
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.