angulartypescriptangular-translate

How to have angular translate of for multiple values in a ts file and also having the parameters?


this.snackBar.open(
            `Only files of size less than ${this.fileSizeAllowed}KB are allowed`,
            this.translate.instant('USER_REG.close'),
            
            {
              panelClass: 'errorSnackbar',
              duration: 5500,
            }
          );

I just want the message present in the snackBar, i.e, "Only files of size less than" to be translated to another language, followed by the dynamic variable and then the line "KB are allowed"is to be translated.How to do it? Completely new to angular translate!!!


Solution

  • Maybe this answer can help you: https://stackoverflow.com/a/45737562/13331446

    Have you tried to do the following?

    this.snackBar.open(
                this.translate.instant('FIRST.MESSAGE')+ ${this.fileSizeAllowed} + this.translate.instant('SECOND.MESSAGE'),
                this.translate.instant('USER_REG.close'),
                
                {
                  panelClass: 'errorSnackbar',
                  duration: 5500,
                }
              );