[#5561] Translate notification action value (#5604)

* [#5561] Translate action value

* Fix lint issues
This commit is contained in:
Arik Sidney Guggenheim
2020-04-14 13:34:38 +02:00
committed by GitHub
parent 63063699fd
commit d089283aa4
2 changed files with 14 additions and 1 deletions

View File

@@ -124,6 +124,18 @@ describe('NotificationService', () => {
fixture.detectChanges();
});
it('should translate the action', (done) => {
spyOn(translationService, 'instant').and.callThrough();
const promise = fixture.componentInstance.sendMessageAction();
promise.afterDismissed().subscribe(() => {
expect(translationService.instant).toHaveBeenCalledTimes(2);
done();
});
fixture.detectChanges();
});
it('should open a message notification bar', (done) => {
const promise = fixture.componentInstance.sendMessage();
promise.afterDismissed().subscribe(() => {

View File

@@ -104,10 +104,11 @@ export class NotificationService {
private dispatchNotification(message: string, action?: string, config?: number | MatSnackBarConfig, interpolateArgs?: any): MatSnackBarRef<any> {
const translatedMessage: string = this.translationService.instant(message, interpolateArgs);
const translatedAction: string = this.translationService.instant(action, interpolateArgs);
const createNotification = this.getNotificationCreator(config);
this.notifications$.next(createNotification(translatedMessage));
return this.snackBar.open(translatedMessage, action, {
return this.snackBar.open(translatedMessage, translatedAction, {
duration: (typeof config === 'number') ? config : this.DEFAULT_DURATION_MESSAGE,
panelClass: INFO_SNACK_CLASS,
...( (typeof config === 'object') ? config : {} )