Amire80 has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/142967

Change subject: Insert links to source article and guideline in JS
......................................................................

Insert links to source article and guideline in JS

This changes the links from being inserted using message
parsing to explicit creating of <a> elements in jQuery.

This also makes sure that the source article link
points to what is configured as the source wiki
and the guidelines link points to the target wiki.

Followup to I4565f87afe614bdc7799096fb064caea0903f816

Change-Id: I84c55d3ddbe4c341c364201e3ff6f53ad2cfdf36
---
M Resources.php
M i18n/en.json
M i18n/qqq.json
M modules/source/ext.cx.source.js
M modules/tools/ext.cx.tools.instructions.js
5 files changed, 38 insertions(+), 26 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation 
refs/changes/67/142967/1

diff --git a/Resources.php b/Resources.php
index a07ec2c..2fe2caa 100644
--- a/Resources.php
+++ b/Resources.php
@@ -142,6 +142,7 @@
        'dependencies' => array(
                'ext.cx.tools.manager',
                'ext.cx.tools.card',
+               'mediawiki.Uri',
        ),
 ) + $resourcePaths;
 
diff --git a/i18n/en.json b/i18n/en.json
index 771388c..8d4263a 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -12,7 +12,7 @@
        "cx-desc": "A tool that allows editors to translate pages from one 
language to another with the help of machine translation and other translation 
tools",
        "cx-header-progressbar-text": "$1% translated",
        "cx-header-translation-center": "Translation center",
-       "cx-source-view-page": "[$1 view page]",
+       "cx-source-view-page": "view page",
        "cx-publish-page": "Page published at [$1 $2]",
        "cx-publish-page-error": "Error while saving page.",
        "cx-publish-button": "Publish translation",
@@ -35,7 +35,7 @@
        "cx-tools-instructions-text5": "Publish the translation",
        "cx-tools-instructions-text6": "When you are happy with the result, 
press \"{{int:cx-publish-button}}\".",
        "cx-tools-searchbox-text": "Search for a word",
-       "cx-tools-view-guidelines": "[$1 View translation guidelines]",
+       "cx-tools-view-guidelines": "View translation guidelines",
        "cx-tools-dictionary-title": "Definition",
        "cx-tools-link-title": "Link",
        "cx-tools-link-add": "Add link",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 3b72cf7..568f061 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -15,7 +15,7 @@
        "cx-desc": 
"{{desc|name=ContentTranslation|url=http://www.mediawiki.org/wiki/Extension:ContentTranslation}}";,
        "cx-header-progressbar-text": "Text to be shown with the progress bar 
in [[Special:ContentTranslation]]. $1 is translation progress in percentage.",
        "cx-header-translation-center": "Text for translation center title.",
-       "cx-source-view-page": "A link that points to the source page under the 
heading of the source article. The square brackets are wiki syntax that creates 
an external link.\n\nParameters:\n* $1 - a URL of the source article",
+       "cx-source-view-page": "A link that points to the source page under the 
heading of the source article.",
        "cx-publish-page": "Link of the page to be publish. Parameters:\n* $1 - 
URL\n* $2 - link text",
        "cx-publish-page-error": "Error message to display when page saving 
fails.",
        "cx-publish-button": "Publish button text in 
[[Special:ContentTranslation]].\n\nAlso used in 
{{msg-mw|Cx-tools-instructions-text6}}.",
@@ -38,7 +38,7 @@
        "cx-tools-instructions-text5": "Help text for the translation tools 
pane.\n\nFollowed by the body {{msg-mw|Cx-tools-instructions-text6}}.",
        "cx-tools-instructions-text6": "Help text for the translation tools 
pane.\n\nRefers to {{msg-mw|Cx-publish-button}}.\n\nPreceded by the heading 
{{msg-mw|Cx-tools-instructions-text5}}.",
        "cx-tools-searchbox-text": "Placeholder text for the searchbox on the 
translation tools column",
-       "cx-tools-view-guidelines": "Shown at the bottom of the instructions 
text. A hyperlink to the translation guidelines in the target language. The 
square brackets are wiki syntax for creating an external link.\nParameters:\n* 
$1 - the URL pointing to the guidelines for translation in Wikipedia",
+       "cx-tools-view-guidelines": "Shown at the bottom of the instructions 
text. A hyperlink to the translation guidelines in the target language.",
        "cx-tools-dictionary-title": "Title of definition tool 
card.\n{{Identical|Definition}}",
        "cx-tools-link-title": "Title of link tool card.\n{{Identical|Link}}",
        "cx-tools-link-add": "Text shown in link tool card. Clicking on it adds 
the link in the cursor position.\n{{Identical|Add link}}",
diff --git a/modules/source/ext.cx.source.js b/modules/source/ext.cx.source.js
index c343993..68216a2 100644
--- a/modules/source/ext.cx.source.js
+++ b/modules/source/ext.cx.source.js
@@ -56,7 +56,9 @@
         * Render the source content column
         */
        ContentTranslationSource.prototype.render = function () {
-               var $heading, $languageLabel, $articleLink, $subHeading, 
$loader;
+               var $heading, $languageLabel, $articleLink, $subHeading, 
$loader,
+                       uri = new mw.Uri(),
+                       domainTemplate = mw.config.get( 
'wgContentTranslationDomainTemplate' );
 
                this.$container.prop( {
                        lang: mw.cx.sourceLanguage,
@@ -71,18 +73,21 @@
                        .addClass( 'cx-column__language-label' )
                        .text( $.uls.data.getAutonym( mw.cx.sourceLanguage ) );
 
+               uri.host = domainTemplate.replace( '$1', mw.cx.sourceLanguage );
+               uri.path = mw.config.get( 'wgScript' );
+               uri.query = {
+                       title: mw.cx.sourceTitle
+               };
+
                $articleLink = $( '<span>' )
                        .addClass( 'cx-column__sub-heading__view-page' )
-                       .html(
-                               mw.message(
-                                       'cx-source-view-page',
-                                       mw.util.getUrl( mw.cx.sourceTitle )
-                               ).parse()
-               );
-
-               // The <a> element is added by the message, which has [].
-               // This makes the article open in a new tab (or window).
-               $articleLink.find( 'a' ).prop( 'target', '_blank' );
+                       .append( $( '<a>' )
+                               .prop( {
+                                       href: uri.toString(),
+                                       target: '_blank'
+                               } )
+                               .text( mw.msg( 'cx-source-view-page' ) )
+                       );
 
                $subHeading = $( '<div>' )
                        .addClass( 'cx-column__sub-heading' )
diff --git a/modules/tools/ext.cx.tools.instructions.js 
b/modules/tools/ext.cx.tools.instructions.js
index ba1b637..840f551 100644
--- a/modules/tools/ext.cx.tools.instructions.js
+++ b/modules/tools/ext.cx.tools.instructions.js
@@ -40,7 +40,9 @@
        InstructionsCard.prototype.constructor = InstructionsCard;
 
        InstructionsCard.prototype.render = function () {
-               var $guidelines;
+               var $guidelines,
+                       uri = new mw.Uri(),
+                       domainTemplate = mw.config.get( 
'wgContentTranslationDomainTemplate' );
 
                this.$card.find( '.tools.count.one' )
                        .text( mw.language.convertNumber( 1 ) );
@@ -63,17 +65,21 @@
                this.$card.find( '.text.description.three' )
                        .text( mw.msg( 'cx-tools-instructions-text6' ) );
 
-               $guidelines = this.$card.find( '.card__section.guidelines' )
-                       .html(
-                               mw.message(
-                                       'cx-tools-view-guidelines',
-                                       mw.util.getUrl( 
'Wikipedia:Translation#How_to_translate' )
-                               ).parse()
-                       );
+               uri.host = domainTemplate.replace( '$1', mw.cx.targetLanguage );
+               uri.path = mw.config.get( 'wgScript' );
+               uri.query = {
+                       // TODO: This must customizable per project
+                       title: 'Project:Translation#How_to_translate'
+               };
 
-               // The <a> element is added by the message, which has [].
-               // This makes the article open in a new tab (or window).
-               $guidelines.find( 'a' ).prop( 'target', '_blank' );
+               $guidelines = this.$card.find( '.card__section.guidelines' )
+                       .append( $( '<a>' )
+                               .prop( {
+                                       href: uri.toString(),
+                                       target: '_blank'
+                               } )
+                               .text( mw.msg( 'cx-tools-view-guidelines' ) )
+                       );
        };
 
        InstructionsCard.prototype.getCard = function () {

-- 
To view, visit https://gerrit.wikimedia.org/r/142967
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I84c55d3ddbe4c341c364201e3ff6f53ad2cfdf36
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Amire80 <amir.ahar...@mail.huji.ac.il>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to