Skip to content

Commit c1622bc

Browse files
committed
compose: Add translations for attaching media to messages and related permission issues
1 parent 49df1b4 commit c1622bc

File tree

2 files changed

+35
-20
lines changed

2 files changed

+35
-20
lines changed

assets/l10n/app_en.arb

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,22 @@
2727
"@profileButtonSendDirectMessage": {
2828
"description": "Label for button in profile screen to navigate to DMs with the shown user."
2929
},
30-
"cameraAccessDeniedTitle": "Permissions needed",
31-
"@cameraAccessDeniedTitle": {
32-
"description": "Title for dialog when the user needs to grant permissions for camera access."
30+
"permissionsNeededTitle": "Permissions needed",
31+
"@permissionsNeededTitle": {
32+
"description": "Title for dialog when the user needs to grant additional permissions."
3333
},
34-
"cameraAccessDeniedMessage": "To upload an image, please grant Zulip additional permissions in Settings.",
35-
"@cameraAccessDeniedMessage": {
36-
"description": "Message for dialog when the user needs to grant permissions for camera access."
34+
"permissionsNeededOpenSettings": "Open settings",
35+
"@permissionsNeededOpenSettings": {
36+
"description": "Button label for permissions dialog button that opens the system settings screen."
3737
},
38-
"cameraAccessDeniedButtonText": "Open settings",
39-
"@cameraAccessDeniedButtonText": {
38+
"permissionsDeniedCameraAccess": "To upload an image, please grant Zulip additional permissions in Settings.",
39+
"@permissionsDeniedCameraAccess": {
4040
"description": "Message for dialog when the user needs to grant permissions for camera access."
4141
},
42+
"permissionsDeniedReadExternalStorage": "To upload files, please grant Zulip additional permissions in Settings.",
43+
"@permissionsDeniedReadExternalStorage": {
44+
"description": "Message for dialog when the user needs to grant permissions for external storage read access."
45+
},
4246
"actionSheetOptionCopy": "Copy message text",
4347
"@actionSheetOptionCopy": {
4448
"description": "Label for copy message text button on action sheet."
@@ -90,6 +94,10 @@
9094
"@errorLoginFailedTitle": {
9195
"description": "Error title for login when signing into a Zulip server fails."
9296
},
97+
"errorMessageNotSent": "Message not sent",
98+
"@errorMessageNotSent": {
99+
"description": "Error message for compose box when a message could not be sent."
100+
},
93101
"errorLoginCouldNotConnect": "Failed to connect to server:\n{url}",
94102
"@errorLoginCouldNotConnect": {
95103
"description": "Error message when the app could not connect to the server.",
@@ -159,6 +167,10 @@
159167
"@errorDialogContinue": {
160168
"description": "Button label in error dialogs to acknowledge error."
161169
},
170+
"errorDialogTitle": "Error",
171+
"@errorDialogTitle": {
172+
"description": "Generic title for error dialog."
173+
},
162174
"lightboxCopyLinkTooltip": "Copy link",
163175
"@lightboxCopyLinkTooltip": {
164176
"description": "Tooltip in lightbox for the copy link action."

lib/widgets/compose_box.dart

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -539,23 +539,25 @@ Future<Iterable<_File>> _getFilePickerFiles(BuildContext context, FileType type)
539539
.pickFiles(allowMultiple: true, withReadStream: true, type: type);
540540
} catch (e) {
541541
if (!context.mounted) return [];
542+
final zulipLocalizations = ZulipLocalizations.of(context);
542543
if (e is PlatformException && e.code == 'read_external_storage_denied') {
543544
// Observed on Android. If Android's error message tells us whether the
544545
// user has checked "Don't ask again", it seems the library doesn't pass
545546
// that on to us. So just always prompt to check permissions in settings.
546547
// If the user hasn't checked "Don't ask again", they can always dismiss
547548
// our prompt and retry, and the permissions request will reappear,
548549
// letting them grant permissions and complete the upload.
549-
showSuggestedActionDialog(context: context, // TODO(i18n)
550-
title: 'Permissions needed',
551-
message: 'To upload files, please grant Zulip additional permissions in Settings.',
552-
actionButtonText: 'Open settings',
550+
showSuggestedActionDialog(context: context,
551+
title: zulipLocalizations.permissionsNeededTitle,
552+
message: zulipLocalizations.permissionsDeniedReadExternalStorage,
553+
actionButtonText: zulipLocalizations.permissionsNeededOpenSettings,
553554
onActionButtonPress: () {
554555
AppSettings.openAppSettings();
555556
});
556557
} else {
557-
// TODO(i18n)
558-
showErrorDialog(context: context, title: 'Error', message: e.toString());
558+
showErrorDialog(context: context,
559+
title: zulipLocalizations.errorDialogTitle,
560+
message: e.toString());
559561
}
560562
return [];
561563
}
@@ -626,15 +628,16 @@ class _AttachFromCameraButton extends _AttachUploadsButton {
626628
// use a protected resource. After that, the only way the user can
627629
// grant it is in Settings.
628630
showSuggestedActionDialog(context: context,
629-
title: zulipLocalizations.cameraAccessDeniedTitle,
630-
message: zulipLocalizations.cameraAccessDeniedMessage,
631-
actionButtonText: zulipLocalizations.cameraAccessDeniedButtonText,
631+
title: zulipLocalizations.permissionsNeededTitle,
632+
message: zulipLocalizations.permissionsDeniedCameraAccess,
633+
actionButtonText: zulipLocalizations.permissionsNeededOpenSettings,
632634
onActionButtonPress: () {
633635
AppSettings.openAppSettings();
634636
});
635637
} else {
636-
// TODO(i18n)
637-
showErrorDialog(context: context, title: 'Error', message: e.toString());
638+
showErrorDialog(context: context,
639+
title: zulipLocalizations.errorDialogTitle,
640+
message: e.toString());
638641
}
639642
return [];
640643
}
@@ -712,7 +715,7 @@ class _SendButtonState extends State<_SendButton> {
712715
];
713716
showErrorDialog(
714717
context: context,
715-
title: 'Message not sent',
718+
title: zulipLocalizations.errorMessageNotSent,
716719
message: validationErrorMessages.join('\n\n'));
717720
return;
718721
}

0 commit comments

Comments
 (0)