Using ngxtranslate for application translation has been seamless so far. However, I am facing an issue with the HttpInterceptor. This interceptor attempts to retrieve data from local storage at the start and displays a dialog prompting you to either load the last changes or dismiss them.
The problem lies in the fact that the text within this dialog is not being translated, unlike elsewhere in the application where translation works perfectly fine.
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')
);
....
The output only shows some.text
and some.anotherText
. How can I resolve this issue and make it work properly?