compose_ui: Use Intl.ListFormat rather than .join(", ").

This commit changes .join(",") to Int1.ListFormat.
This produces more accurate translations.

Refactor compose_ui.test to update the testcase for Alice and Bob.
The previous test case output of "Alice,Bob"  modify to "Alice and Bob"
to align with the behavior of Int1.ListFormat,
which joins lists using ',' & 'and'.
This commit is contained in:
Rahul
2023-10-31 23:38:59 +05:30
committed by Tim Abbott
parent 76024e479d
commit 4dfb04d501
2 changed files with 8 additions and 7 deletions

View File

@@ -247,20 +247,20 @@ run_test("compute_placeholder_text", () => {
opts.private_message_recipient = "alice@zulip.com,bob@zulip.com";
assert.equal(
compose_ui.compute_placeholder_text(opts),
$t({defaultMessage: "Message Alice, Bob"}),
$t({defaultMessage: "Message Alice and Bob"}),
);
alice.is_guest = true;
page_params.realm_enable_guest_user_indicator = true;
assert.equal(
compose_ui.compute_placeholder_text(opts),
$t({defaultMessage: "Message translated: Alice (guest), Bob"}),
$t({defaultMessage: "Message translated: Alice (guest) and Bob"}),
);
page_params.realm_enable_guest_user_indicator = false;
assert.equal(
compose_ui.compute_placeholder_text(opts),
$t({defaultMessage: "Message Alice, Bob"}),
$t({defaultMessage: "Message Alice and Bob"}),
);
});