Skip to content

Commit 0e6a710

Browse files
committed
msglist: Add translations for dm recipient header labels
1 parent d9effc9 commit 0e6a710

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+
"messageListGroupUnknownUser": "(unknown user)",
198+
"@messageListGroupUnknownUser": {
199+
"description": "Name placeholder to use for user when we don't know their name."
200+
},
201+
"messageListGroupYouAndOthers": "You and {others}",
202+
"@messageListGroupYouAndOthers": {
203+
"description": "Message list sticky 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 sticky 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
@@ -651,17 +651,18 @@ class DmRecipientHeader extends StatelessWidget {
651651

652652
@override
653653
Widget build(BuildContext context) {
654+
final zulipLocalizations = ZulipLocalizations.of(context);
654655
final store = PerAccountStoreWidget.of(context);
655656
final String title;
656657
if (message.allRecipientIds.length > 1) {
657-
final otherNames = message.allRecipientIds
658+
title = zulipLocalizations.messageListGroupYouAndOthers(message.allRecipientIds
658659
.where((id) => id != store.account.userId)
659-
.map((id) => store.users[id]?.fullName ?? '(unknown user)')
660+
.map((id) => store.users[id]?.fullName ?? zulipLocalizations.messageListGroupUnknownUser)
660661
.sorted()
661-
.join(", ");
662-
title = 'You and $otherNames';
662+
.join(", "));
663663
} else {
664-
title = 'You with yourself'; // TODO pick string; web has glitchy "You and $yourname"
664+
// TODO pick string; web has glitchy "You and $yourname"
665+
title = zulipLocalizations.messageListGroupYouWithYourself;
665666
}
666667

667668
return GestureDetector(

test/widgets/message_list_test.dart

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

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

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

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

0 commit comments

Comments
 (0)