Skip to content

Commit

Permalink
dialog: translations
Browse files Browse the repository at this point in the history
  • Loading branch information
sirpengi committed Sep 25, 2023
1 parent 8b94b29 commit 634cd43
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
12 changes: 12 additions & 0 deletions assets/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,18 @@
"@actionSheetShare": {
"description": "Label for share button on action sheet."
},
"dialogButtonOK": "OK",
"@dialogButtonOK": {
"description": "Button label in generic dialogs to confirm."
},
"dialogButtonCancel": "Cancel",
"@dialogButtonCancel": {
"description": "Button label in generic dialogs to cancel."
},
"dialogButtonContinue": "Continue",
"@dialogButtonContinue": {
"description": "Button label in generic dialogs to continue."
},
"lightboxCopyLinkTooltip": "Copy link",
"@lightboxCopyLinkTooltip": {
"description": "Tooltip in lightbox for the copy link action."
Expand Down
10 changes: 6 additions & 4 deletions lib/widgets/dialog.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';

Widget _dialogActionText(String text) {
return Text(
Expand All @@ -14,12 +15,12 @@ Widget _dialogActionText(String text) {
);
}

// TODO(i18n): title, message, and action-button text
Future<void> showErrorDialog({
required BuildContext context,
required String title,
String? message,
}) {
final zulipLocalizations = ZulipLocalizations.of(context);
return showDialog(
context: context,
builder: (BuildContext context) => AlertDialog(
Expand All @@ -28,7 +29,7 @@ Future<void> showErrorDialog({
actions: [
TextButton(
onPressed: () => Navigator.pop(context),
child: _dialogActionText('OK')),
child: _dialogActionText(zulipLocalizations.dialogButtonOK)),
]));
}

Expand All @@ -39,6 +40,7 @@ void showSuggestedActionDialog({
required String? actionButtonText,
required VoidCallback onActionButtonPress,
}) {
final zulipLocalizations = ZulipLocalizations.of(context);
showDialog(
context: context,
builder: (BuildContext context) => AlertDialog(
Expand All @@ -47,9 +49,9 @@ void showSuggestedActionDialog({
actions: [
TextButton(
onPressed: () => Navigator.pop(context),
child: _dialogActionText('Cancel')),
child: _dialogActionText(zulipLocalizations.dialogButtonCancel)),
TextButton(
onPressed: onActionButtonPress,
child: _dialogActionText(actionButtonText ?? 'Continue')),
child: _dialogActionText(actionButtonText ?? zulipLocalizations.dialogButtonContinue)),
]));
}

0 comments on commit 634cd43

Please sign in to comment.