Add direct links to translation interface on Special:AllMessages
authorFederico Leva <federicoleva@tiscali.it>
Wed, 6 Nov 2013 23:08:02 +0000 (00:08 +0100)
committerReedy <reedy@wikimedia.org>
Sat, 25 Jan 2014 04:24:27 +0000 (04:24 +0000)
The local Special:AllMessages page is the first and most friendly place
where average users will look for the message and try to translate it:
when they find it, add a link to translatewiki.net so that they can start
translating without searching for it from scratch.

Special:SearchTranslations is the only target usable for this: the solr
search is smart enough to present the most relevant results first and the
translation interface is directly available in place.
On the bright side, similar messages popping up from other projects or areas
of the code will provide suggestions and help find other occurrences of
translations which can similarly be improved.

More specifically, we are using a combined language, key and text search:
* the English text is the only thing guaranteed to exist, if the message is
  available, though quoting it can give some false negatives and not quoting
  it would give it too much weight if it's long;
* the key can be used thanks to the feature revealed by Niklas Laxström in
  comments to this patch: it is simpler to handle but allows only exact matches
  and can be wrong if TWN adds a prefix for the extension, so it can't be used
  alone, but in the best case it's what we're looking for;
* the language makes sense in combination with the key match.
We boost key and language to get the current translation of the message where
possible; if it's not, the first result will usually be English text.
https://wiki.apache.org/solr/SolrQuerySyntax
https://lucene.apache.org/core/2_9_4/queryparsersyntax.html

From the initial search, the user can further refine its search and navigate
the interface to find the message(s) and editor where to add or edit the
translation.

Change-Id: I8de3faba829c50cdc0f2d09726f738c585792e00

includes/specials/SpecialAllmessages.php
languages/messages/MessagesEn.php
languages/messages/MessagesQqq.php
maintenance/language/messages.inc

index 35d6a0c..71bb27a 100644 (file)
@@ -345,6 +345,17 @@ class AllmessagesTablePager extends TablePager {
                        case 'am_title' :
                                $title = Title::makeTitle( NS_MEDIAWIKI, $value . $this->suffix );
                                $talk = Title::makeTitle( NS_MEDIAWIKI_TALK, $value . $this->suffix );
+                               $translation = Linker::makeExternalLink(
+                                       'https://translatewiki.net/w/i.php?' . wfArrayToCgi( array(
+                                               'title' => 'Special:SearchTranslations',
+                                               'group' => 'mediawiki',
+                                               'grouppath' => 'mediawiki',
+                                               'query' => 'language:' . $this->getLanguage()->getCode() . '^25 ' .
+                                                       'messageid:"MediaWiki:' . $value . '"^10 "' .
+                                                       $this->msg ( $value )->inLanguage ( 'en' )->plain() . '"'
+                                       ) ),
+                                       $this->msg( 'allmessages-filter-translate' )->text()
+                               );
 
                                if ( $this->mCurrentRow->am_customised ) {
                                        $title = Linker::linkKnown( $title, $this->getLanguage()->lcfirst( $value ) );
@@ -369,7 +380,10 @@ class AllmessagesTablePager extends TablePager {
                                        );
                                }
 
-                               return $title . ' ' . $this->msg( 'parentheses' )->rawParams( $talk )->escaped();
+                               return $title . ' '
+                               . $this->msg( 'parentheses' )->rawParams( $talk )->escaped()
+                               . ' '
+                               . $this->msg( 'parentheses' )->rawParams( $translation )->escaped();
 
                        case 'am_default' :
                        case 'am_actual' :
index 21f73cc..300792a 100644 (file)
@@ -3557,6 +3557,7 @@ Please visit [https://www.mediawiki.org/wiki/Localisation MediaWiki Localisation
 'allmessages-prefix'            => 'Filter by prefix:',
 'allmessages-language'          => 'Language:',
 'allmessages-filter-submit'     => 'Go',
+'allmessages-filter-translate'  => 'Translate',
 
 # Thumbnails
 'thumbnail-more'           => 'Enlarge',
index 746daee..ebb470f 100644 (file)
@@ -7190,6 +7190,7 @@ See also:
 'allmessages-filter-submit' => 'Used on [[Special:Allmessages]].
 
 {{Identical|Go}}',
+'allmessages-filter-translate' => 'Used on [[Special:Allmessages]]. Label for a link to translatewiki.net for a message to translate.',
 
 # Thumbnails
 'thumbnail-more' => '[[Image:Yes.png|thumb|This:]]
index ea45ee6..d698552 100644 (file)
@@ -2472,6 +2472,7 @@ $wgMessageStructure = array(
                'allmessages-prefix',
                'allmessages-language',
                'allmessages-filter-submit',
+               'allmessages-filter-translate',
        ),
        'thumbnails' => array(
                'thumbnail-more',