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

Hooks for page translation. More...

Static Public Member Functions

static renderTagPage ( $wikitextParser, &$text, $state)
 Hook: ParserBeforeInternalParse.
 
static preprocessTagPage ( $wikitextParser, &$text, $state)
 Hook: ParserBeforePreprocess.
 
static onParserOutputPostCacheTransform (ParserOutput $out, &$text, array &$options)
 Hook: ParserOutputPostCacheTransform.
 
static fetchTranslatableTemplateAndTitle (?LinkTarget $contextLink, ?LinkTarget $templateLink, bool &$skip, ?RevisionRecord &$revRecord)
 This sets &$revRecord to the revision of transcluded page translation if it exists, or sets it to the source language if the page translation does not exist.
 
static onPageContentLanguage (Title $title, &$pageLang)
 Set the right page content language for translated pages ("Page/xx").
 
static onTitleGetEditNotices (Title $title, int $oldid, array &$notices)
 Display an edit notice for translatable source pages if it's enabled Hook: TitleGetEditNotices.
 
static onBeforePageDisplay (OutputPage $out, Skin $skin)
 Hook: BeforePageDisplay.
 
static onVisualEditorBeforeEditor (OutputPage $out, Skin $skin)
 Hook: onVisualEditorBeforeEditor.
 
static onSectionSave (WikiPage $wikiPage, User $user, TextContent $content, $summary, $minor, $flags, MessageHandle $handle)
 This is triggered after an edit to translation unit page.
 
static onGetMagicVariableIDs (&$variableIDs)
 Hook: GetMagicVariableIDs.
 
static onParserGetVariableValueSwitch (Parser $parser, array &$variableCache, string $magicWordId, ?string &$ret, PPFrame $frame)
 Hook: ParserGetVariableValueSwitch.
 
static languages ( $data, $params, $parser)
 
static addLanguageLinks (Title $title, array &$languageLinks)
 Hooks: LanguageLinks.
 
static formatLanguageLink (array &$link, Title $linkTitle, Title $pageTitle, OutputPage $out)
 Hooks: SkinTemplateGetLanguageLink.
 
static tpSyntaxCheckForEditContent ( $context, $content, $status, $summary)
 Display nice error when editing content.
 
static tpSyntaxCheck (RenderedRevision $renderedRevision, UserIdentity $user, CommentStoreComment $summary, $flags, Status $hookStatus)
 When attempting to save, last resort.
 
static addTranstagAfterSave (WikiPage $wikiPage, UserIdentity $userIdentity, string $summary, int $flags, RevisionRecord $revisionRecord, EditResult $editResult)
 Hook: PageSaveComplete.
 
static updateTranstagOnNullRevisions (RevisionRecord $rev)
 Page moving and page protection (and possibly other things) creates null revisions.
 
static onGetUserPermissionsErrorsExpensive (Title $title, User $user, $action, &$result)
 Prevent creation of orphan translation units in Translations namespace.
 
static preventDirectEditing (Title $title, User $user, $action, &$result)
 Prevent editing of translation pages directly.
 
static disableDelete ( $article, $out, &$reason)
 Redirects the delete action to our own for translatable pages.
 
static translatablePageHeader ( $article, &$outputDone, &$pcache)
 Hook: ArticleViewHeader.
 
static replaceMovePage (&$list)
 Hook: SpecialPage_initList.
 
static lockedPagesCheck (Title $title, User $user, $action, &$result)
 Hook: getUserPermissionsErrorsExpensive.
 
static replaceSubtitle (&$subpages, ?Skin $skin, OutputPage $out)
 Hook: SkinSubPageSubtitle.
 
static translateTab (Skin $skin, array &$tabs)
 Converts the edit tab (if exists) for translation pages to translate tab.
 
static onMovePageTranslationUnits (LinkTarget $oldLinkTarget, LinkTarget $newLinkTarget, UserIdentity $userIdentity, int $oldid, int $newid, string $reason, RevisionRecord $revisionRecord)
 Hook to update source and destination translation pages on moving translation units Hook: PageMoveComplete.
 
static onDeleteTranslationUnit (WikiPage $unit, User $user, $reason, $id, $content, $logEntry)
 Hook to update translation page on deleting a translation unit Hook: ArticleDeleteComplete.
 
static onReplaceTextFilterPageTitlesForEdit (array &$titles)
 Removes translation pages from the list of page titles to be edited Hook: ReplaceTextFilterPageTitlesForEdit.
 
static onReplaceTextFilterPageTitlesForRename (array &$titles)
 Removes translatable and translation pages from the list of titles to be renamed Hook: ReplaceTextFilterPageTitlesForRename.
 
static getSpecialManageMessageGroupSubscriptionsLink (Context $context, Config $config)
 
static onLinksUpdateComplete (LinksUpdate $linksUpdate)
 Create any redlinked categories marked for translation Hook: LinksUpdateComplete.
 

Static Public Attributes

static $allowTargetEdit = false
 
static bool $isDeleteTranslatableBundleJobRunning = false
 State flag used by DeleteTranslatableBundleJob for performance optimizations.
 
static $renderingContext = false
 

Detailed Description

Hooks for page translation.

Author
Niklas Laxström @license GPL-2.0-or-later

Definition at line 63 of file Hooks.php.

Member Function Documentation

◆ addLanguageLinks()

static MediaWiki\Extension\Translate\PageTranslation\Hooks::addLanguageLinks ( Title $title,
array & $languageLinks )
static

Hooks: LanguageLinks.

Parameters
Title$titleTitle of the page for which links are needed.
array&$languageLinksList of language links to modify.

Definition at line 692 of file Hooks.php.

◆ addTranstagAfterSave()

static MediaWiki\Extension\Translate\PageTranslation\Hooks::addTranstagAfterSave ( WikiPage $wikiPage,
UserIdentity $userIdentity,
string $summary,
int $flags,
RevisionRecord $revisionRecord,
EditResult $editResult )
static

Hook: PageSaveComplete.

Parameters
WikiPage$wikiPage
UserIdentity$userIdentity
string$summary
int$flags
RevisionRecord$revisionRecord
EditResult$editResult

Definition at line 884 of file Hooks.php.

◆ disableDelete()

static MediaWiki\Extension\Translate\PageTranslation\Hooks::disableDelete ( $article,
$out,
& $reason )
static

Redirects the delete action to our own for translatable pages.

Hook: ArticleConfirmDelete

Parameters
Article$article
OutputPage$out
string&$reason
Returns
bool

Definition at line 1201 of file Hooks.php.

◆ fetchTranslatableTemplateAndTitle()

static MediaWiki\Extension\Translate\PageTranslation\Hooks::fetchTranslatableTemplateAndTitle ( ?LinkTarget $contextLink,
?LinkTarget $templateLink,
bool & $skip,
?RevisionRecord & $revRecord )
static

This sets &$revRecord to the revision of transcluded page translation if it exists, or sets it to the source language if the page translation does not exist.

The page translation is chosen based on language of the source page.

Hook: BeforeParserFetchTemplateRevisionRecord

Parameters
LinkTarget | null$contextLink
LinkTarget | null$templateLink
bool&$skip
RevisionRecord | null&$revRecord

Definition at line 212 of file Hooks.php.

◆ formatLanguageLink()

static MediaWiki\Extension\Translate\PageTranslation\Hooks::formatLanguageLink ( array & $link,
Title $linkTitle,
Title $pageTitle,
OutputPage $out )
static

Hooks: SkinTemplateGetLanguageLink.

Parameters
array&$link
Title$linkTitle
Title$pageTitle
OutputPage$out

Definition at line 772 of file Hooks.php.

◆ getSpecialManageMessageGroupSubscriptionsLink()

static MediaWiki\Extension\Translate\PageTranslation\Hooks::getSpecialManageMessageGroupSubscriptionsLink ( Context $context,
Config $config )
static

Definition at line 1769 of file Hooks.php.

◆ languages()

static MediaWiki\Extension\Translate\PageTranslation\Hooks::languages ( $data,
$params,
$parser )
static
Parameters
string$data
array$params
Parser$parser
Returns
string

Definition at line 485 of file Hooks.php.

◆ lockedPagesCheck()

static MediaWiki\Extension\Translate\PageTranslation\Hooks::lockedPagesCheck ( Title $title,
User $user,
$action,
& $result )
static

Hook: getUserPermissionsErrorsExpensive.

Parameters
Title$title
User$user
string$action
mixed&$result
Returns
bool

Definition at line 1458 of file Hooks.php.

◆ onBeforePageDisplay()

static MediaWiki\Extension\Translate\PageTranslation\Hooks::onBeforePageDisplay ( OutputPage $out,
Skin $skin )
static

Hook: BeforePageDisplay.

Parameters
OutputPage$out
Skin$skin

Definition at line 335 of file Hooks.php.

◆ onDeleteTranslationUnit()

static MediaWiki\Extension\Translate\PageTranslation\Hooks::onDeleteTranslationUnit ( WikiPage $unit,
User $user,
$reason,
$id,
$content,
$logEntry )
static

Hook to update translation page on deleting a translation unit Hook: ArticleDeleteComplete.

Parameters
WikiPage$unit
User$user
string$reason
int$id
Content$content
ManualLogEntry$logEntry

Definition at line 1670 of file Hooks.php.

◆ onGetMagicVariableIDs()

static MediaWiki\Extension\Translate\PageTranslation\Hooks::onGetMagicVariableIDs ( & $variableIDs)
static

Hook: GetMagicVariableIDs.

Parameters
string[]&$variableIDs

Definition at line 456 of file Hooks.php.

◆ onGetUserPermissionsErrorsExpensive()

static MediaWiki\Extension\Translate\PageTranslation\Hooks::onGetUserPermissionsErrorsExpensive ( Title $title,
User $user,
$action,
& $result )
static

Prevent creation of orphan translation units in Translations namespace.

Prevent editing of translation units relating to the source language (these should only be touched by FuzzyBot) Prevent editing of translation units relating to a page if you're blocked from that page Prevent editing of translation units relating to a language that the page isn't allowed to be translated into. Hook: getUserPermissionsErrorsExpensive

Parameters
Title$title
User$user
string$action
mixed&$result
Returns
bool

Definition at line 968 of file Hooks.php.

◆ onLinksUpdateComplete()

static MediaWiki\Extension\Translate\PageTranslation\Hooks::onLinksUpdateComplete ( LinksUpdate $linksUpdate)
static

Create any redlinked categories marked for translation Hook: LinksUpdateComplete.

Definition at line 1782 of file Hooks.php.

◆ onMovePageTranslationUnits()

static MediaWiki\Extension\Translate\PageTranslation\Hooks::onMovePageTranslationUnits ( LinkTarget $oldLinkTarget,
LinkTarget $newLinkTarget,
UserIdentity $userIdentity,
int $oldid,
int $newid,
string $reason,
RevisionRecord $revisionRecord )
static

Hook to update source and destination translation pages on moving translation units Hook: PageMoveComplete.

Parameters
LinkTarget$oldLinkTarget
LinkTarget$newLinkTarget
UserIdentity$userIdentity
int$oldid
int$newid
string$reason
RevisionRecord$revisionRecord

Definition at line 1610 of file Hooks.php.

◆ onPageContentLanguage()

static MediaWiki\Extension\Translate\PageTranslation\Hooks::onPageContentLanguage ( Title $title,
& $pageLang )
static

Set the right page content language for translated pages ("Page/xx").

Hook: PageContentLanguage

Parameters
Title$title
Language | StubUserLang | string&$pageLang

Definition at line 288 of file Hooks.php.

◆ onParserGetVariableValueSwitch()

static MediaWiki\Extension\Translate\PageTranslation\Hooks::onParserGetVariableValueSwitch ( Parser $parser,
array & $variableCache,
string $magicWordId,
?string & $ret,
PPFrame $frame )
static

Hook: ParserGetVariableValueSwitch.

Definition at line 463 of file Hooks.php.

◆ onParserOutputPostCacheTransform()

static MediaWiki\Extension\Translate\PageTranslation\Hooks::onParserOutputPostCacheTransform ( ParserOutput $out,
& $text,
array & $options )
static

Hook: ParserOutputPostCacheTransform.

Parameters
ParserOutput$out
string&$text
array&$options

Definition at line 191 of file Hooks.php.

◆ onReplaceTextFilterPageTitlesForEdit()

static MediaWiki\Extension\Translate\PageTranslation\Hooks::onReplaceTextFilterPageTitlesForEdit ( array & $titles)
static

Removes translation pages from the list of page titles to be edited Hook: ReplaceTextFilterPageTitlesForEdit.

Definition at line 1744 of file Hooks.php.

◆ onReplaceTextFilterPageTitlesForRename()

static MediaWiki\Extension\Translate\PageTranslation\Hooks::onReplaceTextFilterPageTitlesForRename ( array & $titles)
static

Removes translatable and translation pages from the list of titles to be renamed Hook: ReplaceTextFilterPageTitlesForRename.

Definition at line 1757 of file Hooks.php.

◆ onSectionSave()

static MediaWiki\Extension\Translate\PageTranslation\Hooks::onSectionSave ( WikiPage $wikiPage,
User $user,
TextContent $content,
$summary,
$minor,
$flags,
MessageHandle $handle )
static

This is triggered after an edit to translation unit page.

Parameters
WikiPage$wikiPage
User$user
TextContent$content
string$summary
bool$minor
int$flags
MessageHandle$handle

Definition at line 378 of file Hooks.php.

◆ onTitleGetEditNotices()

static MediaWiki\Extension\Translate\PageTranslation\Hooks::onTitleGetEditNotices ( Title $title,
int $oldid,
array & $notices )
static

Display an edit notice for translatable source pages if it's enabled Hook: TitleGetEditNotices.

Parameters
Title$title
int$oldid
array&$notices

Definition at line 304 of file Hooks.php.

◆ onVisualEditorBeforeEditor()

static MediaWiki\Extension\Translate\PageTranslation\Hooks::onVisualEditorBeforeEditor ( OutputPage $out,
Skin $skin )
static

Hook: onVisualEditorBeforeEditor.

Parameters
OutputPage$out
Skin$skin
Returns
bool

Definition at line 364 of file Hooks.php.

◆ preprocessTagPage()

static MediaWiki\Extension\Translate\PageTranslation\Hooks::preprocessTagPage ( $wikitextParser,
& $text,
$state )
static

Hook: ParserBeforePreprocess.

Parameters
Parser$wikitextParser
string&$text
-taint$textescapes_htmlnoent
mixed$state

Definition at line 164 of file Hooks.php.

◆ preventDirectEditing()

static MediaWiki\Extension\Translate\PageTranslation\Hooks::preventDirectEditing ( Title $title,
User $user,
$action,
& $result )
static

Prevent editing of translation pages directly.

Hook: getUserPermissionsErrorsExpensive

Parameters
Title$title
User$user
string$action
bool&$result
Returns
bool

Definition at line 1142 of file Hooks.php.

◆ renderTagPage()

static MediaWiki\Extension\Translate\PageTranslation\Hooks::renderTagPage ( $wikitextParser,
& $text,
$state )
static

Hook: ParserBeforeInternalParse.

Parameters
Parser$wikitextParser
null | string&$text
-taint$textescapes_htmlnoent
mixed$state

Definition at line 81 of file Hooks.php.

◆ replaceMovePage()

static MediaWiki\Extension\Translate\PageTranslation\Hooks::replaceMovePage ( & $list)
static

Hook: SpecialPage_initList.

Parameters
array&$list

Definition at line 1427 of file Hooks.php.

◆ replaceSubtitle()

static MediaWiki\Extension\Translate\PageTranslation\Hooks::replaceSubtitle ( & $subpages,
?Skin $skin,
OutputPage $out )
static

Hook: SkinSubPageSubtitle.

Parameters
array&$subpages
?Skin$skin
OutputPage$out
Returns
bool

Definition at line 1481 of file Hooks.php.

◆ tpSyntaxCheck()

static MediaWiki\Extension\Translate\PageTranslation\Hooks::tpSyntaxCheck ( RenderedRevision $renderedRevision,
UserIdentity $user,
CommentStoreComment $summary,
$flags,
Status $hookStatus )
static

When attempting to save, last resort.

Edit page would only display edit conflict if there wasn't tpSyntaxCheckForEditPage. Hook: MultiContentSave

Parameters
RenderedRevision$renderedRevision
UserIdentity$user
CommentStoreComment$summary
int$flags
Status$hookStatus
Returns
bool

Definition at line 852 of file Hooks.php.

◆ tpSyntaxCheckForEditContent()

static MediaWiki\Extension\Translate\PageTranslation\Hooks::tpSyntaxCheckForEditContent ( $context,
$content,
$status,
$summary )
static

Display nice error when editing content.

Hook: EditFilterMergedContent

Parameters
IContextSource$context
Content$content
Status$status
string$summary
Returns
bool

Definition at line 802 of file Hooks.php.

◆ translatablePageHeader()

static MediaWiki\Extension\Translate\PageTranslation\Hooks::translatablePageHeader ( $article,
& $outputDone,
& $pcache )
static

Hook: ArticleViewHeader.

Parameters
Article$article
bool | ParserOutput | null&$outputDone
bool&$pcache

Definition at line 1223 of file Hooks.php.

◆ translateTab()

static MediaWiki\Extension\Translate\PageTranslation\Hooks::translateTab ( Skin $skin,
array & $tabs )
static

Converts the edit tab (if exists) for translation pages to translate tab.

Hook: SkinTemplateNavigation::Universal

Parameters
Skin$skin
array&$tabs

Definition at line 1551 of file Hooks.php.

◆ updateTranstagOnNullRevisions()

static MediaWiki\Extension\Translate\PageTranslation\Hooks::updateTranstagOnNullRevisions ( RevisionRecord $rev)
static

Page moving and page protection (and possibly other things) creates null revisions.

These revisions re-use the previous text already stored in the database. Those however do not trigger re-parsing of the page and thus the ready tag is not updated. This watches for new revisions, checks if they reuse existing text, checks whether the parent version is the latest version and has a ready tag. If that is the case, also adds a ready tag for the new revision (which is safe, because the text hasn't changed). The interface will say that there has been a change, but shows no change in the content. This lets the user to re-mark the translations of the page title as outdated (if enabled for translation). Hook: RevisionRecordInserted

Parameters
RevisionRecord$rev

Definition at line 929 of file Hooks.php.

Member Data Documentation

◆ $allowTargetEdit

MediaWiki\Extension\Translate\PageTranslation\Hooks::$allowTargetEdit = false
static

Definition at line 66 of file Hooks.php.

◆ $isDeleteTranslatableBundleJobRunning

bool MediaWiki\Extension\Translate\PageTranslation\Hooks::$isDeleteTranslatableBundleJobRunning = false
static

State flag used by DeleteTranslatableBundleJob for performance optimizations.

Definition at line 68 of file Hooks.php.

◆ $renderingContext

MediaWiki\Extension\Translate\PageTranslation\Hooks::$renderingContext = false
static

Definition at line 70 of file Hooks.php.


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