Reedy has uploaded a new change for review. https://gerrit.wikimedia.org/r/150805
Change subject: Allow localisation of site link text ...................................................................... Allow localisation of site link text This uses the same system message infrastructure as is used for the $wgExtraInterlanguageLinkPrefixes feature in core. It is fully backward compatible. Also adds a title attribute to each link, again using the same logic as is used in core for interlanguage links. Bug: 68359 Change-Id: Id6b1aac8e824859bfd6de3b4a8c7f020ce59579e --- M RelatedSites.class.php 1 file changed, 29 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/RelatedSites refs/changes/05/150805/1 diff --git a/RelatedSites.class.php b/RelatedSites.class.php index 60a2653..b16f3b8 100644 --- a/RelatedSites.class.php +++ b/RelatedSites.class.php @@ -78,9 +78,34 @@ $title = Title::newFromText( $site ); if ( $title ) { + // Use the same system message keys as the core $wgExtraInterlanguageLinkPrefixes feature + $linkTextMsg = wfMessage( 'interlanguage-link-' . $title->getInterwiki() ); + $linkText = $linkTextMsg->isDisabled() ? + ( Language::fetchLanguageName( $title->getInterwiki() ) ?: $site ) : + $linkTextMsg->text(); + + // This logic is essentially copied from core SkinTemplate#getLanguages + $linkTitle = null; + $linkTitleMsg = wfMessage( 'interlanguage-link-sitename-' . $title->getInterwiki() ); + if ( !$linkTitleMsg->isDisabled() ) { + if ( $title->getText() === '' ) { + $linkTitle = wfMessage( + 'interlanguage-link-title-nonlangonly', + $linkTitleMsg->text() + )->text(); + } else { + $linkTitle = wfMessage( + 'interlanguage-link-title-nonlang', + $title->getText(), + $linkTitleMsg->text() + )->text(); + } + } + $relatedSitesUrls[] = array( 'href' => $title->getFullURL(), - 'text' => Language::fetchLanguageName( $title->getInterwiki() ) ?: $site, + 'text' => $linkText, + 'title' => $linkTitle, 'class' => 'interwiki-' . $tmp[0] ); } @@ -148,6 +173,9 @@ foreach ( (array) $relatedSitesUrls as $url ) { $attributes = array(); $attributes['href'] = htmlspecialchars( $url['href'] ); + if ( !empty( $url['title'] ) ) { + $attributes['title'] = htmlspecialchars( $url['title'] ); + } if ( $url['text'] == $wgSitename ) { $attributes['rel'] = 'nofollow'; -- To view, visit https://gerrit.wikimedia.org/r/150805 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Id6b1aac8e824859bfd6de3b4a8c7f020ce59579e Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/RelatedSites Gerrit-Branch: wmf/1.24wmf15 Gerrit-Owner: Reedy <re...@wikimedia.org> Gerrit-Reviewer: TTO <at.li...@live.com.au> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits