1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

How to use Angular i18n $localize with plurals?

Discussão em 'Angular' iniciado por yankee, Outubro 4, 2024 às 09:52.

  1. yankee

    yankee Guest

    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?

    Continue reading...

Compartilhe esta Página