Skip to content

Commit 44eab3e

Browse files
committed
msglist: Add translations for DM recipient header labels
1 parent bcdb4ab commit 44eab3e

File tree

3 files changed

+32
-10
lines changed

3 files changed

+32
-10
lines changed

assets/l10n/app_en.arb

+15
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,21 @@
194194
"filename": {"type": "String", "example": "file.txt"}
195195
}
196196
},
197+
"unknownUserName": "(unknown user)",
198+
"@unknownUserName": {
199+
"description": "Name placeholder to use for a user when we don't know their name."
200+
},
201+
"messageListGroupYouAndOthers": "You and {others}",
202+
"@messageListGroupYouAndOthers": {
203+
"description": "Message list recipient header for a DM group with others.",
204+
"placeholders": {
205+
"others": {"type": "String", "example": "Alice, Bob"}
206+
}
207+
},
208+
"messageListGroupYouWithYourself": "You with yourself",
209+
"@messageListGroupYouWithYourself": {
210+
"description": "Message list recipient header for a DM group that only includes yourself."
211+
},
197212
"contentValidationErrorTooLong": "Message length shouldn't be greater than 10000 characters.",
198213
"@contentValidationErrorTooLong": {
199214
"description": "Content validation error message when the message is too long."

lib/widgets/message_list.dart

+6-5
Original file line numberDiff line numberDiff line change
@@ -652,17 +652,18 @@ class DmRecipientHeader extends StatelessWidget {
652652

653653
@override
654654
Widget build(BuildContext context) {
655+
final zulipLocalizations = ZulipLocalizations.of(context);
655656
final store = PerAccountStoreWidget.of(context);
656657
final String title;
657658
if (message.allRecipientIds.length > 1) {
658-
final otherNames = message.allRecipientIds
659+
title = zulipLocalizations.messageListGroupYouAndOthers(message.allRecipientIds
659660
.where((id) => id != store.account.userId)
660-
.map((id) => store.users[id]?.fullName ?? '(unknown user)')
661+
.map((id) => store.users[id]?.fullName ?? zulipLocalizations.unknownUserName)
661662
.sorted()
662-
.join(", ");
663-
title = 'You and $otherNames';
663+
.join(", "));
664664
} else {
665-
title = 'You with yourself'; // TODO pick string; web has glitchy "You and $yourname"
665+
// TODO pick string; web has glitchy "You and $yourname"
666+
title = zulipLocalizations.messageListGroupYouWithYourself;
666667
}
667668

668669
return GestureDetector(

test/widgets/message_list_test.dart

+11-5
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,7 @@ void main() {
333333
});
334334

335335
testWidgets('show names on DMs', (tester) async {
336+
final zulipLocalizations = GlobalLocalizations.zulipLocalizations;
336337
await setupMessageListPage(tester, messages: [
337338
eg.dmMessage(from: eg.selfUser, to: []),
338339
eg.dmMessage(from: eg.otherUser, to: [eg.selfUser]),
@@ -341,20 +342,25 @@ void main() {
341342
store.addUser(eg.otherUser);
342343
store.addUser(eg.thirdUser);
343344
await tester.pump();
344-
tester.widget(find.text("You with yourself"));
345-
tester.widget(find.text("You and ${eg.otherUser.fullName}"));
346-
tester.widget(find.text("You and ${eg.otherUser.fullName}, ${eg.thirdUser.fullName}"));
345+
tester.widget(find.text(zulipLocalizations.messageListGroupYouWithYourself));
346+
tester.widget(find.text(zulipLocalizations.messageListGroupYouAndOthers(
347+
eg.otherUser.fullName)));
348+
tester.widget(find.text(zulipLocalizations.messageListGroupYouAndOthers(
349+
"${eg.otherUser.fullName}, ${eg.thirdUser.fullName}")));
347350
});
348351

349352
testWidgets('show names on DMs: smoothly handle unknown users', (tester) async {
353+
final zulipLocalizations = GlobalLocalizations.zulipLocalizations;
350354
await setupMessageListPage(tester, messages: [
351355
eg.dmMessage(from: eg.otherUser, to: [eg.selfUser]),
352356
eg.dmMessage(from: eg.thirdUser, to: [eg.selfUser, eg.otherUser]),
353357
]);
354358
store.addUser(eg.thirdUser);
355359
await tester.pump();
356-
tester.widget(find.text("You and (unknown user)"));
357-
tester.widget(find.text("You and (unknown user), ${eg.thirdUser.fullName}"));
360+
tester.widget(find.text(zulipLocalizations.messageListGroupYouAndOthers(
361+
zulipLocalizations.unknownUserName)));
362+
tester.widget(find.text(zulipLocalizations.messageListGroupYouAndOthers(
363+
"${zulipLocalizations.unknownUserName}, ${eg.thirdUser.fullName}")));
358364
});
359365

360366
testWidgets('show dates', (tester) async {

0 commit comments

Comments
 (0)