From c16bef413f1c2c6144eca7220b18126d9007f320 Mon Sep 17 00:00:00 2001 From: "Louis Wicket (wil)" Date: Wed, 12 Apr 2023 09:50:18 +0000 Subject: [PATCH] [FIX] mail: adjusts member list separator to the locale MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Prior to this commit, the separator used to separate the names of the members of a group DM could not be translated. This is because the string being translated is too short to be considered by the translation system. This commit fixes the problem by no longer relying on the Odoo translation system and instead using the ECMAScript Internationalization API. closes odoo/odoo#118306 Signed-off-by: Alexandre Kühn (aku) --- addons/mail/static/src/core/thread_model.js | 10 +++++++--- .../static/tests/discuss/channel_invitation_tests.js | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/addons/mail/static/src/core/thread_model.js b/addons/mail/static/src/core/thread_model.js index 87ecbf7fe85..0cc15614208 100644 --- a/addons/mail/static/src/core/thread_model.js +++ b/addons/mail/static/src/core/thread_model.js @@ -214,9 +214,13 @@ export class Thread { ); } if (this.type === "group" && !this.name) { - return this.channelMembers - .map((channelMember) => channelMember.persona.name) - .join(_t(", ")); + const listFormatter = new Intl.ListFormat( + this._store.env.services["user"].lang.replace("_", "-"), + { type: "conjunction", style: "long" } + ); + return listFormatter.format( + this.channelMembers.map((channelMember) => channelMember.persona.name) + ); } return this.name; } diff --git a/addons/mail/static/tests/discuss/channel_invitation_tests.js b/addons/mail/static/tests/discuss/channel_invitation_tests.js index 522811a87c0..3b96b9f8c8f 100644 --- a/addons/mail/static/tests/discuss/channel_invitation_tests.js +++ b/addons/mail/static/tests/discuss/channel_invitation_tests.js @@ -111,6 +111,6 @@ QUnit.test("should be able to create a new group chat from an existing chat", as await click("button[title='Create Group Chat']"); assert.strictEqual( $(".o-mail-Discuss-threadName").val(), - "Mitchell Admin, TestPartner, TestPartner2" + "Mitchell Admin, TestPartner, and TestPartner2" ); });