0

Good morning,

I'm using Angular 10 and i18n package to translate my app. I have already made all the localization for the template files and is working perfectly on the prod server.

The problem is that I'm trying to localize as well strings on the ts file but I am not able to achieve this...

What I have now is this on my ts file:

$localize`@@errorMessage:Error`;
$localize`@@startDate:The end date can not be before the start date`;

The problem is how can I include thisin the xlf file to translate it? I have seen that you can include manually into the xlf file and then you can translate it, but doesn't work

Thanks!

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
kokorosama
  • 31
  • 4

2 Answers2

0

Angular should support this by simply using ng extract-i18n. This will scan all files and generate an xlf-file that includes all translatable items, including those from your code.

Schottky
  • 1,549
  • 1
  • 4
  • 19
-1

You forgot a : before @@. It should be:

$localize`:@@errorMessage:Error`

For the xlf file, it would be something like that:

      <trans-unit id="errorMessage" datatype="html">
        <source>Error</source>
        <target>Erreur</target>
      </trans-unit>
HTN
  • 3,388
  • 1
  • 8
  • 18