The i18nSelect pipe

The i18nSelect pipe is similar to the i18nPlural pipe, but it evaluates a string value instead. This pipe is perfect for localizing text interpolations or providing distinct labels depending on state changes, for instance. For example, we could recap on our timer and serve the UI in different languages:

<button (click)="togglePause()">
{{ languageCode | i18nSelect:localizedLabelsMap }}
</button>

In our controller class, we can populate localizedLabelsMap, as follows:

export class TimerComponent {
languageCode: string ='fr';
localizedLabelsMap: any = {
'en' : 'Start timer',
'es' : 'Comenzar temporizador',
'fr' : 'Demarrer une sequence',
'other' : 'Start timer'
}
}

It is important to note that we can put this convenient pipe to use in use cases other than localizing components, but to provide string bindings depending on map keys and the like. Same as the i18nPlural pipe, when no matching value is found, the pipe will fall back to the mapping set with the 'other' key. 

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset