@@ -44,18 +44,19 @@ abstract class MessageActionSheetMenuItemButton extends StatelessWidget {
44
44
}) : assert (messageListContext.findAncestorWidgetOfExactType <MessageListPage >() != null );
45
45
46
46
IconData get icon;
47
- String get label;
47
+ String Function ( ZulipLocalizations ) get label;
48
48
void Function (BuildContext ) get onPressed;
49
49
50
50
final Message message;
51
51
final BuildContext messageListContext;
52
52
53
53
@override
54
54
Widget build (BuildContext context) {
55
+ final zulipLocalizations = ZulipLocalizations .of (context);
55
56
return MenuItemButton (
56
57
leadingIcon: Icon (icon),
57
58
onPressed: () => onPressed (context),
58
- child: Text (label));
59
+ child: Text (label (zulipLocalizations) ));
59
60
}
60
61
}
61
62
@@ -68,7 +69,9 @@ class ShareButton extends MessageActionSheetMenuItemButton {
68
69
69
70
@override get icon => Icons .adaptive.share;
70
71
71
- @override get label => 'Share' ;
72
+ @override get label => (ZulipLocalizations zulipLocalizations) {
73
+ return zulipLocalizations.actionSheetOptionShare;
74
+ };
72
75
73
76
@override get onPressed => (BuildContext context) async {
74
77
// Close the message action sheet; we're about to show the share
@@ -112,7 +115,7 @@ Future<String?> fetchRawContentWithFeedback({
112
115
applyMarkdown: false ,
113
116
);
114
117
if (fetchedMessage == null ) {
115
- errorMessage = 'That message does not seem to exist.' ;
118
+ errorMessage = zulipLocalizations.errorMessageDoesNotSeemToExist ;
116
119
}
117
120
} catch (e) {
118
121
switch (e) {
@@ -121,7 +124,7 @@ Future<String?> fetchRawContentWithFeedback({
121
124
// TODO specific messages for common errors, like network errors
122
125
// (support with reusable code)
123
126
default :
124
- errorMessage = 'Could not fetch message source.' ;
127
+ errorMessage = zulipLocalizations.errorCouldNotFetchMessageSource ;
125
128
}
126
129
}
127
130
@@ -148,12 +151,15 @@ class QuoteAndReplyButton extends MessageActionSheetMenuItemButton {
148
151
149
152
@override get icon => Icons .format_quote_outlined;
150
153
151
- @override get label => 'Quote and reply' ;
154
+ @override get label => (ZulipLocalizations zulipLocalizations) {
155
+ return zulipLocalizations.actionSheetOptionQuoteAndReply;
156
+ };
152
157
153
158
@override get onPressed => (BuildContext bottomSheetContext) async {
154
159
// Close the message action sheet. We'll show the request progress
155
160
// in the compose-box content input with a "[Quoting…]" placeholder.
156
161
Navigator .of (bottomSheetContext).pop ();
162
+ final zulipLocalizations = ZulipLocalizations .of (messageListContext);
157
163
158
164
// This will be null only if the compose box disappeared after the
159
165
// message action sheet opened, and before "Quote and reply" was pressed.
@@ -176,7 +182,7 @@ class QuoteAndReplyButton extends MessageActionSheetMenuItemButton {
176
182
final rawContent = await fetchRawContentWithFeedback (
177
183
context: messageListContext,
178
184
messageId: message.id,
179
- errorDialogTitle: 'Quotation failed' ,
185
+ errorDialogTitle: zulipLocalizations.errorQuotationFailed ,
180
186
);
181
187
182
188
if (! messageListContext.mounted) return ;
@@ -205,26 +211,29 @@ class CopyButton extends MessageActionSheetMenuItemButton {
205
211
206
212
@override get icon => Icons .copy;
207
213
208
- @override get label => 'Copy message text' ;
214
+ @override get label => (ZulipLocalizations zulipLocalizations) {
215
+ return zulipLocalizations.actionSheetOptionCopy;
216
+ };
209
217
210
218
@override get onPressed => (BuildContext context) async {
211
219
// Close the message action sheet. We won't be showing request progress,
212
220
// but hopefully it won't take long at all, and
213
221
// fetchRawContentWithFeedback has a TODO for giving feedback if it does.
214
222
Navigator .of (context).pop ();
223
+ final zulipLocalizations = ZulipLocalizations .of (messageListContext);
215
224
216
225
final rawContent = await fetchRawContentWithFeedback (
217
226
context: messageListContext,
218
227
messageId: message.id,
219
- errorDialogTitle: 'Copying failed' ,
228
+ errorDialogTitle: zulipLocalizations.errorCopyingFailed ,
220
229
);
221
230
222
231
if (rawContent == null ) return ;
223
232
224
233
if (! messageListContext.mounted) return ;
225
234
226
- // TODO(i18n)
227
- copyWithPopup (context : context, successContent: const Text ('Message copied' ),
235
+ copyWithPopup (context : context,
236
+ successContent: Text (zulipLocalizations.successMessageCopied ),
228
237
data: ClipboardData (text: rawContent));
229
238
};
230
239
}
0 commit comments