jenkins-bot has submitted this change and it was merged.

Change subject: Correct the lang and dir attributes for documentation language
......................................................................


Correct the lang and dir attributes for documentation language

The lang and dir attributes must reflect the actual language
that is being displayed or edited. "qqq", or whatever the documentation
language code is, shouldn't be a value for lang.

When the target language is the documentation language, use
the site's content language code for this, assuming that that
will be the documentation language.

Change-Id: I7319894f0b627cac118c48d4738993c8106f9ca8
---
M resources/js/ext.translate.editor.js
M resources/js/ext.translate.messagetable.js
M resources/js/ext.translate.pagemode.js
M resources/js/ext.translate.proofread.js
4 files changed, 71 insertions(+), 50 deletions(-)

Approvals:
  Nikerabbit: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/resources/js/ext.translate.editor.js 
b/resources/js/ext.translate.editor.js
index 0d10a15..27fbe7f 100644
--- a/resources/js/ext.translate.editor.js
+++ b/resources/js/ext.translate.editor.js
@@ -341,6 +341,7 @@
                                $layoutActions,
                                $infoToggleIcon,
                                $messageList,
+                               targetLangAttrib, targetLangDir, targetLangCode,
                                $messageTools = 
translateEditor.createMessageTools(),
                                canTranslate = mw.translate.canTranslate();
 
@@ -447,11 +448,20 @@
                                        }
                                } );
 
+                       targetLangCode = $messageList.data( 'targetlangcode' );
+                       if ( targetLangCode === mw.config.get( 
'wgTranslateDocumentationLanguageCode' ) ) {
+                               targetLangAttrib = mw.config.get( 
'wgContentLanguage' );
+                               targetLangDir = $.uls.data.getDir( 
targetLangAttrib );
+                       } else {
+                               targetLangAttrib = targetLangCode;
+                               targetLangDir = $messageList.data( 
'targetlangdir' );
+                       }
+
                        $textarea = $( '<textarea>' )
                                .addClass( 'tux-textarea-translation' )
                                .attr( {
-                                       lang: $messageList.data( 
'targetlangcode' ),
-                                       dir: $messageList.data( 'targetlangdir' 
)
+                                       lang: targetLangAttrib,
+                                       dir: targetLangDir
                                } )
                                .val( this.message.translation || '' );
 
diff --git a/resources/js/ext.translate.messagetable.js 
b/resources/js/ext.translate.messagetable.js
index a47bd98..c2ec5f4 100644
--- a/resources/js/ext.translate.messagetable.js
+++ b/resources/js/ext.translate.messagetable.js
@@ -177,19 +177,15 @@
                 * Add a message to the message table for translation.
                 */
                addTranslate: function ( message ) {
-                       var $message, targetLanguage, targetLanguageDir, 
sourceLanguage, sourceLanguageDir,
-                               status,
-                               statusMsg = '',
-                               statusClass,
-                               $messageWrapper;
-
-                       sourceLanguage = this.$container.data( 'sourcelangcode' 
);
-                       sourceLanguageDir = $.uls.data.getDir( sourceLanguage );
-                       targetLanguage = this.$container.data( 'targetlangcode' 
);
-                       targetLanguageDir = $.uls.data.getDir( targetLanguage );
-
-                       status = message.properties.status;
-                       statusClass = 'tux-status-' + status;
+                       var $message,
+                               targetLangDir, targetLangAttrib,
+                               targetLangCode = this.$container.data( 
'targetlangcode' ),
+                               sourceLangCode = this.$container.data( 
'sourcelangcode' ),
+                               sourceLangDir = $.uls.data.getDir( 
sourceLangCode ),
+                               status = message.properties.status,
+                               statusClass = 'tux-status-' + status,
+                               $messageWrapper = $( '<div>' ).addClass( 'row 
tux-message' ),
+                               statusMsg = '';
 
                        if ( message.tags.length &&
                                $.inArray( 'optional', message.tags ) >= 0 &&
@@ -212,8 +208,13 @@
                                statusMsg = 'tux-status-' + status;
                        }
 
-                       $messageWrapper = $( '<div>' )
-                               .addClass( 'row tux-message' );
+                       if ( targetLangCode === mw.config.get( 
'wgTranslateDocumentationLanguageCode' ) ) {
+                               targetLangAttrib = mw.config.get( 
'wgContentLanguage' );
+                               targetLangDir = $.uls.data.getDir( 
targetLangAttrib );
+                       } else {
+                               targetLangAttrib = targetLangCode;
+                               targetLangDir = this.$container.data( 
'targetlangdir' );
+                       }
 
                        $message = $( '<div>' )
                                .addClass( 'row message tux-message-item ' + 
status )
@@ -224,8 +225,8 @@
                                                        $( '<span>' )
                                                                .addClass( 
'tux-list-source' )
                                                                .attr( {
-                                                                       lang: 
sourceLanguage,
-                                                                       dir: 
sourceLanguageDir
+                                                                       lang: 
sourceLangCode,
+                                                                       dir: 
sourceLangDir
                                                                } )
                                                                .text( 
message.definition ),
                                                        // Bidirectional 
isolation.
@@ -237,8 +238,8 @@
                                                        $( '<span>' )
                                                                .addClass( 
'tux-list-translation' )
                                                                .attr( {
-                                                                       lang: 
targetLanguage,
-                                                                       dir: 
targetLanguageDir
+                                                                       lang: 
targetLangAttrib,
+                                                                       dir: 
targetLangDir
                                                                } )
                                                                .text( 
message.translation || '' )
                                                        ),
@@ -401,19 +402,15 @@
                },
 
                load: function () {
-                       var messagegroup,
-                               pageSize,
-                               remaining,
-                               targetLanguage,
+                       var remaining,
                                query,
                                messageTable = this,
                                $messageList = $( '.tux-messagelist' ),
                                offset = this.$loader.data( 'offset' ),
-                               filter = messageTable.$loader.data( 'filter' );
-
-                       messagegroup = messageTable.$loader.data( 
'messagegroup' );
-                       pageSize = messageTable.$loader.data( 'pagesize' );
-                       targetLanguage = $messageList.data( 'targetlangcode' );
+                               filter = messageTable.$loader.data( 'filter' ),
+                               targetLangCode = $messageList.data( 
'targetlangcode' ),
+                               messagegroup = messageTable.$loader.data( 
'messagegroup' ),
+                               pageSize = messageTable.$loader.data( 
'pagesize' );
 
                        if ( offset === -1 ) {
                                return;
@@ -427,7 +424,7 @@
 
                        messageTable.loading = true;
 
-                       mw.translate.getMessages( messagegroup, targetLanguage, 
offset, pageSize, filter )
+                       mw.translate.getMessages( messagegroup, targetLangCode, 
offset, pageSize, filter )
                                .done( function ( result ) {
                                        var messages = 
result.query.messagecollection,
                                                state;
@@ -457,7 +454,7 @@
                                        } );
 
                                        state = result.query.metadata && 
result.query.metadata.state;
-                                       $( '.tux-workflow' ).workflowselector( 
messagegroup, targetLanguage, state );
+                                       $( '.tux-workflow' ).workflowselector( 
messagegroup, targetLangCode, state );
 
                                        // Dynamically loaded messages should 
pass the search filter if present.
                                        query = $( '.tux-message-filter-box' 
).val();
diff --git a/resources/js/ext.translate.pagemode.js 
b/resources/js/ext.translate.pagemode.js
index b9d730b..a091fc1 100644
--- a/resources/js/ext.translate.pagemode.js
+++ b/resources/js/ext.translate.pagemode.js
@@ -50,12 +50,18 @@
                },
 
                render: function () {
-                       var targetLanguage, targetLanguageDir, sourceLanguage, 
sourceLanguageDir;
+                       var targetLangAttrib, targetLangDir,
+                               sourceLangDir = $.uls.data.getDir( 
this.options.sourcelangcode );
 
-                       sourceLanguage = this.options.sourcelangcode;
-                       sourceLanguageDir = $.uls.data.getDir( sourceLanguage );
-                       targetLanguage = this.options.targetlangcode;
-                       targetLanguageDir = $.uls.data.getDir( targetLanguage );
+                       if ( this.options.targetlangcode ===
+                               mw.config.get( 
'wgTranslateDocumentationLanguageCode' )
+                       ) {
+                               targetLangAttrib = mw.config.get( 
'wgContentLanguage' );
+                       } else {
+                               targetLangAttrib = this.options.targetlangcode;
+                       }
+
+                       targetLangDir = $.uls.data.getDir( targetLangAttrib );
 
                        this.$message.append(
                                $( '<div>' )
@@ -66,15 +72,15 @@
                                                $( '<div>' )
                                                        .addClass( 'five 
columns tux-pagemode-source' )
                                                        .attr( {
-                                                               lang: 
sourceLanguage,
-                                                               dir: 
sourceLanguageDir
+                                                               lang: 
this.options.sourcelangcode,
+                                                               dir: 
sourceLangDir
                                                        } )
                                                        .html( 
mw.translate.formatMessageGently( this.message.definition, this.message.key ) ),
                                                $( '<div>' )
                                                        .addClass( 'five 
columns tux-pagemode-translation' )
                                                        .attr( {
-                                                               lang: 
targetLanguage,
-                                                               dir: 
targetLanguageDir
+                                                               lang: 
targetLangAttrib,
+                                                               dir: 
targetLangDir
                                                        } )
                                                        .html( 
mw.translate.formatMessageGently( this.message.translation || '', 
this.message.key ) ),
                                                $( '<div>' )
diff --git a/resources/js/ext.translate.proofread.js 
b/resources/js/ext.translate.proofread.js
index b165850..8b1db0d 100644
--- a/resources/js/ext.translate.proofread.js
+++ b/resources/js/ext.translate.proofread.js
@@ -159,7 +159,8 @@
                },
 
                render: function () {
-                       var targetLanguage, targetLanguageDir, sourceLanguage, 
sourceLanguageDir,
+                       var targetLangCode, targetLangDir, targetLangAttrib,
+                               sourceLangCode, sourceLangDir,
                                $proofreadAction, $proofreadEdit, userId, 
reviewers, otherReviewers,
                                translatedBySelf, proofreadBySelf;
 
@@ -174,10 +175,10 @@
                        translatedBySelf = ( 
this.message.properties['last-translator-text'] === mw.user.getName() );
                        proofreadBySelf = $.inArray( userId, reviewers ) > -1;
 
-                       sourceLanguage = this.options.sourcelangcode;
-                       sourceLanguageDir = $.uls.data.getDir( sourceLanguage );
-                       targetLanguage = this.options.targetlangcode;
-                       targetLanguageDir = $.uls.data.getDir( targetLanguage );
+                       sourceLangCode = this.options.sourcelangcode;
+                       sourceLangDir = $.uls.data.getDir( sourceLangCode );
+                       targetLangCode = this.options.targetlangcode;
+                       targetLangDir = $.uls.data.getDir( targetLangCode );
 
                        $proofreadAction = $( '<div>' )
                                .attr( 'title', mw.msg( 
'tux-proofread-action-tooltip' ) )
@@ -199,6 +200,13 @@
                                        $( this ).find( 
'.tux-proofread-edit-label' ).addClass( 'hide' );
                                } );
 
+                       if ( targetLangCode === mw.config.get( 
'wgTranslateDocumentationLanguageCode' ) ) {
+                               targetLangAttrib = mw.config.get( 
'wgContentLanguage' );
+                       } else {
+                               targetLangAttrib = targetLangCode;
+                       }
+                       targetLangDir = $.uls.data.getDir( targetLangAttrib );
+
                        this.$message.append(
                                $( '<div>' )
                                        .addClass( 'row 
tux-message-item-compact message' )
@@ -208,15 +216,15 @@
                                                $( '<div>' )
                                                        .addClass( 'five 
columns tux-proofread-source' )
                                                        .attr( {
-                                                               lang: 
sourceLanguage,
-                                                               dir: 
sourceLanguageDir
+                                                               lang: 
sourceLangCode,
+                                                               dir: 
sourceLangDir
                                                        } )
                                                        .text( 
this.message.definition ),
                                                $( '<div>' )
                                                        .addClass( 'five 
columns tux-proofread-translation' )
                                                        .attr( {
-                                                               lang: 
targetLanguage,
-                                                               dir: 
targetLanguageDir
+                                                               lang: 
targetLangAttrib,
+                                                               dir: 
targetLangDir
                                                        } )
                                                        .text( 
this.message.translation || '' ),
                                                $( '<div>' )

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I7319894f0b627cac118c48d4738993c8106f9ca8
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/Translate
Gerrit-Branch: master
Gerrit-Owner: Amire80 <[email protected]>
Gerrit-Reviewer: Nikerabbit <[email protected]>
Gerrit-Reviewer: SuchetaG <[email protected]>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to