I am using ngxtranslate to translate the application. It works like charm.
Problem is that I have HttpInterceptor which is trying to get data from local storage in the beginning and shows a dialog if asking you if you want to load the last changes or dismiss.
Problem is that text here in the dialog is not translated and I don't know how to do it because everywhere it works.
HTTPInterceptor file
import { TranslateService } from '@ngx-translate/core';
@Injectable()
export class CacheInterceptor implements HttpInterceptor {
constructor(private cacheService: HttpCacheService, private dialog: MatDialog, private translate: TranslateService) {}
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
return from(this.handle(req, next));
}
.......
const cachedResponse: HttpResponse<any> =
this.cacheService.get(reqId);
if (cachedResponse) {
console.log('cache hit');
const dialogResult = await this.openDialog();
if (dialogResult) {
console.log('Loading item from cache');
// return modifyied response
.........
async openDialog() {
const dialogData = new ConfirmationDialogModel(
await this.translate.instant('some.text'),
await this.translate.instant('some.anotherText')
);
....
output is just some.text and some.anotherText
What can I do to make it work please?