Stickman77
Stickman77

Reputation: 47

Disable JhiAlertService from using TranslateService to translate message

When i use my service to print a message, the JhiAlertService tries to translate the message, how can i disable?

enter image description here

import { Injectable } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { JhiAlertService } from 'ng-jhipster';

@Injectable({
    providedIn: 'root'
})
export class MessageServiceService {
    

    constructor(public translate: TranslateService, public alertService: JhiAlertService) {
        this.getTranslations();
    }
	
	getTranslations(){
		this.clientError1 = this.translate.instant('global.error.clientError1');
		this.clientError2 = this.translate.instant('global.error.clientError2');
	}

    printError(name, clientnumber) {
        this.alertService.error(
            this.clientError1 + name + this.clientError2 + clientnumber 
        );
    }
}

Upvotes: 1

Views: 577

Answers (1)

Unfortunately I have not found a way to not activate the translate;

however, to solve the problem it is sufficient to pass the variables between the parameters as follows:

String:

MSG_STR: "Hello {{user}}"

Alert command:

this.alertService.error(MSG_STR, {user: 'Max'}));

Result:

Hello Max

Upvotes: 2

Related Questions