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 11, 2025
1 parent c02d947 commit 076d845
Show file tree
Hide file tree
Showing 5 changed files with 549 additions and 536 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
Loading

0 comments on commit 076d845

Please sign in to comment.