* Add 'editsection-brackets' message to allow localization (or removal) of the brackets in the "[edit]" link for sections.

* rebuildMessages.php no longer adds the ending ?>
* Rebuilt MessagesEn.php
* Added Linker::doEditSectionLink to remove shared code from editSectionLink and editSectionLinkForOther
This commit is contained in:
Aryeh Gregor 2007-07-02 15:46:55 +00:00
parent 7dc483c1ed
commit 43b05c00cb
5 changed files with 88 additions and 54 deletions

View file

@ -1060,34 +1060,66 @@ class Linker {
. "</script>\n";
}
/** @todo document */
/**
* Used to generate section edit links that point to "other" pages
* (sections that are really part of included pages).
*
* @param $title Title string.
* @param $section Integer: section number.
*/
public function editSectionLinkForOther( $title, $section ) {
global $wgContLang;
$title = Title::newFromText( $title );
$editurl = '&section='.$section;
$url = $this->makeKnownLinkObj( $title, wfMsg('editsection'), 'action=edit'.$editurl );
$result = null;
wfRunHooks( 'EditSectionLinkForOther', array( &$this, $title, $section, $url, &$result ) );
return is_null( $result )
? "<span class=\"editsection\">[{$url}]</span>"
: "<span class=\"editsection\">[{$result}]</span>";
return $this->doEditSectionLink( $title, $section, '', 'EditSectionLinkForOther' );
}
/**
* @param $title Title object.
* @param $nt Title object.
* @param $section Integer: section number.
* @param $hint Link String: title, or default if omitted or empty
*/
public function editSectionLink( $nt, $section, $hint='' ) {
public function editSectionLink( Title $nt, $section, $hint='' ) {
if( $hint != '' ) {
$hint = wfMsgHtml( 'editsectionhint', htmlspecialchars( $hint ) );
$hint = " title=\"$hint\"";
}
return $this->doEditSectionLink( $nt, $section, $hint, 'EditSectionLink' );
}
/**
* Implement editSectionLink and editSectionLinkForOther.
*
* @param $nt Title object
* @param $section Integer, section number
* @param $hint String, for HTML title attribute
* @param $hook String, name of hook to run
* @return String, HTML to use for edit link
*/
private function doEditSectionLink( Title $nt, $section, $hint, $hook ) {
global $wgContLang;
$editurl = '&section='.$section;
$hint = ( $hint=='' ) ? '' : ' title="' . wfMsgHtml( 'editsectionhint', htmlspecialchars( $hint ) ) . '"';
$url = $this->makeKnownLinkObj( $nt, wfMsg('editsection'), 'action=edit'.$editurl, '', '', '', $hint );
$url = $this->makeKnownLinkObj(
$nt,
wfMsg('editsection'),
'action=edit'.$editurl,
'', '', '', $hint
);
$result = null;
wfRunHooks( 'EditSectionLink', array( &$this, $nt, $section, $hint, $url, &$result ) );
return is_null( $result )
? "<span class=\"editsection\">[{$url}]</span>"
: "<span class=\"editsection\">[{$result}]</span>";
// The two hooks have slightly different interfaces . . .
if( $hook == 'EditSectionLink' ) {
wfRunHooks( $hook, array( &$this, $nt, $section, $hint, $url, &$result ) );
} elseif( $hook == 'EditSectionLinkForOther' ) {
wfRunHooks( $hook, array( &$this, $nt, $section, $url, &$result ) );
}
// For reverse compatibility, add the brackets *after* the hook is run,
// and even add them to hook-provided text.
if( is_null( $result ) ) {
$result = wfMsg( 'editsection-brackets', $url );
} else {
$result = wfMsg( 'editsection-brackets', $result );
}
return "<span class=\"editsection\">$result</span>";
}
/**

View file

@ -682,29 +682,30 @@ XHTML id names.
'versionrequired' => 'Version $1 of MediaWiki required',
'versionrequiredtext' => 'Version $1 of MediaWiki is required to use this page. See [[Special:Version|version page]].',
'ok' => 'OK',
'sitetitle' => '{{SITENAME}}', # don't translate or duplicate this message to other languages
'pagetitle' => '$1 - {{SITENAME}}',
'sitesubtitle' => '', # don't translate or duplicate this message to other languages
'retrievedfrom' => 'Retrieved from "$1"',
'youhavenewmessages' => 'You have $1 ($2).',
'newmessageslink' => 'new messages',
'newmessagesdifflink' => 'last change',
'editsection' => 'edit',
'editold' => 'edit',
'editsectionhint' => 'Edit section: $1',
'toc' => 'Contents',
'showtoc' => 'show',
'hidetoc' => 'hide',
'thisisdeleted' => 'View or restore $1?',
'viewdeleted' => 'View $1?',
'restorelink' => '{{PLURAL:$1|one deleted edit|$1 deleted edits}}',
'feedlinks' => 'Feed:',
'feed-invalid' => 'Invalid subscription feed type.',
'feed-atom' => 'Atom', # only translate this message to other languages if you have to change it
'feed-rss' => 'RSS', # only translate this message to other languages if you have to change it
'sitenotice' => '-', # the equivalent to wgSiteNotice; don't translate or duplicate this message to other languages
'anonnotice' => '-', # don't translate or duplicate this message to other languages
'ok' => 'OK',
'sitetitle' => '{{SITENAME}}', # don't translate or duplicate this message to other languages
'pagetitle' => '$1 - {{SITENAME}}',
'sitesubtitle' => '', # don't translate or duplicate this message to other languages
'retrievedfrom' => 'Retrieved from "$1"',
'youhavenewmessages' => 'You have $1 ($2).',
'newmessageslink' => 'new messages',
'newmessagesdifflink' => 'last change',
'editsection' => 'edit',
'editsection-brackets' => '[$1]', # only translate this message to other languages if you have to change it
'editold' => 'edit',
'editsectionhint' => 'Edit section: $1',
'toc' => 'Contents',
'showtoc' => 'show',
'hidetoc' => 'hide',
'thisisdeleted' => 'View or restore $1?',
'viewdeleted' => 'View $1?',
'restorelink' => '{{PLURAL:$1|one deleted edit|$1 deleted edits}}',
'feedlinks' => 'Feed:',
'feed-invalid' => 'Invalid subscription feed type.',
'feed-atom' => 'Atom', # only translate this message to other languages if you have to change it
'feed-rss' => 'RSS', # only translate this message to other languages if you have to change it
'sitenotice' => '-', # the equivalent to wgSiteNotice; don't translate or duplicate this message to other languages
'anonnotice' => '-', # don't translate or duplicate this message to other languages
# Short words for each namespace, by default used in the 'article' tab in monobook
'nstab-main' => 'Article',
@ -1266,18 +1267,18 @@ containing all of the search terms will appear in the result).",
'files' => 'Files',
# User rights
'userrights-lookup-user' => 'Manage user groups',
'userrights-user-editname' => 'Enter a username:',
'editusergroup' => 'Edit User Groups',
'userrights-editusergroup' => 'Edit user groups',
'saveusergroups' => 'Save User Groups',
'userrights-groupsmember' => 'Member of:',
'userrights-groupsavailable' => 'Available groups:',
'userrights-groupshelp' => 'Select groups you want the user to be removed from or added to.
'userrights-lookup-user' => 'Manage user groups',
'userrights-user-editname' => 'Enter a username:',
'editusergroup' => 'Edit User Groups',
'userrights-editusergroup' => 'Edit user groups',
'saveusergroups' => 'Save User Groups',
'userrights-groupsmember' => 'Member of:',
'userrights-groupsavailable' => 'Available groups:',
'userrights-groupshelp' => 'Select groups you want the user to be removed from or added to.
Unselected groups will not be changed. You can deselect a group with CTRL + Left Click',
'userrights-reason' => 'Reason for change:',
'userrights-available-none' => 'You may not alter group membership.',
'userrights-available-add' => 'You can add users to $1.',
'userrights-reason' => 'Reason for change:',
'userrights-available-none' => 'You may not alter group membership.',
'userrights-available-add' => 'You can add users to $1.',
'userrights-available-remove' => 'You can remove users from $1.',
# Groups

View file

@ -106,6 +106,7 @@ $wgIgnoredMessages = array(
$wgOptionalMessages = array(
'imgmultigotopost',
'linkprefix',
'editsection-brackets',
'feed-atom',
'feed-rss',
'sectionlink',

View file

@ -248,6 +248,7 @@ $wgMessageStructure = array(
'newmessageslink',
'newmessagesdifflink',
'editsection',
'editsection-brackets',
'editold',
'editsectionhint',
'toc',

View file

@ -29,13 +29,12 @@ function writeMessagesToFile( $messages, $code, $write, $listUnknown ) {
$contents = file_get_contents( $filename );
if ( strpos( $contents, '$messages' ) !== false ) {
$contents = explode( '$messages', $contents );
if ( $messagesText . "\n?>\n" == '$messages' . $contents[1] ) {
echo "Generated messages for language $code. Same to the current file.\n";
if ( $messagesText == '$messages' . $contents[1] ) {
echo "Generated messages for language $code. Same as the current file.\n";
} else {
if ( $write ) {
$new = $contents[0];
$new .= $messagesText;
$new .= "\n?>\n";
file_put_contents( $filename, $new );
echo "Generated and wrote messages for language $code.\n";
} else {