mirror of
https://github.com/zulip/zulip.git
synced 2025-11-10 08:56:10 +00:00
recent_topics: Use plural syntax to conditionally display text.
We can use this format to display text in plural form or not based on a number. This helps translators easily translate text and users get a better formatted text.
This commit is contained in:
@@ -256,8 +256,16 @@ function format_topic(topic_data) {
|
|||||||
// We display only 10 extra senders in tooltips,
|
// We display only 10 extra senders in tooltips,
|
||||||
// and just display remaining number of senders.
|
// and just display remaining number of senders.
|
||||||
const remaining_senders = extra_sender_ids.length - MAX_EXTRA_SENDERS;
|
const remaining_senders = extra_sender_ids.length - MAX_EXTRA_SENDERS;
|
||||||
|
// Pluralization syntax from:
|
||||||
|
// https://formatjs.io/docs/core-concepts/icu-syntax/#plural-format
|
||||||
displayed_other_names.push(
|
displayed_other_names.push(
|
||||||
$t({defaultMessage: `and {remaining_senders} other(s).`}, {remaining_senders}),
|
$t(
|
||||||
|
{
|
||||||
|
defaultMessage:
|
||||||
|
"and {remaining_senders, plural, one {1 other} other {# others}}.",
|
||||||
|
},
|
||||||
|
{remaining_senders},
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
const other_sender_names = displayed_other_names.join("<br/>");
|
const other_sender_names = displayed_other_names.join("<br/>");
|
||||||
|
|||||||
Reference in New Issue
Block a user