From ae0c5ffaef3f1b48ee2b5463aa62b58044c1b790 Mon Sep 17 00:00:00 2001 From: James Graham Date: Sun, 12 Nov 2023 14:08:36 +0000 Subject: [PATCH] Improve State Text Translatability Make the state state strings less ambiguous for the purpose of translation. BUG: 476358 --- src/models/messagefiltermodel.cpp | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/models/messagefiltermodel.cpp b/src/models/messagefiltermodel.cpp index 471b680b1..2935ccc60 100644 --- a/src/models/messagefiltermodel.cpp +++ b/src/models/messagefiltermodel.cpp @@ -117,35 +117,37 @@ QString MessageFilterModel::aggregateEventToString(int sourceRow) const chunks += QString(); int count = 1; auto part = parts.takeFirst(); - chunks.last() += part; while (!parts.isEmpty() && parts.first() == part) { parts.removeFirst(); count++; } - if (count > 1 && uniqueAuthors.length() == 1) { - chunks.last() += i18ncp("n times", " %1 time ", " %1 times ", count); - } + chunks.last() += i18ncp("%1: What's being done; %2: How often it is done.", " %1", " %1 %2 times", part, count); } chunks.removeDuplicates(); - QString text = QStringLiteral(""); // There can be links in the event text so make sure all are styled. // The author text is either "n users" if > 1 user or the matrix.to link to a single user. QString userText = uniqueAuthors.length() > 1 ? i18ncp("n users", " %1 user ", " %1 users ", uniqueAuthors.length()) : QStringLiteral("%3 ") .arg(uniqueAuthors[0].toMap()[QStringLiteral("id")].toString(), uniqueAuthors[0].toMap()[QStringLiteral("color")].toString(), uniqueAuthors[0].toMap()[QStringLiteral("displayName")].toString().toHtmlEscaped()); - text += userText; - text += chunks.takeFirst(); + QString chunksText; + chunksText += chunks.takeFirst(); if (chunks.size() > 0) { while (chunks.size() > 1) { - text += i18nc("[action 1], [action 2 and/or action 3]", ", "); - text += chunks.takeFirst(); + chunksText += i18nc("[action 1], [action 2 and/or action 3]", ", "); + chunksText += chunks.takeFirst(); } - text += uniqueAuthors.length() > 1 ? i18nc("[action 1, action 2] or [action 3]", " or ") : i18nc("[action 1, action 2] and [action 3]", " and "); - text += chunks.takeFirst(); + chunksText += + uniqueAuthors.length() > 1 ? i18nc("[action 1, action 2] or [action 3]", " or ") : i18nc("[action 1, action 2] and [action 3]", " and "); + chunksText += chunks.takeFirst(); } - return text; + return i18nc( + "userText (%1) is either a Matrix username if a single user sent all the states or n users if they were sent by multiple users." + "chunksText (%2) is a list of comma separated actions for each of the state events in the group.", + "%1 %2", + userText, + chunksText); } else { return {}; }