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

Change subject: Load check warnings for fuzzy messages before user starts typing
......................................................................


Load check warnings for fuzzy messages before user starts typing

Bug: 47923
Change-Id: I4cde54fd3ddc7387f7aa8af5c5dfe065a7914b5e
---
M resources/js/ext.translate.editor.helpers.js
M resources/js/ext.translate.editor.js
2 files changed, 28 insertions(+), 3 deletions(-)

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



diff --git a/resources/js/ext.translate.editor.helpers.js 
b/resources/js/ext.translate.editor.helpers.js
index c3d9027..d489983 100644
--- a/resources/js/ext.translate.editor.helpers.js
+++ b/resources/js/ext.translate.editor.helpers.js
@@ -462,6 +462,17 @@
                                translateEditor.showMachineTranslations( 
result.helpers.mt );
                                translateEditor.showSupportOptions( 
result.helpers.support );
                                translateEditor.addDefinitionDiff( 
result.helpers.definitiondiff );
+
+                               // Load the possible warnings as soon as 
possible, do not wait
+                               // for the user to make changes. Otherwise 
users might try confirming
+                               // translations which fail checks. Confirmation 
seems to work but
+                               // the message will continue to appear outdated.
+                               if ( translateEditor.message.properties &&
+                                       
translateEditor.message.properties.status === 'fuzzy'
+                               ) {
+                                       translateEditor.validateTranslation();
+                               }
+
                                mw.translateHooks.run( 
'showTranslationHelpers', result.helpers, translateEditor.$editor );
 
                        } ).fail( function ( errorCode, results ) {
diff --git a/resources/js/ext.translate.editor.js 
b/resources/js/ext.translate.editor.js
index e904142..bb42dee 100644
--- a/resources/js/ext.translate.editor.js
+++ b/resources/js/ext.translate.editor.js
@@ -643,11 +643,25 @@
                                var warningIndex,
                                        warnings = jQuery.parseJSON( data );
 
-                               if ( !warnings ) {
+                               translateEditor.removeWarning( 'validation' );
+                               if ( !warnings || !warnings.length ) {
                                        return;
                                }
 
-                               translateEditor.removeWarning( 'validation' );
+                               // Remove useless outdated warning without 
diff, since our checks
+                               // have found issues to complain about.
+                               if ( translateEditor.$editor.find( 
'.show-diff-link' ).hasClass( 'hide' ) ) {
+                                       translateEditor.removeWarning( 'diff' );
+                               }
+
+                               // Disable confirm translation button, since 
fuzzy translations
+                               // cannot be confirmed. The check for dirty 
state can be removed
+                               // to prevent translations with warnings.
+                               if ( !translateEditor.dirty ) {
+                                       translateEditor.$editor.find( 
'.tux-editor-save-button' )
+                                               .prop( 'disabled', true );
+                               }
+
                                for ( warningIndex = 0; warningIndex < 
warnings.length; warningIndex++ ) {
                                        translateEditor.addWarning( 
warnings[warningIndex], 'validation' );
                                }
@@ -936,7 +950,7 @@
                        mw.loader.load( 'mediawiki.action.history.diff', 
undefined, true );
 
                        // TODO add an option to hide diff
-                       this.$editor.find( '.tux-warning .show-diff-link' )
+                       this.$editor.find( '.show-diff-link' )
                                .removeClass( 'hide' )
                                .on( 'click', function () {
                                        $( this ).parent().html( 
definitiondiff.html );

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

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

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

Reply via email to