This repository was archived by the owner on Nov 18, 2024. It is now read-only.
Repository navigation
Possible to have fbt.param inside fbt.plural? #196
Answered
by
jrwats
alexandernanberg
asked this question in
Q&A
|
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 |
Answered by
jrwats
Mar 13, 2021
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', ...);
} |
0 replies
Answer selected by
alexandernanberg
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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