jenkins-bot has submitted this change and it was merged.
Change subject: Stash: ensure user does not run out of messages
......................................................................
Stash: ensure user does not run out of messages
* Reload if we run out of messages
* Provide more messages than the limit so that reloading is needed only
rarely
* Remove untranslated class from translated messages
Change-Id: I768082c54600653d7b5cb4f58b4c55822a2acc01
---
M messagegroups/SandboxMessageGroup.php
M resources/js/ext.translate.editor.js
M resources/js/ext.translate.special.translationstash.js
3 files changed, 35 insertions(+), 6 deletions(-)
Approvals:
Nikerabbit: Looks good to me, approved
jenkins-bot: Verified
diff --git a/messagegroups/SandboxMessageGroup.php
b/messagegroups/SandboxMessageGroup.php
index 37f29ab..59f5ebb 100644
--- a/messagegroups/SandboxMessageGroup.php
+++ b/messagegroups/SandboxMessageGroup.php
@@ -95,6 +95,11 @@
// Fetch definitions, slowly, one by one
$count = 0;
+
+ // Provide twice the number of messages than the limit
+ // to have a buffer in case the user skips some messages
+ $messagesToProvide = $wgTranslateSandboxLimit * 2;
+
foreach ( $list as $index => &$translation ) {
list( $ns, $page ) = explode( ':', $index, 2 );
$title = Title::makeTitle( $ns,
"$page/{$this->language}" );
@@ -122,14 +127,13 @@
$count++;
- // Always show 20 messages (or less in rare cases)
- if ( $count === $wgTranslateSandboxLimit ) {
+ if ( $count === $messagesToProvide ) {
break;
}
}
// Remove the extra entries
- $list = array_slice( $list, 0, $wgTranslateSandboxLimit );
+ $list = array_slice( $list, 0, $messagesToProvide );
return $list;
}
diff --git a/resources/js/ext.translate.editor.js
b/resources/js/ext.translate.editor.js
index 5f62b30..3faf4f4 100644
--- a/resources/js/ext.translate.editor.js
+++ b/resources/js/ext.translate.editor.js
@@ -136,7 +136,9 @@
.text( mw.msg( 'tux-status-translated'
) )
);
- this.$messageItem.addClass( 'translated' );
+ this.$messageItem
+ .addClass( 'translated' )
+ .removeClass( 'untranslated' );
this.dirty = false;
if ( this.message.properties ) {
@@ -249,6 +251,7 @@
this.$editTrigger = $next;
return this.next();
}
+
// If this is the last message, just hide it
if ( !$next.length ) {
this.hide();
@@ -598,15 +601,22 @@
.on( 'click', function ( e ) {
translateEditor.skip();
translateEditor.next();
+
+ if ( translateEditor.options.onSkip ) {
+
translateEditor.options.onSkip.call( translateEditor );
+ }
+
e.stopPropagation();
} );
+ // This appears instead of "Skip" on the last message
on the page
$cancelButton = $( '<button>' )
.addClass( 'button tux-editor-cancel-button' )
.text( mw.msg( 'tux-editor-cancel-button-label'
) )
.on( 'click', function ( e ) {
translateEditor.skip();
translateEditor.hide();
+
e.stopPropagation();
} );
diff --git a/resources/js/ext.translate.special.translationstash.js
b/resources/js/ext.translate.special.translationstash.js
index c16447b..25da3c6 100644
--- a/resources/js/ext.translate.special.translationstash.js
+++ b/resources/js/ext.translate.special.translationstash.js
@@ -102,6 +102,17 @@
message: message,
storage: translationStashStorage,
onSave: updateStats,
+ onSkip: function () {
+ var $next = this.$editTrigger.next(
'.tux-message' );
+
+ // This can happen when it's
+ // the last message in the translation stash
+ if ( !$next.length ) {
+ // Reload the page to get more messages
+ // when we get to the last one
+ window.location.reload();
+ }
+ },
onReady: function () {
this.$editor.find( '.tux-editor-skip-button' )
.text( mw.msg(
'translate-translationstash-skip-button-label' ) );
@@ -129,11 +140,15 @@
) );
if ( count >= mw.config.get( 'wgTranslateSandboxLimit' ) ) {
+ // Remove the untranslated message to disallow
translation beyond the limit
+ $( '.tux-message' ).has( '.untranslated' ).remove();
+
+ // Show a message telling that the limit was reached
$( '.limit-reached' )
- .removeClass( 'hide' )
.empty()
.append( $( '<h1>' ).text( mw.message(
'tsb-limit-reached-title' ) ) )
- .append( $( '<p>' ).text( mw.message(
'tsb-limit-reached-body' ) ) );
+ .append( $( '<p>' ).text( mw.message(
'tsb-limit-reached-body' ) ) )
+ .removeClass( 'hide' );
}
}
--
To view, visit https://gerrit.wikimedia.org/r/91370
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I768082c54600653d7b5cb4f58b4c55822a2acc01
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/Translate
Gerrit-Branch: master
Gerrit-Owner: Amire80 <[email protected]>
Gerrit-Reviewer: Nikerabbit <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits