Skip to content

Commit

Permalink
i18n: Use translation for "(unknown users)"
Browse files Browse the repository at this point in the history
  • Loading branch information
mofirojean committed Jan 6, 2025
1 parent c02d947 commit 97b7ff4
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 7 deletions.
4 changes: 3 additions & 1 deletion lib/widgets/emoji_reaction.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/zulip_localizations.dart';

import '../api/exception.dart';
import '../api/model/model.dart';
Expand Down Expand Up @@ -149,6 +150,7 @@ class ReactionChip extends StatelessWidget {
@override
Widget build(BuildContext context) {
final store = PerAccountStoreWidget.of(context);
final zulipLocalizations = ZulipLocalizations.of(context);

final reactionType = reactionWithVotes.reactionType;
final emojiCode = reactionWithVotes.emojiCode;
Expand All @@ -163,7 +165,7 @@ class ReactionChip extends StatelessWidget {
? userIds.map((id) {
return id == store.selfUserId
? 'You'
: store.users[id]?.fullName ?? '(unknown user)'; // TODO(i18n)
: store.users[id]?.fullName ?? zulipLocalizations.unknownUserName;
}).join(', ')
: userIds.length.toString();

Expand Down
8 changes: 6 additions & 2 deletions lib/widgets/inbox.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/zulip_localizations.dart';

import '../api/model/model.dart';
import '../model/narrow.dart';
Expand Down Expand Up @@ -360,18 +361,21 @@ class _DmItem extends StatelessWidget {
@override
Widget build(BuildContext context) {
final store = PerAccountStoreWidget.of(context);
final zulipLocalizations = ZulipLocalizations.of(context);
final selfUser = store.users[store.selfUserId]!;

final designVariables = DesignVariables.of(context);

final title = switch (narrow.otherRecipientIds) { // TODO dedupe with [RecentDmConversationsItem]
[] => selfUser.fullName,
[var otherUserId] => store.users[otherUserId]?.fullName ?? '(unknown user)',
[var otherUserId] => store.users[otherUserId]?.fullName ?? zulipLocalizations.unknownUserName,

// TODO(i18n): List formatting, like you can do in JavaScript:
// new Intl.ListFormat('ja').format(['Chris', 'Greg', 'Alya', 'Shu'])
// // 'Chris、Greg、Alya、Shu'
_ => narrow.otherRecipientIds.map((id) => store.users[id]?.fullName ?? '(unknown user)').join(', '),
_ => narrow.otherRecipientIds.map((id) =>
store.users[id]?.fullName ?? zulipLocalizations.unknownUserName
).join(', '),
};

return Material(
Expand Down
6 changes: 5 additions & 1 deletion lib/widgets/message_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'dart:math';
import 'package:collection/collection.dart';
import 'package:flutter/material.dart';
import 'package:flutter_color_models/flutter_color_models.dart';
import 'package:flutter_gen/gen_l10n/zulip_localizations.dart';
import 'package:intl/intl.dart';

import '../api/model/model.dart';
Expand Down Expand Up @@ -316,6 +317,7 @@ class MessageListAppBarTitle extends StatelessWidget {

Widget _buildStreamRow(BuildContext context, {
ZulipStream? stream,
required String text,
}) {
// A null [Icon.icon] makes a blank space.
final icon = stream != null ? iconDataForStream(stream) : null;
Expand Down Expand Up @@ -422,7 +424,8 @@ class MessageListAppBarTitle extends StatelessWidget {
if (otherRecipientIds.isEmpty) {
return const Text("DMs with yourself");
} else {
final names = otherRecipientIds.map((id) => store.users[id]?.fullName ?? '(unknown user)');
final names = otherRecipientIds.map((id) =>
store.users[id]?.fullName ?? zulipLocalizations.unknownUserName);
return Text("DMs with ${names.join(", ")}"); // TODO show avatars
}
}
Expand Down Expand Up @@ -1049,6 +1052,7 @@ class StreamMessageRecipientHeader extends StatelessWidget {
streamWidget = const SizedBox(width: 16);
} else {
final stream = store.streams[message.streamId];
// TODO(i18n): provide translations for 'unknown channel'
final streamName = stream?.name
?? message.displayRecipient
?? '(unknown channel)'; // TODO(log)
Expand Down
3 changes: 2 additions & 1 deletion lib/widgets/profile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,9 @@ class _UserWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
final store = PerAccountStoreWidget.of(context);
final zulipLocalizations = ZulipLocalizations.of(context);
final user = store.users[userId];
final fullName = user?.fullName ?? '(unknown user)';
final fullName = user?.fullName ?? zulipLocalizations.unknownUserName;
return InkWell(
onTap: () => Navigator.push(context,
ProfilePage.buildRoute(context: context,
Expand Down
7 changes: 5 additions & 2 deletions lib/widgets/recent_dm_conversations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class RecentDmConversationsItem extends StatelessWidget {
Widget build(BuildContext context) {
final store = PerAccountStoreWidget.of(context);
final selfUser = store.users[store.selfUserId]!;
final zulipLocalizations = ZulipLocalizations.of(context);

final designVariables = DesignVariables.of(context);

Expand All @@ -94,13 +95,15 @@ class RecentDmConversationsItem extends StatelessWidget {
// (should we offer a "spam folder" style summary screen of recent
// 1:1 DM conversations from muted users?)
final otherUser = store.users[otherUserId];
title = otherUser?.fullName ?? '(unknown user)';
title = otherUser?.fullName ?? zulipLocalizations.unknownUserName;
avatar = AvatarImage(userId: otherUserId, size: _avatarSize);
default:
// TODO(i18n): List formatting, like you can do in JavaScript:
// new Intl.ListFormat('ja').format(['Chris', 'Greg', 'Alya'])
// // 'Chris、Greg、Alya'
title = narrow.otherRecipientIds.map((id) => store.users[id]?.fullName ?? '(unknown user)').join(', ');
title = narrow.otherRecipientIds.map((id) =>
store.users[id]?.fullName ?? zulipLocalizations.unknownUserName
).join(', ');
avatar = ColoredBox(color: designVariables.groupDmConversationIconBg,
child: Center(
child: Icon(color: designVariables.groupDmConversationIcon,
Expand Down

0 comments on commit 97b7ff4

Please sign in to comment.