From 49d6f995615e9c253ac8019eaec38249191d7335 Mon Sep 17 00:00:00 2001 From: Shu Chen Date: Tue, 26 Sep 2023 15:38:50 +0100 Subject: [PATCH] dialog: Translations --- assets/l10n/app_en.arb | 12 ++++++++++++ lib/widgets/dialog.dart | 10 ++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/assets/l10n/app_en.arb b/assets/l10n/app_en.arb index 7a33c18ff61..e8366bf1098 100644 --- a/assets/l10n/app_en.arb +++ b/assets/l10n/app_en.arb @@ -71,6 +71,18 @@ "@successMessageCopied": { "description": "Message when content of a message was copied to the users system clipboard." }, + "dialogCancel": "Cancel", + "@dialogCancel": { + "description": "Button label in dialogs to cancel." + }, + "dialogContinue": "Continue", + "@dialogContinue": { + "description": "Button label in dialogs to proceed." + }, + "errorDialogContinue": "OK", + "@errorDialogContinue": { + "description": "Button label in error dialogs to acknowledge error." + }, "subscribedToNStreams": "Subscribed to {num, plural, =0{no streams} =1{1 stream} other{{num} streams}}", "@subscribedToNStreams": { "description": "Test page label showing number of streams user is subscribed to.", diff --git a/lib/widgets/dialog.dart b/lib/widgets/dialog.dart index 985e7cd5f99..be2fca21f5c 100644 --- a/lib/widgets/dialog.dart +++ b/lib/widgets/dialog.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:flutter_gen/gen_l10n/zulip_localizations.dart'; Widget _dialogActionText(String text) { return Text( @@ -14,12 +15,12 @@ Widget _dialogActionText(String text) { ); } -// TODO(i18n): title, message, and action-button text Future showErrorDialog({ required BuildContext context, required String title, String? message, }) { + final zulipLocalizations = ZulipLocalizations.of(context); return showDialog( context: context, builder: (BuildContext context) => AlertDialog( @@ -28,7 +29,7 @@ Future showErrorDialog({ actions: [ TextButton( onPressed: () => Navigator.pop(context), - child: _dialogActionText('OK')), + child: _dialogActionText(zulipLocalizations.errorDialogContinue)), ])); } @@ -39,6 +40,7 @@ void showSuggestedActionDialog({ required String? actionButtonText, required VoidCallback onActionButtonPress, }) { + final zulipLocalizations = ZulipLocalizations.of(context); showDialog( context: context, builder: (BuildContext context) => AlertDialog( @@ -47,9 +49,9 @@ void showSuggestedActionDialog({ actions: [ TextButton( onPressed: () => Navigator.pop(context), - child: _dialogActionText('Cancel')), + child: _dialogActionText(zulipLocalizations.dialogCancel)), TextButton( onPressed: onActionButtonPress, - child: _dialogActionText(actionButtonText ?? 'Continue')), + child: _dialogActionText(actionButtonText ?? zulipLocalizations.dialogContinue)), ])); }