Merge pull request #5943 from emanuelschuetze/translationDiffService

Add translation service to DiffService.
This commit is contained in:
Emanuel Schütze 2021-03-08 13:28:59 +01:00 committed by GitHub
commit 4d706f648f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 6 deletions

View File

@ -1,6 +1,7 @@
import { inject, TestBed } from '@angular/core/testing';
import { DiffService, ModificationType } from './diff.service';
import { E2EImportsModule } from '../../../e2e-imports.module';
import { LinenumberingService } from './linenumbering.service';
describe('DiffService', () => {
@ -167,6 +168,7 @@ describe('DiffService', () => {
beforeEach(() => {
TestBed.configureTestingModule({
imports: [E2EImportsModule],
providers: [DiffService]
});
});

View File

@ -1,5 +1,7 @@
import { Injectable } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { LineNumberedString, LinenumberingService, LineNumberRange } from './linenumbering.service';
import { ViewUnifiedChange } from '../../shared/models/motions/view-unified-change';
@ -240,7 +242,10 @@ export class DiffService {
*
* @param {LinenumberingService} lineNumberingService
*/
public constructor(private readonly lineNumberingService: LinenumberingService) {}
public constructor(
private readonly lineNumberingService: LinenumberingService,
protected translate: TranslateService
) {}
/**
* Searches for the line breaking node within the given Document specified by the given lineNumber.
@ -2238,11 +2243,15 @@ export class DiffService {
// That's a pretty serious inconsistency that should not happen at all,
// we're just doing some basic damage control here.
const msg =
'Inconsistent data.' +
this.translate.instant('Inconsistent data.') +
' ' +
'A change recommendation or amendment is probably referring to a non-existant line number.' +
this.translate.instant(
'A change recommendation or amendment is probably referring to a non-existant line number.'
) +
' ' +
'If it is an amendment, you can back up its content when editing it and delete it afterwards.';
this.translate.instant(
'If it is an amendment, you can back up its content when editing it and delete it afterwards.'
);
return '<em style="color: red; font-weight: bold;">' + msg + '</em>';
}
@ -2303,9 +2312,11 @@ export class DiffService {
// That's a pretty serious inconsistency that should not happen at all,
// we're just doing some basic damage control here.
const msg =
'Inconsistent data.' +
this.translate.instant('Inconsistent data.') +
' ' +
'A change recommendation or amendment is probably referring to a non-existant line number.';
this.translate.instant(
'A change recommendation or amendment is probably referring to a non-existant line number.'
);
return '<em style="color: red; font-weight: bold;">' + msg + '</em>';
}