Add translation service to DiffService.

This commit is contained in:
Emanuel Schütze 2021-03-08 11:54:46 +01:00
parent 92afd07b62
commit ba0e9b3bc6
2 changed files with 19 additions and 6 deletions

View File

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

View File

@ -1,5 +1,7 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { LineNumberedString, LinenumberingService, LineNumberRange } from './linenumbering.service'; import { LineNumberedString, LinenumberingService, LineNumberRange } from './linenumbering.service';
import { ViewUnifiedChange } from '../../shared/models/motions/view-unified-change'; import { ViewUnifiedChange } from '../../shared/models/motions/view-unified-change';
@ -240,7 +242,10 @@ export class DiffService {
* *
* @param {LinenumberingService} lineNumberingService * @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. * 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, // That's a pretty serious inconsistency that should not happen at all,
// we're just doing some basic damage control here. // we're just doing some basic damage control here.
const msg = 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>'; 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, // That's a pretty serious inconsistency that should not happen at all,
// we're just doing some basic damage control here. // we're just doing some basic damage control here.
const msg = 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>'; return '<em style="color: red; font-weight: bold;">' + msg + '</em>';
} }