From 0d7a30fa27ebaefb5d89693bbe658916b982c082 Mon Sep 17 00:00:00 2001 From: Pavel Selitskas Date: Thu, 29 Nov 2012 13:42:17 +0300 Subject: [PATCH] Mouseover explanations for interlanguage links in native language Adds a language name in User's language from CLDR to an interwiki 'title' attribute. Believed to be RTL-compilant. New message added: tooltip-iwiki, added to $preloadedMessages Bug: 5231 Change-Id: I3dcb00cdc28a10711b6703fa509b8b8d06e325a2 --- includes/SkinTemplate.php | 7 ++++++- languages/messages/MessagesEn.php | 2 ++ languages/messages/MessagesQqq.php | 3 +++ maintenance/language/messages.inc | 1 + 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/includes/SkinTemplate.php b/includes/SkinTemplate.php index ccfb3dbe8c..d968d79573 100644 --- a/includes/SkinTemplate.php +++ b/includes/SkinTemplate.php @@ -131,6 +131,7 @@ class SkinTemplate extends Skin { public function getLanguages() { global $wgHideInterlanguageLinks; $out = $this->getOutput(); + $userLang = $this->getLanguage(); # Language links $language_urls = array(); @@ -151,10 +152,14 @@ class SkinTemplate extends Skin { $ilLangName = $this->formatLanguageName( $ilLangName ); } + // CLDR extension or similar is required to localize the language name; + // otherwise we'll end up with the autonym again. + $ilLangLocalName = Language::fetchLanguageName( $ilInterwikiCode, $userLang->getCode() ); + $language_urls[] = array( 'href' => $languageLinkTitle->getFullURL(), 'text' => $ilLangName, - 'title' => $languageLinkTitle->getText(), + 'title' => wfMessage( 'tooltip-iwiki', $languageLinkTitle->getText(), $ilLangLocalName )->escaped(), 'class' => $class, 'lang' => wfBCP47( $ilInterwikiCode ), 'hreflang' => wfBCP47( $ilInterwikiCode ), diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index 225a6b2160..e4d06513c2 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -551,6 +551,7 @@ $preloadedMessages = array( 'editsectionhint', 'help', 'helppage', + 'tooltip-iwiki', 'jumpto', 'jumptonavigation', 'jumptosearch', @@ -972,6 +973,7 @@ See [[Special:Version|version page]].', 'red-link-title' => '$1 (page does not exist)', 'sort-descending' => 'Sort descending', 'sort-ascending' => 'Sort ascending', +'tooltip-iwiki' => '$1 – $2', # only translate this message to other languages if you have to change it # Short words for each namespace, by default used in the namespace tab in monobook 'nstab-main' => 'Page', diff --git a/languages/messages/MessagesQqq.php b/languages/messages/MessagesQqq.php index da14d70d0d..304d9d3aae 100644 --- a/languages/messages/MessagesQqq.php +++ b/languages/messages/MessagesQqq.php @@ -962,6 +962,9 @@ Parameters: * $1 - page title', 'sort-descending' => 'JavaScript message. Used by sortable table script.', 'sort-ascending' => 'JavaScript message. Used by sortable table script.', +'tooltip-iwiki' => 'Format of a sidebar interwiki link tooltip. Parameters: +* $1 - Page name in the target wiki +* $2 - Target wiki language autonym', # Short words for each namespace, by default used in the namespace tab in monobook 'nstab-main' => 'The name for the tab of the main namespace. Example: [[Example]] diff --git a/maintenance/language/messages.inc b/maintenance/language/messages.inc index 43be19538c..0e9cfef501 100644 --- a/maintenance/language/messages.inc +++ b/maintenance/language/messages.inc @@ -2726,6 +2726,7 @@ $wgMessageStructure = array( 'tooltip-undo', 'tooltip-preferences-save', 'tooltip-summary', + 'tooltip-iwiki', ), 'stylesheets' => array( 'common.css', -- 2.20.1