Skip to content

Commit d2d7dfc

Browse files
committed
inbox: Support localizable header titles
Signed-off-by: Zixuan James Li <[email protected]>
1 parent 6026af2 commit d2d7dfc

10 files changed

+98
-10
lines changed

assets/l10n/app_en.arb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,18 @@
618618
"numOthers": {"type": "int", "example": "4"}
619619
}
620620
},
621+
"pinnedSubscriptionsLabel": "Pinned",
622+
"@pinnedSubscriptionsLabel": {
623+
"description": "Label for the list of pinned subscribed channels."
624+
},
625+
"unpinnedSubscriptionsLabel": "Unpinned",
626+
"@unpinnedSubscriptionsLabel": {
627+
"description": "Label for the list of unpinned subscribed channels."
628+
},
629+
"noSubscriptions": "No channels found",
630+
"@noSubscriptions": {
631+
"description": "Text to display when there are no subscribed channels."
632+
},
621633
"notifSelfUser": "You",
622634
"@notifSelfUser": {
623635
"description": "Display name for the user themself, to show after replying in an Android notification"

lib/generated/l10n/zulip_localizations.dart

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -931,6 +931,24 @@ abstract class ZulipLocalizations {
931931
/// **'{senderFullName} to you and {numOthers, plural, =1{1 other} other{{numOthers} others}}'**
932932
String notifGroupDmConversationLabel(String senderFullName, int numOthers);
933933

934+
/// Label for the list of pinned subscribed channels.
935+
///
936+
/// In en, this message translates to:
937+
/// **'Pinned'**
938+
String get pinnedSubscriptionsLabel;
939+
940+
/// Label for the list of unpinned subscribed channels.
941+
///
942+
/// In en, this message translates to:
943+
/// **'Unpinned'**
944+
String get unpinnedSubscriptionsLabel;
945+
946+
/// Text to display when there are no subscribed channels.
947+
///
948+
/// In en, this message translates to:
949+
/// **'No channels found'**
950+
String get noSubscriptions;
951+
934952
/// Display name for the user themself, to show after replying in an Android notification
935953
///
936954
/// In en, this message translates to:

lib/generated/l10n/zulip_localizations_ar.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,15 @@ class ZulipLocalizationsAr extends ZulipLocalizations {
492492
return '$senderFullName to you and $_temp0';
493493
}
494494

495+
@override
496+
String get pinnedSubscriptionsLabel => 'Pinned';
497+
498+
@override
499+
String get unpinnedSubscriptionsLabel => 'Unpinned';
500+
501+
@override
502+
String get noSubscriptions => 'No channels found';
503+
495504
@override
496505
String get notifSelfUser => 'You';
497506

lib/generated/l10n/zulip_localizations_en.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,15 @@ class ZulipLocalizationsEn extends ZulipLocalizations {
492492
return '$senderFullName to you and $_temp0';
493493
}
494494

495+
@override
496+
String get pinnedSubscriptionsLabel => 'Pinned';
497+
498+
@override
499+
String get unpinnedSubscriptionsLabel => 'Unpinned';
500+
501+
@override
502+
String get noSubscriptions => 'No channels found';
503+
495504
@override
496505
String get notifSelfUser => 'You';
497506

lib/generated/l10n/zulip_localizations_fr.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,15 @@ class ZulipLocalizationsFr extends ZulipLocalizations {
492492
return '$senderFullName to you and $_temp0';
493493
}
494494

495+
@override
496+
String get pinnedSubscriptionsLabel => 'Pinned';
497+
498+
@override
499+
String get unpinnedSubscriptionsLabel => 'Unpinned';
500+
501+
@override
502+
String get noSubscriptions => 'No channels found';
503+
495504
@override
496505
String get notifSelfUser => 'You';
497506

lib/generated/l10n/zulip_localizations_ja.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,15 @@ class ZulipLocalizationsJa extends ZulipLocalizations {
492492
return '$senderFullName to you and $_temp0';
493493
}
494494

495+
@override
496+
String get pinnedSubscriptionsLabel => 'Pinned';
497+
498+
@override
499+
String get unpinnedSubscriptionsLabel => 'Unpinned';
500+
501+
@override
502+
String get noSubscriptions => 'No channels found';
503+
495504
@override
496505
String get notifSelfUser => 'You';
497506

lib/generated/l10n/zulip_localizations_pl.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,15 @@ class ZulipLocalizationsPl extends ZulipLocalizations {
492492
return '$senderFullName do ciebie i $_temp0';
493493
}
494494

495+
@override
496+
String get pinnedSubscriptionsLabel => 'Pinned';
497+
498+
@override
499+
String get unpinnedSubscriptionsLabel => 'Unpinned';
500+
501+
@override
502+
String get noSubscriptions => 'No channels found';
503+
495504
@override
496505
String get notifSelfUser => 'Ty';
497506

lib/generated/l10n/zulip_localizations_ru.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,15 @@ class ZulipLocalizationsRu extends ZulipLocalizations {
492492
return '$senderFullName to you and $_temp0';
493493
}
494494

495+
@override
496+
String get pinnedSubscriptionsLabel => 'Pinned';
497+
498+
@override
499+
String get unpinnedSubscriptionsLabel => 'Unpinned';
500+
501+
@override
502+
String get noSubscriptions => 'No channels found';
503+
495504
@override
496505
String get notifSelfUser => 'You';
497506

lib/widgets/inbox.dart

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import 'package:flutter/material.dart';
22

33
import '../api/model/model.dart';
4+
import '../generated/l10n/zulip_localizations.dart';
45
import '../model/narrow.dart';
56
import '../model/recent_dm_conversations.dart';
67
import '../model/unreads.dart';
@@ -218,7 +219,7 @@ abstract class _HeaderItem extends StatelessWidget {
218219
required this.sectionContext,
219220
});
220221

221-
String get title;
222+
String title(ZulipLocalizations zulipLocalizations);
222223
IconData get icon;
223224
Color collapsedIconColor(BuildContext context);
224225
Color uncollapsedIconColor(BuildContext context);
@@ -238,6 +239,7 @@ abstract class _HeaderItem extends StatelessWidget {
238239

239240
@override
240241
Widget build(BuildContext context) {
242+
final zulipLocalizations = ZulipLocalizations.of(context);
241243
final designVariables = DesignVariables.of(context);
242244
return Material(
243245
color: collapsed
@@ -272,7 +274,7 @@ abstract class _HeaderItem extends StatelessWidget {
272274
).merge(weightVariableTextStyle(context, wght: 600)),
273275
maxLines: 1,
274276
overflow: TextOverflow.ellipsis,
275-
title))),
277+
title(zulipLocalizations)))),
276278
const SizedBox(width: 12),
277279
if (hasMention) const _IconMarker(icon: ZulipIcons.at_sign),
278280
Padding(padding: const EdgeInsetsDirectional.only(end: 16),
@@ -293,7 +295,8 @@ class _AllDmsHeaderItem extends _HeaderItem {
293295
required super.sectionContext,
294296
});
295297

296-
@override String get title => 'Direct messages'; // TODO(i18n)
298+
@override String title(ZulipLocalizations zulipLocalizations) =>
299+
zulipLocalizations.recentDmConversationsPageTitle;
297300
@override IconData get icon => ZulipIcons.user;
298301

299302
// TODO(design) check if this is the right variable for these
@@ -417,7 +420,8 @@ class _StreamHeaderItem extends _HeaderItem {
417420
required super.sectionContext,
418421
});
419422

420-
@override String get title => subscription.name;
423+
@override String title(ZulipLocalizations zulipLocalizations) =>
424+
subscription.name;
421425
@override IconData get icon => iconDataForStream(subscription);
422426
@override Color collapsedIconColor(context) =>
423427
colorSwatchFor(context, subscription).iconOnPlainBackground;

lib/widgets/subscription_list.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import 'package:flutter/material.dart';
22

33
import '../api/model/model.dart';
4+
import '../generated/l10n/zulip_localizations.dart';
45
import '../model/narrow.dart';
56
import '../model/unreads.dart';
67
import 'icons.dart';
@@ -65,10 +66,8 @@ class _SubscriptionListPageBodyState extends State<SubscriptionListPageBody> wit
6566

6667
// TODO: Implement collapsible topics
6768

68-
// TODO(i18n): localize strings on page
69-
// Strings here left unlocalized as they likely will not
70-
// exist in the settled design.
7169
final store = PerAccountStoreWidget.of(context);
70+
final zulipLocalizations = ZulipLocalizations.of(context);
7271

7372
final List<Subscription> pinned = [];
7473
final List<Subscription> unpinned = [];
@@ -90,11 +89,11 @@ class _SubscriptionListPageBodyState extends State<SubscriptionListPageBody> wit
9089
if (pinned.isEmpty && unpinned.isEmpty)
9190
const _NoSubscriptionsItem(),
9291
if (pinned.isNotEmpty) ...[
93-
const _SubscriptionListHeader(label: "Pinned"),
92+
_SubscriptionListHeader(label: zulipLocalizations.pinnedSubscriptionsLabel),
9493
_SubscriptionList(unreadsModel: unreadsModel, subscriptions: pinned),
9594
],
9695
if (unpinned.isNotEmpty) ...[
97-
const _SubscriptionListHeader(label: "Unpinned"),
96+
_SubscriptionListHeader(label: zulipLocalizations.unpinnedSubscriptionsLabel),
9897
_SubscriptionList(unreadsModel: unreadsModel, subscriptions: unpinned),
9998
],
10099

@@ -112,11 +111,12 @@ class _NoSubscriptionsItem extends StatelessWidget {
112111
@override
113112
Widget build(BuildContext context) {
114113
final designVariables = DesignVariables.of(context);
114+
final zulipLocalizations = ZulipLocalizations.of(context);
115115

116116
return SliverToBoxAdapter(
117117
child: Padding(
118118
padding: const EdgeInsets.all(10),
119-
child: Text("No channels found",
119+
child: Text(zulipLocalizations.noSubscriptions,
120120
textAlign: TextAlign.center,
121121
style: TextStyle(
122122
color: designVariables.subscriptionListHeaderText,

0 commit comments

Comments
 (0)