Enable localization of special page.

- Improved: Special Page can now be translated using messages.
This commit is contained in:
Daniel Kraus
2017-09-03 14:24:28 +02:00
parent 34715f9dc8
commit 2f76224ac0
5 changed files with 37 additions and 60 deletions

View File

@ -1,6 +1,11 @@
{
"linktitles": "LinkTitles",
"linktitles": "LinkTitles",
"linktitles-desc": "Fügt beim Speichern von Seiten automatisch Querverweise zu vorhandenen Seiten ein.",
"right-linktitles-batch": "LinkTitles-Stapelverarbeitung ausführen",
"action-linktitles-batch": "LinkTitles-Stapelverarbeitung auszuführen"
"linktitles-special-info": "LinkTitles-Erweiterung: $1\n== Stapelverarbeitung ==\nKlicken Sie auf den Button, um die Stapelverarbeitung zu beginnen. Die Erweiterung wird nacheinander alle Seiten Ihres Wikis mit automatischen Links versehen. Um zu verhindern, daß der Server bei der Ausführung blockiert wird, wird diese Seite sich wiederholt selbst aufrufen. Um die Stapelverarbeitung abzubrechen, schließen Sie einfach diese Seite.",
"linktitles-special-progress": "== Verarbeite die Seiten... ==\nDie [$1 LinkTitles-Erweiterung] verarbeitet gerade alle Seiten Ihres Wikis.\n=== Aktuelle Seite: $2 ===",
"linktitles-special-page-count": "Seite $1 von $2.\n",
"linktitles-special-cancel-notice": "=== Um abzubrechen, schließen Sie diese Seite, oder klicken Sie den 'Stopp'-Knopf in Ihrem Browser ===\n[[Special:LinkTitles|Zu Special:LinkTitles zurückkehren.]]",
"linktitles-special-completed-info": "== Stapelverarbeitung abgeschlossen! ==\n{| class=\"wikitable\"\n|-\n| Anzahl der verarbeiteten Seiten: || $1\n|-\n| Verarbeitungsintervall [s]: || $2\n|-\n| Reloads: || $3\n|-\n| Seiten pro Reload: || $4\n|}",
"right-linktitles-batch": "LinkTitles-Stapelverarbeitung ausführen",
"action-linktitles-batch": "LinkTitles-Stapelverarbeitung auszuführen"
}

View File

@ -1,6 +1,11 @@
{
"linktitles": "LinkTitles",
"linktitles": "LinkTitles",
"linktitles-desc": "Automatically adds links to existing pages whenever a page is saved.",
"right-linktitles-batch": "Perform a LinkTitles batch operation",
"action-linktitles-batch": "perform a LinkTitles batch operation"
"linktitles-special-info": "LinkTitles extension: $1\n== Batch Linking ==\nYou can start a batch linking process by clicking on the button below. This will go through every page in the normal namespace of your Wiki and insert links automatically. This page will repeatedly reload itself, in order to prevent blocking the server. To interrupt the process, simply close this page.",
"linktitles-special-progress": "== Processing pages... ==\nThe [$1 LinkTitles] extension is currently going through every page of your wiki, adding links to existing pages as appropriate.\n=== Current page: $2 ===",
"linktitles-special-page-count": "Page $1 of $2.\n",
"linktitles-special-cancel-notice": "=== To abort, close this page, or hit the 'Stop' button in your browser ===\n[[Special:LinkTitles|Return to Special:LinkTitles.]]",
"linktitles-special-completed-info": "== Batch processing completed! ==\n{| class=\"wikitable\"\n|-\n| total number of pages: || $1\n|-\n| timeout setting [s]: || $2\n|-\n| webpage reloads: || $3\n|-\n| pages scanned per reload interval: || $4\n|}",
"right-linktitles-batch": "Perform a LinkTitles batch operation",
"action-linktitles-batch": "perform a LinkTitles batch operation"
}

View File

@ -1,6 +1,11 @@
{
"linktitles": "Title of the LinkTitles extension; also used for the special page.",
"linktitles": "Name of the LinkTitles extension; also used for the special page.",
"linktitles-desc": "Description of the LinkTitles extension.",
"right-linktitles-batch": "Describes the right to perform a LinkTitles batch operation.",
"action-linktitles-batch": "Describes the action of performing a LinkTitles batch operation."
"linktitles-special-info": "Descriptive text that appears on the Special:LinkTitles page.",
"linktitles-special-progress": "Text that is shown on the Special:LinkTitles page while batch processing is executing.",
"linktitles-special-page-count": "Number of pages.",
"linktitles-special-cancel-notice": "Informs the user how to cancel the LinkTitles batch processing.",
"linktitles-special-completed-info": "Text and statistics table that appear when batch processing has completed.",
"right-linktitles-batch": "Describes the right to perform a LinkTitles batch operation.",
"action-linktitles-batch": "Describes the action of performing a LinkTitles batch operation."
}

View File

@ -27,6 +27,7 @@ namespace LinkTitles;
* Provides event handlers and entry points for the extension.
*/
class Extension {
const URL = 'https://github.com/bovender/LinkTitles';
/**
* Event handler for the PageContentSave hook.

View File

@ -175,21 +175,8 @@ class Special extends \SpecialPage {
* and a form and button to start linking.
*/
private function buildInfoPage( &$request, &$output ) {
$output->addWikiText( $this->msg( 'linktitles-special-info', Extension::URL ) );
$url = $request->getRequestURL();
// TODO: Put the page contents in messages in the i18n file.
$output->addWikiText(
<<<EOF
LinkTitles extension: https://github.com/bovender/LinkTitles
== Batch Linking ==
You can start a batch linking process by clicking on the button below.
This will go through every page in the normal namespace of your Wiki and
insert links automatically. This page will repeatedly reload itself, in
order to prevent blocking the server. To interrupt the process, simply
close this page.
EOF
);
$output->addHTML(
<<<EOF
<form method="post" action="${url}">
@ -211,34 +198,18 @@ EOF
$progress = $index / $end * 100;
$percent = sprintf("%01.1f", $progress);
$output->addWikiText(
$output->addWikiText( $this->msg( 'linktitles-special-progress', Extension::URL, $curTitle ) );
$pageInfo = $this->msg( 'linktitles-page-count', $index, $end );
$output->addWikiText( 'linktitles-special-page-count', $index, $end );
$output->addHTML( // TODO: do not use the style attribute (to make it work with CSP-enabled sites)
<<<EOF
== Processing pages... ==
The [https://github.com/bovender/LinkTitles LinkTitles]
extension is currently going through every page of your wiki, adding links to
existing pages as appropriate.
=== Current page: $curTitle ===
EOF
);
$output->addHTML(
<<<EOF
<p>Page ${index} of ${end}.</p>
<div style="width:100%; padding:2px; border:1px solid #000; position: relative;
margin-bottom:16px;">
<span style="position: absolute; left: 50%; font-weight:bold; color:#555;">
${percent}%
</span>
<div style="width:100%; padding:2px; border:1px solid #000; position: relative; margin-bottom:16px;">
<span style="position: absolute; left: 50%; font-weight:bold; color:#555;">${percent}%</span>
<div style="width:${progress}%; background-color:#bbb; height:20px; margin:0;"></div>
</div>
EOF
);
$output->addWikiText(
<<<EOF
=== To abort, close this page, or hit the 'Stop' button in your browser ===
[[Special:LinkTitles|Return to Special:LinkTitles.]]
EOF
);
$output->addWikiText( $this->msg( 'linktitles-special-cancel-notice' ) );
}
/**
@ -276,20 +247,10 @@ EOF
private function addCompletedInfo( &$output, $start, $end, $reloads ) {
$pagesPerReload = sprintf('%0.1f', $end / $reloads);
$output->addWikiText(
<<<EOF
== Batch processing completed! ==
{| class="wikitable"
|-
| total number of pages: || ${end}
|-
| timeout setting [s]: || {$config->specialPageReloadAfter}
|-
| webpage reloads: || ${reloads}
|-
| pages scanned per reload interval: || ${pagesPerReload}
|}
EOF
);
$this->msg( 'linktitltes-special-completed-info', $end,
$config->specialPageReloadAfter, $reloads, $pagesPerReload
)
);
}
/**