51 if ( $action !==
'edit' ) {
56 if ( !$handle->isValid() ) {
60 if ( $user->isAllowed(
'translate-manage' ) ) {
64 $group = $handle->getGroup();
65 $languages = $group->getTranslatableLanguages();
66 $langCode = $handle->getCode();
67 if ( $languages !==
null && $langCode && !isset( $languages[$langCode] ) ) {
68 $result = [
'translate-language-disabled' ];
72 $groupId = $group->getId();
75 strtok( $groupId,
'-' ),
79 $disabledLanguages = Services::getInstance()->getConfigHelper()->getDisabledTargetLanguages();
80 foreach ( $checks as $check ) {
81 if ( isset( $disabledLanguages[$check][$langCode] ) ) {
82 $reason = $disabledLanguages[$check][$langCode];
83 $result = [
'translate-page-disabled', $reason ];
97 UserIdentity $userIdentity,
100 RevisionRecord $revisionRecord,
101 EditResult $editResult
103 global $wgEnablePageTranslation;
105 $content = $wikiPage->getContent();
107 if ( !$content instanceof TextContent ) {
112 $text = $content->getText();
113 $title = $wikiPage->getTitle();
116 if ( !$handle->isValid() ) {
121 $revId = $revisionRecord->getId();
122 $mwServices = MediaWikiServices::getInstance();
124 $fuzzy = $handle->needsFuzzy( $text );
125 $parentId = $revisionRecord->getParentId();
126 if ( $editResult->isNullEdit() || $parentId == 0 ) {
128 $wasFuzzy = $handle->isFuzzy();
133 $revTagStore = Services::getInstance()->getRevTagStore();
134 $wasFuzzy = $revTagStore->isRevIdFuzzy( $title->getArticleID(), $parentId );
136 if ( !$fuzzy && $wasFuzzy ) {
137 $title = $mwServices->getTitleFactory()->castFromPageIdentity( $wikiPage );
138 $user = $mwServices->getUserFactory()->newFromUserIdentity( $userIdentity );
140 if ( !$mwServices->getPermissionManager()->userCan(
'unfuzzy', $user, $title ) ) {
143 } elseif ( $editResult->isNullEdit() ) {
144 $entry =
new ManualLogEntry(
'translationreview',
'unfuzzy' );
147 $dbw = $mwServices->getDBLoadBalancer()->getConnection( DB_PRIMARY );
148 $nullRevision = $mwServices->getRevisionStore()->newNullRevision(
151 CommentStoreComment::newUnsavedComment(
152 $summary !==
'' ? $summary : wfMessage(
"translate-unfuzzy-comment" )
157 if ( $nullRevision ) {
158 $nullRevision = $mwServices->getRevisionStore()->insertRevisionOn( $nullRevision, $dbw );
161 $revId = $nullRevision->getId();
162 $wikiPage->updateRevisionOn( $dbw, $nullRevision, $nullRevision->getParentId() );
163 $entry->setAssociatedRevId( $revId );
166 $entry->setPerformer( $userIdentity );
167 $entry->setTarget( $title );
168 $logId = $entry->insert();
169 $entry->publish( $logId );
172 self::updateFuzzyTag( $title, $revId, $fuzzy );
174 $group = $handle->getGroup();
176 if ( $handle->getCode() !== $group->getSourceLanguage() ) {
181 MessageGroupStats::clear( $handle );
187 DeferredUpdates::addCallableUpdate(
188 static function () use ( $handle ) {
192 $user = $mwServices->getUserFactory()
193 ->newFromId( $userIdentity->getId() );
196 Services::getInstance()->getHookRunner()
197 ->onTranslate_newTranslation( $handle, $revId, $text, $user );
200 TtmServer::onChange( $handle );
202 if ( $wgEnablePageTranslation && $handle->isPageTranslation() ) {
204 $minor = (bool)( $flags & EDIT_MINOR );
206 $summary, $minor, $flags, $handle );
254 if ( $user->isAllowed(
'bot' ) ) {
258 $group = $handle->getGroup();
260 $title = $handle->getTitle();
261 $name = $handle->getKey() .
'/' . $group->getSourceLanguage();
262 $definitionTitle = Title::makeTitleSafe( $title->getNamespace(), $name );
263 if ( !$definitionTitle || !$definitionTitle->exists() ) {
267 $definitionRevision = $definitionTitle->getLatestRevID();
268 $revTagStore = Services::getInstance()->getRevTagStore();
269 $revTagStore->setTransver( $title, $revision, $definitionRevision );