2declare( strict_types = 1 );
7use MediaWiki\Permissions\Authority;
23 global $wgTranslateValidationExclusionFile;
24 return $wgTranslateValidationExclusionFile;
27 public function getTranslateAuthorExclusionList(): array {
28 global $wgTranslateAuthorExclusionList;
29 return $wgTranslateAuthorExclusionList;
32 public function getDisabledTargetLanguages(): array {
33 global $wgTranslateDisabledTargetLanguages;
34 return $wgTranslateDisabledTargetLanguages;
47 ?
string &$reason =
null
49 $globalDisabledReason = null;
50 $groupId = $group->
getId();
53 strtok( $groupId,
'-' ),
57 $disabledLanguages = $this->getDisabledTargetLanguages();
58 foreach ( $checks as $check ) {
59 if ( isset( $disabledLanguages[$check][$languageCode] ) ) {
60 $globalDisabledReason = $disabledLanguages[$check][$languageCode];
67 $isLanguageDisabled = $groupLanguages === MessageGroup::DEFAULT_LANGUAGES
68 ? $globalDisabledReason !== null
69 : !array_key_exists( $languageCode, $groupLanguages );
72 if ( $isLanguageDisabled ) {
73 $reason = $globalDisabledReason;
76 return $isLanguageDisabled;
94 if ( $translated === 0 && $fuzzy === 0 ) {
97 return $authority->isAllowed(
'pagetranslation' );
100 public function isAuthorExcluded(
MessageGroup|
string $group,
string $languageCode,
string $username ): bool {
101 $groupId = $group instanceof
MessageGroup ? $group->getId() : $group;
102 $hash =
"$groupId;$languageCode;$username";
103 $authorExclusionList = $this->getTranslateAuthorExclusionList();
106 foreach ( $authorExclusionList as [ $type, $regex ] ) {
107 if ( preg_match( $regex, $hash ) ) {
108 if ( $type ===
'include' ) {