Translate extension for MediaWiki
 
Loading...
Searching...
No Matches
MediaWiki\Extension\Translate\PageTranslation\TranslatablePageMarker Class Reference

Service to mark/unmark pages from translation and perform related validations. More...

Public Member Functions

 __construct (IConnectionProvider $dbProvider, JobQueueGroup $jobQueueGroup, LinkRenderer $linkRenderer, MessageGroups $messageGroups, MessageIndex $messageIndex, TitleFormatter $titleFormatter, TitleParser $titleParser, TranslatablePageParser $translatablePageParser, TranslatablePageStore $translatablePageStore, TranslatablePageStateStore $translatablePageStateStore, TranslationUnitStoreFactory $translationUnitStoreFactory, MessageGroupMetadata $messageGroupMetadata, WikiPageFactory $wikiPageFactory, TranslatablePageView $translatablePageView, MessageGroupSubscription $messageGroupSubscription, FormatterFactory $formatterFactory, HookRunner $hookRunner,)
 
 unmarkPage (TranslatablePage $page, User $user, MessageLocalizer $localizer, bool $removeMarkup)
 Remove a page from translation.
 
 getMarkOperation (PageRecord $page, ?int $revision, ?bool $translateTitle)
 Parse the given page and create a new MarkPageOperation with the page and the given revision if the revision is latest and that latest revision is ready to be marked.
 
 markForTranslation (TranslatablePageMarkOperation $operation, TranslatablePageSettings $pageSettings, MessageLocalizer $localizer, User $user)
 This function does the heavy duty of marking a page.
 
 sendNotifications (array $sections, WikiPageMessageGroup $group, string $groupId, bool $isFirstMark)
 

Public Attributes

const LATEST_SYNTAX_VERSION = '2'
 
const DEFAULT_SYNTAX_VERSION = '1'
 

Detailed Description

Service to mark/unmark pages from translation and perform related validations.

Since
2023.10

Definition at line 43 of file TranslatablePageMarker.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Extension\Translate\PageTranslation\TranslatablePageMarker::__construct ( IConnectionProvider $dbProvider,
JobQueueGroup $jobQueueGroup,
LinkRenderer $linkRenderer,
MessageGroups $messageGroups,
MessageIndex $messageIndex,
TitleFormatter $titleFormatter,
TitleParser $titleParser,
TranslatablePageParser $translatablePageParser,
TranslatablePageStore $translatablePageStore,
TranslatablePageStateStore $translatablePageStateStore,
TranslationUnitStoreFactory $translationUnitStoreFactory,
MessageGroupMetadata $messageGroupMetadata,
WikiPageFactory $wikiPageFactory,
TranslatablePageView $translatablePageView,
MessageGroupSubscription $messageGroupSubscription,
FormatterFactory $formatterFactory,
HookRunner $hookRunner )

Definition at line 65 of file TranslatablePageMarker.php.

Member Function Documentation

◆ getMarkOperation()

MediaWiki\Extension\Translate\PageTranslation\TranslatablePageMarker::getMarkOperation ( PageRecord $page,
?int $revision,
?bool $translateTitle )

Parse the given page and create a new MarkPageOperation with the page and the given revision if the revision is latest and that latest revision is ready to be marked.

Parameters
PageRecord$page
?int$revisionRevision to use, or null to use the latest revision of the given page (i.e. not do the latest revision check)
?bool$translateTitle
  • true: The user explicitly said they wanted to translate the title
  • false: The user explicitly said they didn't want to translate the title
  • null: The user didn't say anything about whether to translate the title or not
Exceptions
TranslatablePageMarkExceptionIf the revision was provided and was non-latest, or if the latest revision of the page is not ready to be marked
ParsingFailureIf the parse fails

Definition at line 158 of file TranslatablePageMarker.php.

◆ markForTranslation()

MediaWiki\Extension\Translate\PageTranslation\TranslatablePageMarker::markForTranslation ( TranslatablePageMarkOperation $operation,
TranslatablePageSettings $pageSettings,
MessageLocalizer $localizer,
User $user )

This function does the heavy duty of marking a page.

  • Updates the source page with section markers.
  • Updates translate_sections table
  • Updates revtags table
  • Sets up renderjobs to update the translation pages
  • Invalidates caches
  • Adds interim cache for MessageIndex
Parameters
TranslatablePageMarkOperation$operation
TranslatablePageSettings$pageSettingsContains information about priority languages, units that should not be fuzzed, whether title should be translated and other translatable page settings
MessageLocalizer$localizer
User$userUser performing the action. Checking user permissions is the caller’s responsibility
Exceptions
TranslatablePageMarkExceptionIf marking the page for translation failed (because some extension hook interfered with the process)
Returns
int The number of translation units actually used

Definition at line 319 of file TranslatablePageMarker.php.

◆ sendNotifications()

MediaWiki\Extension\Translate\PageTranslation\TranslatablePageMarker::sendNotifications ( array $sections,
WikiPageMessageGroup $group,
string $groupId,
bool $isFirstMark )
Parameters
TranslationUnit[]$sections
WikiPageMessageGroup$group
string$groupId
bool$isFirstMark

Definition at line 602 of file TranslatablePageMarker.php.

◆ unmarkPage()

MediaWiki\Extension\Translate\PageTranslation\TranslatablePageMarker::unmarkPage ( TranslatablePage $page,
User $user,
MessageLocalizer $localizer,
bool $removeMarkup )

Remove a page from translation.

Parameters
TranslatablePage$pageThe page to remove from translation
User$userThe user performing the action
MessageLocalizer$localizer
bool$removeMarkupWhether to remove markup from the translation page
Exceptions
TranslatablePageMarkExceptionIf removing the markup from the translation page fails

Definition at line 111 of file TranslatablePageMarker.php.

Member Data Documentation

◆ DEFAULT_SYNTAX_VERSION

const MediaWiki\Extension\Translate\PageTranslation\TranslatablePageMarker::DEFAULT_SYNTAX_VERSION = '1'

Definition at line 45 of file TranslatablePageMarker.php.

◆ LATEST_SYNTAX_VERSION

const MediaWiki\Extension\Translate\PageTranslation\TranslatablePageMarker::LATEST_SYNTAX_VERSION = '2'

Definition at line 44 of file TranslatablePageMarker.php.


The documentation for this class was generated from the following file: