Possible to have fbt.param inside fbt.plural? #196
-
Hey! I have a case were I need a param inside a plural, not sure if anything like this is possible? Basically I want to print the name of the episode if singular, otherwise like regular plural. So
I've tried with 👇 but got an fbt(
fbt.plural(
fbt.param('episode name', relevantEpisodes[0].name) +
' was published',
relevantEpisodes.length + 1,
{
name: 'number of episodes',
showCount: 'ifMany',
many: 'episodes were published',
}
),
'Published episodes summary'
) I can bring out the
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Yeah fbt.plural is limited to static strings. Simplest would be to just use an if (count === 1) {
return fbt(fbt.param('name', ...) + 'was published', ...);
} else {
return fbt(fbt.param('count', count) + 'episodes were published', ...);
} |
Beta Was this translation helpful? Give feedback.
Yeah fbt.plural is limited to static strings. Simplest would be to just use an
if/else
. Some day... we'll support the parsing of ternaries which would enable you group this into one construct, but I'm not sure it'd be more readable than the below