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
16use MediaWiki\Extension\Translate\PageTranslation\TranslateTitleEnum;
25use MediaWiki\HookContainer\HookContainer;
26use MediaWiki\Page\PageIdentity;
27use MediaWiki\User\User;
28use MediaWiki\User\UserIdentity;
29use MessageGroup;
30
40class HookRunner implements
56{
57
58 public function __construct(
59 private readonly HookContainer $hookContainer,
60 ) {
61 }
62
64 public function onTranslate_TranslatorSandbox_UserPromoted( UserIdentity $user ): void {
65 $this->hookContainer->run( 'Translate:TranslatorSandbox:UserPromoted', [ $user ], [ 'abortable' => false ] );
66 }
67
69 public function onTranslatePrefillTranslation( ?string &$translation, MessageHandle $handle ) {
70 return $this->hookContainer->run( 'TranslatePrefillTranslation', [ &$translation, $handle ] );
71 }
72
74 public function onTranslateBeforeAddModules( array &$modules ) {
75 return $this->hookContainer->run( 'TranslateBeforeAddModules', [ &$modules ] );
76 }
77
80 return $this->hookContainer->run( 'TranslateEventTranslationReview', [ $handle ] );
81 }
82
84 public function onTranslateGetSpecialTranslateOptions( array &$defaults, array &$nonDefaults ) {
85 return $this->hookContainer->run( 'TranslateGetSpecialTranslateOptions', [ &$defaults, &$nonDefaults ] );
86 }
87
89 public function onTranslate_newTranslation( MessageHandle $handle, int $revisionId, string $text, User $user ) {
90 return $this->hookContainer->run( 'Translate:newTranslation', [ $handle, $revisionId, $text, $user ] );
91 }
92
94 public function onTranslate_modifyMessageGroupStates( string $groupId, array &$conf ) {
95 return $this->hookContainer->run( 'Translate:modifyMessageGroupStates', [ $groupId, &$conf ] );
96 }
97
100 MessageGroup $group,
101 string $code,
102 $oldState,
103 string $newState
104 ) {
105 return $this->hookContainer->run( 'TranslateEventMessageGroupStateChange',
106 [ $group, $code, $oldState, $newState ] );
107 }
108
110 public function onTranslateInitGroupLoaders( array &$groupLoader, array $deps ) {
111 return $this->hookContainer->run( 'TranslateInitGroupLoaders', [ &$groupLoader, $deps ] );
112 }
113
115 public function onTranslatePostInitGroups( array &$groups, array &$deps, array &$autoload ) {
116 return $this->hookContainer->run( 'TranslatePostInitGroups', [ &$groups, &$deps, &$autoload ] );
117 }
118
121 array &$a,
122 array $props,
123 array $params,
124 MessageGroup $g
125 ) {
126 return $this->hookContainer->run( 'TranslateProcessAPIMessageGroupsProperties', [ &$a, $props, $params, $g ] );
127 }
128
130 public function onTranslateSupportedLanguages( array &$list, ?string $language ) {
131 return $this->hookContainer->run( 'TranslateSupportedLanguages', [ &$list, $language ] );
132 }
133
135 public function onTranslateEventMessageMembershipChange( MessageHandle $handle, array $old, array $new ) {
136 return $this->hookContainer->run( 'TranslateEventMessageMembershipChange', [ $handle, $old, $new ] );
137 }
138
141 array &$headers,
142 MessageGroup $group,
143 string $languageCode
144 ) {
145 return $this->hookContainer->run(
146 'Translate:GettextFormat:headerFields',
147 [ &$headers, $group, $languageCode ]
148 );
149 }
150
153 TranslateTitleEnum &$state,
154 PageIdentity $page,
155 ?string &$reason
156 ): void {
157 $this->hookContainer->run(
158 'TranslateTitlePageTranslation', [ &$state, $page, &$reason ], [ 'abortable' => false ]
159 );
160 }
161}
Hook runner for the Translate extension.
onTranslateGetSpecialTranslateOptions(array &$defaults, array &$nonDefaults)
@inheritDoc
onTranslatePrefillTranslation(?string &$translation, MessageHandle $handle)
@inheritDoc
onTranslateSupportedLanguages(array &$list, ?string $language)
@inheritDoc
onTranslateEventMessageGroupStateChange(MessageGroup $group, string $code, $oldState, string $newState)
@inheritDoc
onTranslate_newTranslation(MessageHandle $handle, int $revisionId, string $text, User $user)
@inheritDoc
onTranslateProcessAPIMessageGroupsProperties(array &$a, array $props, array $params, MessageGroup $g)
@inheritDoc
onTranslateEventTranslationReview(MessageHandle $handle)
@inheritDoc
onTranslateBeforeAddModules(array &$modules)
@inheritDoc
onTranslate_GettextFormat_headerFields(array &$headers, MessageGroup $group, string $languageCode)
@inheritDoc
onTranslate_TranslatorSandbox_UserPromoted(UserIdentity $user)
@inheritDoc
onTranslateInitGroupLoaders(array &$groupLoader, array $deps)
@inheritDoc
onTranslatePostInitGroups(array &$groups, array &$deps, array &$autoload)
@inheritDoc
onTranslate_modifyMessageGroupStates(string $groupId, array &$conf)
@inheritDoc
onTranslateTitlePageTranslation(TranslateTitleEnum &$state, PageIdentity $page, ?string &$reason)
@inheritDoc
onTranslateEventMessageMembershipChange(MessageHandle $handle, array $old, array $new)
@inheritDoc
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.