Since Angular 9 we can use
$localize`Hello ${name}:name:`
For i18n in typescript code. This still has some limitations as the ng xi18n
command does not detect the strings, but if these texts are added manually to the translation file it works.
The $localize
function is quite well documented in the JSDoc in the source, however it does not explain how to work with plurals. What I mean is something like this (pseudo-code):
$localize`Hello {${count}, plural, =1 {reader} other {readers}}`
Is this possible with $localize
? If yes: How? If no: How does Angular compile such expressions from HTML to TypeScript?
<span i18n>Updated {minutes, plural, =0 {just now} =1 {one minute ago} other {{{minutes}} minutes ago}}</span>
? Thats in the docs. Pretty similar to what you want – Disorder