Skip to content

Commit 86753c1

Browse files
committed
action_sheet: translations
1 parent 3e20a17 commit 86753c1

File tree

2 files changed

+52
-11
lines changed

2 files changed

+52
-11
lines changed

assets/l10n/app_en.arb

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,38 @@
4343
"@cameraAccessDeniedButtonText": {
4444
"description": "Message for dialog when the user needs to grant permissions for camera access."
4545
},
46+
"actionSheetOptionCopy": "Copy message text",
47+
"@actionSheetOptionCopy": {
48+
"description": "Label for copy message text button on action sheet."
49+
},
50+
"actionSheetOptionShare": "Share",
51+
"@actionSheetOptionShare": {
52+
"description": "Label for share button on action sheet."
53+
},
54+
"actionSheetOptionQuoteAndReply": "Quote and reply",
55+
"@actionSheetOptionQuoteAndReply": {
56+
"description": "Label for Quote and reply button on action sheet."
57+
},
58+
"errorCouldNotFetchMessageSource": "Could not fetch message source",
59+
"@errorCouldNotFetchMessageSource": {
60+
"description": "Dialog message when the source of a message could not be fetched."
61+
},
62+
"errorCopyingFailed": "Copying failed",
63+
"@errorCopyingFailed": {
64+
"description": "Dialog message when copying the text of a message to the users system clipboard failed."
65+
},
66+
"errorMessageDoesNotSeemToExist": "That message does not seem to exist.",
67+
"@errorMessageDoesNotSeemToExist": {
68+
"description": "Dialog message in action sheet when loading a message that does not exist."
69+
},
70+
"errorQuotationFailed": "Quotation failed",
71+
"@errorQuotationFailed": {
72+
"description": "Error dialog message when quoting a message failed."
73+
},
74+
"successMessageCopied": "Message Copied",
75+
"@successMessageCopied": {
76+
"description": "Dialog message when content of a message was copied to the users system clipboard."
77+
},
4678
"subscribedToNStreams": "Subscribed to {num, plural, =0{no streams} =1{1 stream} other{{num} streams}}",
4779
"@subscribedToNStreams": {
4880
"description": "Test page label showing number of streams user is subscribed to.",

lib/widgets/action_sheet.dart

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,19 @@ abstract class MessageActionSheetMenuItemButton extends StatelessWidget {
4444
}) : assert(messageListContext.findAncestorWidgetOfExactType<MessageListPage>() != null);
4545

4646
IconData get icon;
47-
String get label;
47+
String Function(ZulipLocalizations) get label;
4848
void Function(BuildContext) get onPressed;
4949

5050
final Message message;
5151
final BuildContext messageListContext;
5252

5353
@override
5454
Widget build(BuildContext context) {
55+
final zulipLocalizations = ZulipLocalizations.of(context);
5556
return MenuItemButton(
5657
leadingIcon: Icon(icon),
5758
onPressed: () => onPressed(context),
58-
child: Text(label));
59+
child: Text(label(zulipLocalizations)));
5960
}
6061
}
6162

@@ -68,7 +69,9 @@ class ShareButton extends MessageActionSheetMenuItemButton {
6869

6970
@override get icon => Icons.adaptive.share;
7071

71-
@override get label => 'Share';
72+
@override get label => (ZulipLocalizations zulipLocalizations) {
73+
return zulipLocalizations.actionSheetOptionShare;
74+
};
7275

7376
@override get onPressed => (BuildContext context) async {
7477
// Close the message action sheet; we're about to show the share
@@ -112,7 +115,7 @@ Future<String?> fetchRawContentWithFeedback({
112115
applyMarkdown: false,
113116
);
114117
if (fetchedMessage == null) {
115-
errorMessage = 'That message does not seem to exist.';
118+
errorMessage = zulipLocalizations.errorMessageDoesNotSeemToExist;
116119
}
117120
} catch (e) {
118121
switch (e) {
@@ -121,7 +124,7 @@ Future<String?> fetchRawContentWithFeedback({
121124
// TODO specific messages for common errors, like network errors
122125
// (support with reusable code)
123126
default:
124-
errorMessage = 'Could not fetch message source.';
127+
errorMessage = zulipLocalizations.errorCouldNotFetchMessageSource;
125128
}
126129
}
127130

@@ -148,12 +151,15 @@ class QuoteAndReplyButton extends MessageActionSheetMenuItemButton {
148151

149152
@override get icon => Icons.format_quote_outlined;
150153

151-
@override get label => 'Quote and reply';
154+
@override get label => (ZulipLocalizations zulipLocalizations) {
155+
return zulipLocalizations.actionSheetOptionQuoteAndReply;
156+
};
152157

153158
@override get onPressed => (BuildContext bottomSheetContext) async {
154159
// Close the message action sheet. We'll show the request progress
155160
// in the compose-box content input with a "[Quoting…]" placeholder.
156161
Navigator.of(bottomSheetContext).pop();
162+
final zulipLocalizations = ZulipLocalizations.of(messageListContext);
157163

158164
// This will be null only if the compose box disappeared after the
159165
// message action sheet opened, and before "Quote and reply" was pressed.
@@ -176,7 +182,7 @@ class QuoteAndReplyButton extends MessageActionSheetMenuItemButton {
176182
final rawContent = await fetchRawContentWithFeedback(
177183
context: messageListContext,
178184
messageId: message.id,
179-
errorDialogTitle: 'Quotation failed',
185+
errorDialogTitle: zulipLocalizations.errorQuotationFailed,
180186
);
181187

182188
if (!messageListContext.mounted) return;
@@ -205,26 +211,29 @@ class CopyButton extends MessageActionSheetMenuItemButton {
205211

206212
@override get icon => Icons.copy;
207213

208-
@override get label => 'Copy message text';
214+
@override get label => (ZulipLocalizations zulipLocalizations) {
215+
return zulipLocalizations.actionSheetOptionCopy;
216+
};
209217

210218
@override get onPressed => (BuildContext context) async {
211219
// Close the message action sheet. We won't be showing request progress,
212220
// but hopefully it won't take long at all, and
213221
// fetchRawContentWithFeedback has a TODO for giving feedback if it does.
214222
Navigator.of(context).pop();
223+
final zulipLocalizations = ZulipLocalizations.of(messageListContext);
215224

216225
final rawContent = await fetchRawContentWithFeedback(
217226
context: messageListContext,
218227
messageId: message.id,
219-
errorDialogTitle: 'Copying failed',
228+
errorDialogTitle: zulipLocalizations.errorCopyingFailed,
220229
);
221230

222231
if (rawContent == null) return;
223232

224233
if (!messageListContext.mounted) return;
225234

226-
// TODO(i18n)
227-
copyWithPopup(context: context, successContent: const Text('Message copied'),
235+
copyWithPopup(context: context,
236+
successContent: Text(zulipLocalizations.successMessageCopied),
228237
data: ClipboardData(text: rawContent));
229238
};
230239
}

0 commit comments

Comments
 (0)