Modifying the view thread component

I wanted to keep the translate feature simple. So, along with the existing text message, we are going to add a Translate button in the meta data column of the text message. Open client\app\view-thread\view-thread.component.html and after the Delete message section, add this code:

// SNIPP SNIPP<!-- Any text message will have a nlpLanguage varible --><div *ngIf="message.nlpLanguage"> <br> <button class="btn btn-info btn-block" type="button" (click)="translateMessage(message)"><i class="fa fa-arrows-h"></i> Translate Message</button></div>// SNIPP SNIPP

Next, the required logic for translateMessage will be placed in client\app\view-thread\view-thread.component.ts and should be as shown here:

// SNIPP SNIPP ...

Get Google Cloud AI Services Quick Start Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.