简体   繁体   中英

Angular: How to generate one trans-unit from i18n attribute and $localize function?

Code in component:

title = $localize`Monday`;

Code in template:

<div i18n>Monday</div>

"ng extract-i18n" command extract two separate trans-units to messages.xlf.

Yes, because you have two separate translations: title in the ts-file and the <div> in the template. If you wish to use title you can use in the template with interpolation with the i18n attribute. If you use the i18n attribute it's translated to another $localize in the compilation process before the translations happen:

<div>{{title}}</div>

The other option is to omit the title and only use i18n in the template, which I find easier.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM