Generic selector that displays the string that matches the current value.
Pipe usage
{{ value_expression | i18nSelect:mapping }}API
class I18nSelectPipe implements PipeTransform {
transform(value: string | null | undefined, mapping: { [key: string]: string; }): string;
}
transform
string
@paramvalue
string | null | undefineda string to be internationalized.
@parammapping
{ [key: string]: string; }an object that indicates the text that should be displayed for different values of the provided value.
@returns
string
Description
Generic selector that displays the string that matches the current value.
If none of the keys of the mapping match the value, then the content of the other key is returned when present, otherwise an empty string is returned.
Exported by
Usage Notes
Example
@Component({
selector: 'i18n-select-pipe',
imports: [I18nSelectPipe],
template: `<div>{{ gender | i18nSelect: inviteMap }}</div>`,
})
export class I18nSelectPipeComponent {
gender: string = 'male';
inviteMap: any = {'male': 'Invite him.', 'female': 'Invite her.', 'other': 'Invite them.'};
}