From 0f494b10d033e0b6ff652437ad23a8daac0ab4be Mon Sep 17 00:00:00 2001 From: Nicoleta Panaghiu Date: Fri, 27 Sep 2024 15:40:21 +0300 Subject: [PATCH] RED-9381: translations for annotation content tooltip. --- .../src/app/models/file/annotation.wrapper.ts | 50 ++++++++++++++----- .../annotation-wrapper.component.html | 2 +- .../annotation-wrapper.component.ts | 2 + .../services/annotation-draw.service.ts | 2 +- apps/red-ui/src/assets/i18n/redact/de.json | 1 + apps/red-ui/src/assets/i18n/redact/en.json | 1 + apps/red-ui/src/assets/i18n/scm/de.json | 1 + apps/red-ui/src/assets/i18n/scm/en.json | 1 + 8 files changed, 45 insertions(+), 15 deletions(-) diff --git a/apps/red-ui/src/app/models/file/annotation.wrapper.ts b/apps/red-ui/src/app/models/file/annotation.wrapper.ts index fe01347fd..c0f69a8ee 100644 --- a/apps/red-ui/src/app/models/file/annotation.wrapper.ts +++ b/apps/red-ui/src/app/models/file/annotation.wrapper.ts @@ -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[]) { diff --git a/apps/red-ui/src/app/modules/file-preview/components/annotation-wrapper/annotation-wrapper.component.html b/apps/red-ui/src/app/modules/file-preview/components/annotation-wrapper/annotation-wrapper.component.html index 887105917..7297036a0 100644 --- a/apps/red-ui/src/app/modules/file-preview/components/annotation-wrapper/annotation-wrapper.component.html +++ b/apps/red-ui/src/app/modules/file-preview/components/annotation-wrapper/annotation-wrapper.component.html @@ -4,7 +4,7 @@ diff --git a/apps/red-ui/src/app/modules/file-preview/components/annotation-wrapper/annotation-wrapper.component.ts b/apps/red-ui/src/app/modules/file-preview/components/annotation-wrapper/annotation-wrapper.component.ts index 49ea32325..b7ce777e0 100644 --- a/apps/red-ui/src/app/modules/file-preview/components/annotation-wrapper/annotation-wrapper.component.ts +++ b/apps/red-ui/src/app/modules/file-preview/components/annotation-wrapper/annotation-wrapper.component.ts @@ -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 { diff --git a/apps/red-ui/src/app/modules/pdf-viewer/services/annotation-draw.service.ts b/apps/red-ui/src/app/modules/pdf-viewer/services/annotation-draw.service.ts index b888686b6..444eadf90 100644 --- a/apps/red-ui/src/app/modules/pdf-viewer/services/annotation-draw.service.ts +++ b/apps/red-ui/src/app/modules/pdf-viewer/services/annotation-draw.service.ts @@ -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; diff --git a/apps/red-ui/src/assets/i18n/redact/de.json b/apps/red-ui/src/assets/i18n/redact/de.json index 270e6dd7c..588f1bbfe 100644 --- a/apps/red-ui/src/assets/i18n/redact/de.json +++ b/apps/red-ui/src/assets/i18n/redact/de.json @@ -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", diff --git a/apps/red-ui/src/assets/i18n/redact/en.json b/apps/red-ui/src/assets/i18n/redact/en.json index 19bd0a4b7..dbfff7087 100644 --- a/apps/red-ui/src/assets/i18n/redact/en.json +++ b/apps/red-ui/src/assets/i18n/redact/en.json @@ -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", diff --git a/apps/red-ui/src/assets/i18n/scm/de.json b/apps/red-ui/src/assets/i18n/scm/de.json index da632758e..97bf00f22 100644 --- a/apps/red-ui/src/assets/i18n/scm/de.json +++ b/apps/red-ui/src/assets/i18n/scm/de.json @@ -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", diff --git a/apps/red-ui/src/assets/i18n/scm/en.json b/apps/red-ui/src/assets/i18n/scm/en.json index e866d7b96..20da78957 100644 --- a/apps/red-ui/src/assets/i18n/scm/en.json +++ b/apps/red-ui/src/assets/i18n/scm/en.json @@ -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",