How can I change the name of the template that is passed to the @Render decorator in the Interceptor? I need to add the desired locale to the template url, depending on the user's language. I'm trying to do this, but it doesn't work. How can I do this?
@Injectable()
export class RenderByLanguageInterceptor implements NestInterceptor {
constructor(private reflector: Reflector) {}
intercept(context: ExecutionContext, next: CallHandler): Observable<any> {
const template = this.reflector.getAllAndOverride<string>(RENDER_METADATA, [
context.getHandler(),
context.getClass(),
]);
const lang = context.switchToHttp().getRequest().i18nLang;
SetMetadata(RENDER_METADATA, `${lang}/${template}`);
return next.handle();
}
}