Skip to content

Commit

Permalink
Machinery: Group same results
Browse files Browse the repository at this point in the history
Issue #3626
  • Loading branch information
nijel committed May 12, 2020
1 parent c70f5bb commit 2a2b7f5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
1 change: 1 addition & 0 deletions docs/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Not yet released.
* Allow to whitelist registration methods with registrations closed.
* Improved lookup of related terms in glossary.
* Improved translation memory matches.
* Group same machinery results.

Weblate 4.0.4
-------------
Expand Down
24 changes: 18 additions & 6 deletions weblate/static/loader-bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,14 +296,15 @@ function processMachineTranslation(data, scope) {
decreaseLoading(scope);
if (data.responseStatus === 200) {
data.translations.forEach(function (el, idx) {
var newRow = $('<tr/>').data('quality', el.quality);
var newRow = $('<tr/>').data('raw', el);
var done = false;
var $machineTranslations = $('#' + scope + '-translations');
var service;

newRow.append($('<td/>').attr('class', 'target mt-text').attr('lang', data.lang).attr('dir', data.dir).text(el.text));
newRow.append($('<td/>').attr('class', 'mt-text').text(el.source));
if (scope === "mt") {
var service = $('<td/>').text(el.service);
service = $('<td/>').text(el.service);
if (typeof el.origin !== 'undefined') {
service.append(' (');
var origin;
Expand All @@ -318,10 +319,10 @@ function processMachineTranslation(data, scope) {
service.append(')');
// newRow.append($('<td/>').text(interpolate('%s (%s)', [el.service, ])));
}
newRow.append(service);
} else {
newRow.append($('<td/>').text(el.origin));
service = $('<td/>').text(el.origin);
}
newRow.append(service);
/* Quality score as bar with the text */
newRow.append($(
'<td>' +
Expand All @@ -348,9 +349,20 @@ function processMachineTranslation(data, scope) {
'</td>'
));
$machineTranslations.children('tr').each(function (idx) {
if ($(this).data('quality') < el.quality && !done) {
$(this).before(newRow);
var $this = $(this);
var base = $this.data('raw');
if (base.text == el.text && base.source == el.source) {
// Add origin to current ones
var current = $this.children('td:nth-child(3)');
current.append($("<br/>"));
current.append(service.html());
done = true;
return false;
} else if (base.quality <= el.quality) {
// Insert match before lower quality one
$this.before(newRow);
done = true;
return false;
}
});
if (! done) {
Expand Down

0 comments on commit 2a2b7f5

Please sign in to comment.