RED-9381: translations for annotation content tooltip.
This commit is contained in:
parent
b2091d4f83
commit
0f494b10d0
@ -26,6 +26,12 @@ import {
|
||||
} from '@red/domain';
|
||||
import { annotationTypesTranslations } from '@translations/annotation-types-translations';
|
||||
|
||||
interface AnnotationContent {
|
||||
translation: string;
|
||||
params: { [key: string]: string };
|
||||
untranslatedContent: string;
|
||||
}
|
||||
|
||||
export class AnnotationWrapper implements IListable {
|
||||
id: string;
|
||||
superType: SuperType;
|
||||
@ -36,7 +42,7 @@ export class AnnotationWrapper implements IListable {
|
||||
numberOfComments = 0;
|
||||
firstTopLeftPoint: IPoint;
|
||||
shortContent: string;
|
||||
content: string;
|
||||
content: AnnotationContent;
|
||||
value: string;
|
||||
pageNumber: number;
|
||||
dictionaryOperation = false;
|
||||
@ -279,7 +285,7 @@ export class AnnotationWrapper implements IListable {
|
||||
);
|
||||
|
||||
const content = this.#createContent(annotationWrapper, logEntry, isDocumine);
|
||||
annotationWrapper.shortContent = this.#getShortContent(annotationWrapper, legalBasisList) || content;
|
||||
annotationWrapper.shortContent = this.#getShortContent(annotationWrapper, legalBasisList) || content.untranslatedContent;
|
||||
annotationWrapper.content = content;
|
||||
|
||||
const lastRelevantManualChange = logEntry.manualChanges?.at(-1);
|
||||
@ -311,39 +317,57 @@ export class AnnotationWrapper implements IListable {
|
||||
}
|
||||
|
||||
static #createContent(annotationWrapper: AnnotationWrapper, logEntry: IEntityLogEntry, isDocumine: boolean) {
|
||||
let content = '';
|
||||
let untranslatedContent = '';
|
||||
const params: { [key: string]: string } = {};
|
||||
if (logEntry.matchedRule) {
|
||||
content += `Rule ${logEntry.matchedRule} matched${isDocumine ? ':' : ''} \n\n`;
|
||||
params['hasRule'] = 'true';
|
||||
params['matchedRule'] = logEntry.matchedRule.replace(/(^[, ]*)|([, ]*$)/g, '');
|
||||
params['ruleSymbol'] = isDocumine ? ':' : '';
|
||||
|
||||
untranslatedContent += `Rule ${logEntry.matchedRule} matched${isDocumine ? ':' : ''} \n\n`;
|
||||
}
|
||||
|
||||
if (logEntry.reason) {
|
||||
params['hasReason'] = 'true';
|
||||
if (isDocumine && logEntry.reason.slice(-1) === '.') {
|
||||
logEntry.reason = logEntry.reason.slice(0, -1);
|
||||
}
|
||||
|
||||
content += logEntry.reason + '\n\n';
|
||||
if (!params['hasRule']) {
|
||||
params['reason'] = logEntry.reason.substring(0, 1).toUpperCase() + logEntry.reason.substring(1);
|
||||
} else {
|
||||
params['reason'] = logEntry.reason;
|
||||
}
|
||||
params['reason'] = params['reason'].replace(/(^[, ]*)|([, ]*$)/g, '');
|
||||
untranslatedContent += logEntry.reason + '\n\n';
|
||||
//remove leading and trailing commas and whitespaces
|
||||
content = content.replace(/(^[, ]*)|([, ]*$)/g, '');
|
||||
content = content.substring(0, 1).toUpperCase() + content.substring(1);
|
||||
untranslatedContent = untranslatedContent.replace(/(^[, ]*)|([, ]*$)/g, '');
|
||||
untranslatedContent = untranslatedContent.substring(0, 1).toUpperCase() + untranslatedContent.substring(1);
|
||||
}
|
||||
|
||||
if (annotationWrapper.legalBasis && !isDocumine) {
|
||||
content += 'Legal basis: ' + annotationWrapper.legalBasis + '\n\n';
|
||||
params['hasLb'] = 'true';
|
||||
params['legalBasis'] = annotationWrapper.legalBasis;
|
||||
untranslatedContent += 'Legal basis: ' + annotationWrapper.legalBasis + '\n\n';
|
||||
}
|
||||
|
||||
if (annotationWrapper.hasBeenRemovedByManualOverride) {
|
||||
content += 'Removed by manual override';
|
||||
params['hasOverride'] = 'true';
|
||||
untranslatedContent += 'Removed by manual override';
|
||||
}
|
||||
|
||||
if (logEntry.section) {
|
||||
params['hasSection'] = 'true';
|
||||
params['sectionSymbol'] = isDocumine ? '' : ':';
|
||||
params['shouldLower'] = untranslatedContent.length.toString();
|
||||
params['section'] = logEntry.section;
|
||||
let prefix = `In section${isDocumine ? '' : ':'} `;
|
||||
if (content.length) {
|
||||
if (untranslatedContent.length) {
|
||||
prefix = ` ${prefix.toLowerCase()}`;
|
||||
}
|
||||
content += `${prefix} "${logEntry.section}"`;
|
||||
untranslatedContent += `${prefix} "${logEntry.section}"`;
|
||||
}
|
||||
|
||||
return content;
|
||||
return { translation: _('annotation-content'), params: params, untranslatedContent: untranslatedContent };
|
||||
}
|
||||
|
||||
static #getShortContent(annotationWrapper: AnnotationWrapper, legalBasisList: ILegalBasis[]) {
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
<redaction-annotation-card
|
||||
[annotation]="annotation.item"
|
||||
[isSelected]="annotation.isSelected"
|
||||
[matTooltip]="annotation.item.content"
|
||||
[matTooltip]="annotation.item.content.translation | translate: annotation.item.content.params | replaceNbsp"
|
||||
matTooltipPosition="above"
|
||||
></redaction-annotation-card>
|
||||
|
||||
|
||||
@ -13,6 +13,7 @@ import { MatIcon } from '@angular/material/icon';
|
||||
import { AnnotationActionsComponent } from '../annotation-actions/annotation-actions.component';
|
||||
import { CommentsComponent } from '../comments/comments.component';
|
||||
import { AnnotationDetailsComponent } from '../annotation-details/annotation-details.component';
|
||||
import { ReplaceNbspPipe } from '@common-ui/pipes/replace-nbsp.pipe';
|
||||
|
||||
@Component({
|
||||
selector: 'redaction-annotation-wrapper',
|
||||
@ -29,6 +30,7 @@ import { AnnotationDetailsComponent } from '../annotation-details/annotation-det
|
||||
AnnotationActionsComponent,
|
||||
CommentsComponent,
|
||||
AnnotationDetailsComponent,
|
||||
ReplaceNbspPipe,
|
||||
],
|
||||
})
|
||||
export class AnnotationWrapperComponent implements OnChanges {
|
||||
|
||||
@ -169,7 +169,7 @@ export class AnnotationDrawService {
|
||||
const annotation = this._pdf.textHighlight();
|
||||
annotation.Quads = this.#rectanglesToQuads(annotationWrapper.positions, pageNumber);
|
||||
annotation.Opacity = annotationWrapper.isRemoved ? DEFAULT_REMOVED_ANNOTATION_OPACITY : DEFAULT_TEXT_ANNOTATION_OPACITY;
|
||||
annotation.setContents(annotationWrapper.content);
|
||||
annotation.setContents(annotationWrapper.content.untranslatedContent);
|
||||
annotation.PageNumber = pageNumber;
|
||||
annotation.StrokeColor = this.convertColor(annotationWrapper.color);
|
||||
annotation.Id = annotationWrapper.id;
|
||||
|
||||
@ -376,6 +376,7 @@
|
||||
"removed-manual": "Schwärzung/Hinweis wurde entfernt",
|
||||
"resized": "Schwärzungsbereich wurde geändert"
|
||||
},
|
||||
"annotation-content": "{hasRule, select, true {Regel {matchedRule} trifft zu auf{ruleSymbol}} other {}} {hasReason, select, true {{reason}} other {}} {hasLb, select, true {Rechstgrundlage: {legalBasis}} other {}} {hasOverride, select, true {Entfernt durch manuelles Überschreiben} other {}} {hasSection, select, true {{shouldLower, plural, =0 {I} other {i}}n Abschnitt{sectionSymbol} \"{section}\"} other {}}",
|
||||
"annotation-engines": {
|
||||
"dictionary": "{isHint, select, true{Hinweis} other{Schwärzung}} basiert auf Wörterbuch",
|
||||
"dossier-dictionary": "Basiert auf Dossier-Wörterbuch",
|
||||
|
||||
@ -376,6 +376,7 @@
|
||||
"removed-manual": "Redaction/Hint removed",
|
||||
"resized": "Redaction area has been modified"
|
||||
},
|
||||
"annotation-content": "{hasRule, select, true {Rule {matchedRule} matched{ruleSymbol}} other {}} {hasReason, select, true {{reason}} other {}} {hasLb, select, true {Legal basis: {legalBasis}} other {}} {hasOverride, select, true {Removed by manual override} other {}} {hasSection, select, true {{shouldLower, plural, =0 {I} other {i}}n section{sectionSymbol} \"{section}\"} other {}}",
|
||||
"annotation-engines": {
|
||||
"dictionary": "Based on dictionary",
|
||||
"dossier-dictionary": "Based on dossier dictionary",
|
||||
|
||||
@ -376,6 +376,7 @@
|
||||
"removed-manual": "Schwärzung/Hinweis entfernt",
|
||||
"resized": "Schwärzungsbereich wurde geändert"
|
||||
},
|
||||
"annotation-content": "{hasRule, select, true {Regel {matchedRule} trifft zu auf{ruleSymbol}} other {}} {hasReason, select, true {{reason}} other {}} {hasLb, select, true {Rechstgrundlage: {legalBasis}} other {}} {hasOverride, select, true {Entfernt durch manuelles Überschreiben} other {}} {hasSection, select, true {{shouldLower, plural, =0 {I} other {i}}n Abschnitt{sectionSymbol} \"{section}\"} other {}}",
|
||||
"annotation-engines": {
|
||||
"dictionary": "{isHint, select, true{Hint} other{Redaction}} basierend auf Wörterbuch",
|
||||
"dossier-dictionary": "Annotation based on dossier dictionary",
|
||||
|
||||
@ -376,6 +376,7 @@
|
||||
"removed-manual": "Annotation/Hint removed",
|
||||
"resized": "Annotation area has been modified"
|
||||
},
|
||||
"annotation-content": "{hasRule, select, true {Rule {matchedRule} matched{ruleSymbol}} other {}} {hasReason, select, true {{reason}} other {}} {hasLb, select, true {Legal basis: {legalBasis}} other {}} {hasOverride, select, true {Removed by manual override} other {}} {hasSection, select, true {{shouldLower, plural, =0 {I} other {i}}n section{sectionSymbol} \"{section}\"} other {}}",
|
||||
"annotation-engines": {
|
||||
"dictionary": "{isHint, select, true{Hint} other{Annotation}} based on dictionary",
|
||||
"dossier-dictionary": "Annotation based on dossier dictionary",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user