Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
mauretto78 committed Feb 20, 2024
2 parents e7f52b0 + 91b236b commit 7ace7f2
Show file tree
Hide file tree
Showing 17 changed files with 322 additions and 186 deletions.
4 changes: 2 additions & 2 deletions lib/Controller/getWarningController.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@ private function __segmentWarningsCall() {
$featureSet = $this->getFeatureSet();
$Filter = MateCatFilter::getInstance( $featureSet, $this->chunk->source, $this->chunk->target, [] );

$this->__postInput->src_content = $Filter->fromLayer2ToLayer0( $this->__postInput->src_content );
$this->__postInput->trg_content = $Filter->fromLayer2ToLayer0( $this->__postInput->trg_content );
$this->__postInput->src_content = $Filter->fromLayer0ToLayer2( $this->__postInput->src_content );
$this->__postInput->trg_content = $Filter->fromLayer0ToLayer2( $this->__postInput->trg_content );

$QA = new QA( $this->__postInput->src_content, $this->__postInput->trg_content );
$QA->setFeatureSet( $featureSet );
Expand Down
2 changes: 1 addition & 1 deletion lib/Controller/setTranslationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ public function doAction() {
$new_translation->suggestion_position = ($this->chosen_suggestion_index !== null ? $this->chosen_suggestion_index : $old_translation->suggestion_position);
$new_translation->warning = $check->thereAreWarnings();
$new_translation->translation_date = date( "Y-m-d H:i:s" );
$new_translation->suggestion = ((!empty($old_suggestion)) ? $old_suggestion->translation : $old_translation->translation);
$new_translation->suggestion = ((!empty($old_suggestion)) ? $old_suggestion->translation : $old_translation->suggestion);
$new_translation->suggestion_source = $old_translation->suggestion_source;
$new_translation->suggestion_match = $old_translation->suggestion_match;

Expand Down
51 changes: 41 additions & 10 deletions lib/Utils/Analysis/Workers/TMAnalysisWorker.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,22 +149,23 @@ protected function _endQueueCallback( QueueElement $queueElement ) {
*/
protected function _updateRecord( QueueElement $queueElement ) {

$firstAvailableNotMTMatch = $this->getFirstAvailableNotMTMatch();
$featureSet = ( $this->featureSet !== null ) ? $this->featureSet : new \FeatureSet();
$filter = MateCatFilter::getInstance( $featureSet, $queueElement->params->source, $queueElement->params->target, [] );
$suggestion = $this->_matches[ 0 ][ 'raw_translation' ]; //No layering needed
$suggestion = $firstAvailableNotMTMatch[ 'raw_translation' ]; //No layering needed

$suggestion_match = $this->_matches[ 0 ][ 'match' ];
$suggestion_source = $this->_matches[ 0 ][ 'created_by' ];
$suggestion_match = $firstAvailableNotMTMatch[ 'match' ];
$suggestion_source = $firstAvailableNotMTMatch[ 'created_by' ];

$equivalentWordMapping = json_decode( $queueElement->params->payable_rates, true );

$new_match_type = $this->_getNewMatchType(
( stripos( $this->_matches[ 0 ][ 'created_by' ], "MT" ) !== false ? "MT" : $suggestion_match ),
( stripos( $firstAvailableNotMTMatch[ 'created_by' ], "MT" ) !== false ? "MT" : $suggestion_match ),
$queueElement->params->match_type,
$equivalentWordMapping,
/* is Public TM */
empty( $this->_matches[ 0 ][ 'memory_key' ] ),
isset( $this->_matches[ 0 ][ 'ICE' ] ) && $this->_matches[ 0 ][ 'ICE' ]
empty( $firstAvailableNotMTMatch[ 'memory_key' ] ),
isset( $firstAvailableNotMTMatch[ 'ICE' ] ) && $firstAvailableNotMTMatch[ 'ICE' ]
);

$eqWordMapping = (isset($equivalentWordMapping[ $new_match_type ])) ? $equivalentWordMapping[ $new_match_type ] : null;
Expand All @@ -182,7 +183,12 @@ protected function _updateRecord( QueueElement $queueElement ) {
$standard_words = $equivalentWordMapping[ "NO_MATCH" ] * $queueElement->params->raw_word_count / 100;

// realign MT Spaces
$check = $this->initPostProcess( $this->_matches[ 0 ][ 'raw_segment' ], $suggestion, $queueElement->params->source, $queueElement->params->target );
$check = $this->initPostProcess(
$firstAvailableNotMTMatch[ 'raw_segment' ],
$suggestion,
$queueElement->params->source,
$queueElement->params->target
);
$check->realignMTSpaces();

//this should every time be ok because MT preserve tags, but we use the check on the errors
Expand All @@ -201,14 +207,19 @@ protected function _updateRecord( QueueElement $queueElement ) {

}

( !empty( $this->_matches[ 0 ][ 'sentence_confidence' ] ) ?
$mt_qe = floatval( $this->_matches[ 0 ][ 'sentence_confidence' ] ) :
( !empty( $firstAvailableNotMTMatch[ 'sentence_confidence' ] ) ?
$mt_qe = floatval( $firstAvailableNotMTMatch[ 'sentence_confidence' ] ) :
$mt_qe = null
);

// perform a consistency check as setTranslation does
// in order to add spaces to translation if needed
$check = $this->initPostProcess( $queueElement->params->segment, $suggestion, $queueElement->params->source, $queueElement->params->target );
$check = $this->initPostProcess(
$queueElement->params->segment,
$suggestion,
$queueElement->params->source,
$queueElement->params->target
);
$check->performConsistencyCheck();
$suggestion = $check->getTargetSeg();
$err_json2 = ( $check->thereAreErrors() ) ? $check->getErrorsJSON() : '';
Expand Down Expand Up @@ -276,6 +287,26 @@ protected function _updateRecord( QueueElement $queueElement ) {

}

/**
* Get the first available not MT match
* @return mixed
*/
private function getFirstAvailableNotMTMatch()
{
foreach($this->_matches as $match){
// return $match if not MT and quality >= 75
if(
stripos( $match[ 'created_by' ], "MT" ) === false and
(int)$match[ 'match' ] >= 75
){
return $match;
}
}

// return the first match available
return $this->_matches[0];
}

/**
* Init a \PostProcess instance.
* This method forces to set source/target languages
Expand Down
9 changes: 4 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
"react-tagsinput": "^3.19.0",
"react-transition-group": "^4.2.2",
"react-virtual": "^2.10.4",
"showdown": "^2.0.0",
"sprintf-js": "^1.1.2"
},
"devDependencies": {
Expand All @@ -45,7 +44,7 @@
"@babel/plugin-transform-runtime": "^7.23.7",
"@babel/preset-env": "^7.23.8",
"@babel/preset-react": "^7.23.3",
"@sentry/webpack-plugin": "2.10.3",
"@sentry/webpack-plugin": "2.13.0",
"@testing-library/jest-dom": "^6.2.0",
"@testing-library/react": "^14.1.2",
"@testing-library/user-event": "^14.5.2",
Expand All @@ -72,11 +71,11 @@
"sass": "^1.66.0",
"sass-loader": "14.1.0",
"style-loader": "3.3.4",
"undici": "^5.28.2",
"webpack": "5.90.0",
"webpack": "5.90.1",
"webpack-cli": "5.1.4",
"webpack-concat-files-plugin": "^0.5.2",
"whatwg-fetch": "^3.6.20"
"whatwg-fetch": "^3.6.20",
"undici": "^5.28.2"
},
"resolutions": {
"wrap-ansi": "^7.0.0"
Expand Down
2 changes: 1 addition & 1 deletion plugins/translated
2 changes: 1 addition & 1 deletion plugins/uber
Submodule uber updated from c5f7e7 to dd644f
5 changes: 5 additions & 0 deletions public/css/sass/modals/instructionsModal.scss
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@
line-height: 26px;
word-break: break-all;
}
blockquote {
border-left: 5px solid #ccc;
margin: 1.5em 10px;
padding: 0.5em 10px;
}
}

.description {
Expand Down
11 changes: 8 additions & 3 deletions public/css/sass/segment-notes.scss
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,21 @@ div.segment-notes ul.graysmall li span.note-label {
font-size: 16px;
word-break: break-word;
white-space: pre-wrap;
display: flex;
align-content: center;
}
.segments-notes-container .metadata-notes {
display: flex;
flex-wrap: wrap;
flex-direction: row;
}

.segments-notes-container div.note p {
margin: 0;
line-height: 25px;
.segments-notes-container div.note {
p,
span {
margin: 0;
line-height: 20px;
}
}

.segments-notes-container div.note p a {
Expand Down
Binary file modified public/img/emails/matecat-logo--white.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 6 additions & 2 deletions public/js/cat_source/es6/actions/SegmentActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,9 @@ const SegmentActions = {
if (shouldRefresh) {
getGlossaryForSegment({
idSegment: sid,
source: DraftMatecatUtils.removeTagsFromText(text),
source: DraftMatecatUtils.removePlaceholdersForGlossary(
DraftMatecatUtils.removeTagsFromText(text),
),
}).catch(() => {
OfflineUtils.failedConnection(sid, 'getGlossaryForSegment')
})
Expand Down Expand Up @@ -850,7 +852,9 @@ const SegmentActions = {
//Response inside SSE Channel
getGlossaryForSegment({
idSegment: request.sid,
source: DraftMatecatUtils.removeTagsFromText(request.text),
source: DraftMatecatUtils.removePlaceholdersForGlossary(
DraftMatecatUtils.removeTagsFromText(request.text),
),
}).catch(() => {
OfflineUtils.failedConnection(request.sid, 'getGlossaryForSegment')
})
Expand Down
13 changes: 2 additions & 11 deletions public/js/cat_source/es6/components/modals/JobMetadataModal.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,11 @@
import showdown from 'showdown'
import React from 'react'

import CommonUtils from '../../utils/commonUtils'
import TextUtils from '../../utils/textUtils'

class JobMetadataModal extends React.Component {
constructor(props) {
super(props)
this.state = {}
this.converter = new showdown.Converter()
this.converter.setOption('literalMidWordUnderscores', true)
// this.instructions =
// '**Client:** Product - Rider \n' +
// '**Domain:** UI \n' +
// '**Note:** Link to file a query: http://t.uber.com/riderq Rider \n' +
// ' Screen Search: https://docs.google.com/document/d/19Dk92t9NXdN.';
}
createFileList() {
const {currentFile, currentFilePart} = this.props
Expand Down Expand Up @@ -89,7 +80,7 @@ class JobMetadataModal extends React.Component {
}

getHtml(text) {
return TextUtils.replaceUrl(text.replace(/[ ]*\n/g, '<br>\n'))
return text
}

componentDidMount() {
Expand Down Expand Up @@ -123,7 +114,7 @@ class JobMetadataModal extends React.Component {
{this.props.files &&
this.props.files.find((file) => file.metadata.instructions) && (
<div>
<h2>Files instructions</h2>
<h2>File instructions</h2>
<div
className="ui styled fluid accordion"
ref={(acc) => {
Expand Down
37 changes: 33 additions & 4 deletions public/js/cat_source/es6/components/modals/LoginModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class LoginModal extends React.Component {
this.handleSubmitClicked = this.handleSubmitClicked.bind(this)
this.sendLoginData = this.sendLoginData.bind(this)
this.errorFor = this.errorFor.bind(this)
this.timerLoginAttempts
}

// TODO: find a way to abstract this into the plugin
Expand Down Expand Up @@ -87,8 +88,31 @@ class LoginModal extends React.Component {
}
}

showErrorWithTimer(time) {
this.setState({
requestRunning: true,
})
clearInterval(this.timerLoginAttempts)
this.timerLoginAttempts = setInterval(() => {
time--
if (time === 0) {
clearInterval(this.timerLoginAttempts)
this.setState({
requestRunning: false,
showErrors: false,
generalError: '',
})
} else {
let text = `Too many attempts, please retry in ${time} seconds`
this.setState({
generalError: text,
requestRunning: true,
})
}
}, 1000)
}

handleSubmitClicked() {
let self = this
this.setState({showErrors: true})
if ($.isEmptyObject(this.state.validationErrors) == false) return null
if (this.state.requestRunning) {
Expand All @@ -98,15 +122,20 @@ class LoginModal extends React.Component {
this.checkRedeemProject().then(
this.sendLoginData()
.then(() => {
if (self.props.goToManage) {
if (this.props.goToManage) {
window.location = '/manage/'
} else {
window.location.reload()
}
})
.catch(() => {
.catch((response) => {
if (response.status === 429) {
const time = response.headers.get('Retry-After')
this.showErrorWithTimer(time)
return
}
const text = 'Login failed.'
self.setState({
this.setState({
generalError: text,
requestRunning: false,
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ function SegmentFooter() {
getMetadataNoteTemplate: () =>
segment.metadata?.length > 0 ? segment.metadata : null,
allowHTML: () => '',
getNoteContentStructure: (note) => note,
}
const notes =
SegmentFooterTabMessages.prototype.getNotes.call(tabMessagesContext)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,39 +15,40 @@ class SegmentFooterTabMessages extends React.Component {
({meta_key}) => meta_key !== 'sizeRestriction',
)
}

getNoteContentStructure(note) {
return TEXT_UTILS.getContentWithAllowedLinkRedirect(note).length > 1
? TEXT_UTILS.getContentWithAllowedLinkRedirect(note).map(
(content, index) =>
typeof content === 'object' && content.isLink ? (
<a key={index} href={content.link} target="_blank">
{content.link}
</a>
) : (
content
),
)
: note
}
getNotes() {
let notesHtml = []
let self = this

const getNoteContentStructure = (note) =>
TEXT_UTILS.getContentWithAllowedLinkRedirect(note).length > 1
? TEXT_UTILS.getContentWithAllowedLinkRedirect(note).map(
(content, index) =>
typeof content === 'object' && content.isLink ? (
<a key={index} href={content.link} target="_blank">
{content.link}
</a>
) : (
content
),
)
: note

if (this.props.notes) {
this.props.notes.forEach(function (item, index) {
this.props.notes.forEach((item, index) => {
if (item.note && item.note !== '') {
if (
self.excludeMatchingNotesRegExp &&
self.excludeMatchingNotesRegExp.test(item.note)
this.excludeMatchingNotesRegExp &&
this.excludeMatchingNotesRegExp.test(item.note)
) {
return
}
let note = item.note
let html = (
<div className="note" key={'note-' + index}>
<span className="note-label">Note: </span>
<span>{getNoteContentStructure(note)}</span>
<span
dangerouslySetInnerHTML={{
__html: this.getNoteContentStructure(note),
}}
/>
</div>
)
notesHtml.push(html)
Expand Down
Loading

0 comments on commit 7ace7f2

Please sign in to comment.