Skip to content

How do you interpret variable value as translation key? #548

Discussion options

You must be logged in to vote

I have one approach now that seems to be working and that is using a custom transpiler. I've extended the functional transpiler (so I have the option to use its functionality) and just replaced every occurance of the variable name with the respective value (with custom match pattern):

import { Injectable, Injector } from '@angular/core';
import { FunctionalTranspiler, HashMap, isString, Translation, TranslocoTranspiler } from '@ngneat/transloco';

@Injectable()
export class CustomTranspiler extends FunctionalTranspiler implements TranslocoTranspiler {
  constructor(private injector1: Injector) {
    super(injector1);
  }

  transpile(value: any, params: HashMap<any> | undefined, translation

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@shaharkazaz
Comment options

Answer selected by gunnarburmeister
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants