From 395e62e96a37ad91d6224eb93e435a6472963f34 Mon Sep 17 00:00:00 2001 From: Christian Pauly Date: Sat, 13 Feb 2021 14:33:43 +0100 Subject: [PATCH] feat: localize bootstrap --- lib/components/dialogs/bootstrap_dialog.dart | 24 +++++----- lib/l10n/intl_en.arb | 50 ++++++++++++++++++++ lib/views/settings.dart | 3 +- lib/views/settings_style.dart | 2 +- 4 files changed, 63 insertions(+), 16 deletions(-) diff --git a/lib/components/dialogs/bootstrap_dialog.dart b/lib/components/dialogs/bootstrap_dialog.dart index 80119066..09be1fa9 100644 --- a/lib/components/dialogs/bootstrap_dialog.dart +++ b/lib/components/dialogs/bootstrap_dialog.dart @@ -66,9 +66,8 @@ class _BootstrapDialogState extends State { titleText = widget.l10n.loadingPleaseWait; if (bootstrap == null) { - titleText = 'Chat backup'; - body = Text( - 'To make sure that only you have access to your encrypted messages, we have generated a security key for you.'); + titleText = widget.l10n.chatBackup; + body = Text(widget.l10n.chatBackupDescription); buttons.add(AdaptiveFlatButton( child: Text(widget.l10n.next), onPressed: () => _createBootstrap(false), @@ -76,7 +75,7 @@ class _BootstrapDialogState extends State { } else if (bootstrap.newSsssKey?.recoveryKey != null && _recoveryKeyStored == false) { final key = bootstrap.newSsssKey.recoveryKey; - titleText = 'Security key'; + titleText = widget.l10n.securityKey; body = Container( alignment: Alignment.center, width: 200, @@ -91,7 +90,7 @@ class _BootstrapDialogState extends State { ), ); buttons.add(AdaptiveFlatButton( - child: Text('Copy to clipboard'), + child: Text(widget.l10n.copyToClipboard), onPressed: () => Clipboard.setData(ClipboardData(text: key)), )); buttons.add(AdaptiveFlatButton( @@ -122,7 +121,7 @@ class _BootstrapDialogState extends State { case BootstrapState.openExistingSsss: _recoveryKeyStored = true; titleText = - _recoveryKeyInputError ?? 'Please enter your security key!'; + _recoveryKeyInputError ?? widget.l10n.pleaseEnterSecurityKey; body = PlatformInfos.isCupertinoStyle ? CupertinoTextField( minLines: 2, @@ -151,9 +150,8 @@ class _BootstrapDialogState extends State { if (OkCancelResult.ok == await showOkCancelAlertDialog( context: context, - title: 'Lost security key', - message: - 'Wipe your chat backup to create a new security key?', + title: widget.l10n.securityKeyLost, + message: widget.l10n.wipeChatBackup, isDestructiveAction: true, )) { _createBootstrap(true); @@ -161,7 +159,7 @@ class _BootstrapDialogState extends State { }, )); buttons.add(AdaptiveFlatButton( - child: Text('Transfer from another device'), + child: Text(widget.l10n.transferFromAnotherDevice), onPressed: () async { final req = await widget .client.userDeviceKeys[widget.client.userID] @@ -202,7 +200,7 @@ class _BootstrapDialogState extends State { } catch (e, s) { Logs().w('Unable to unlock SSSS', e, s); setState(() => _recoveryKeyInputError = - L10n.of(context).oopsSomethingWentWrong); + widget.l10n.oopsSomethingWentWrong); } finally { setState(() => _recoveryKeyInputLoading = false); } @@ -247,11 +245,11 @@ class _BootstrapDialogState extends State { )); break; case BootstrapState.done: - titleText = 'Process completed'; + titleText = L10n.of(context).everythingReady; body = ListTile( contentPadding: EdgeInsets.zero, leading: Icon(Icons.check_circle, color: Colors.green), - title: Text('Chat backup has been initialized!'), + title: Text(L10n.of(context).keysCached), ); buttons.add(AdaptiveFlatButton( child: Text(widget.l10n.close), diff --git a/lib/l10n/intl_en.arb b/lib/l10n/intl_en.arb index e0f28b09..895ebd5e 100644 --- a/lib/l10n/intl_en.arb +++ b/lib/l10n/intl_en.arb @@ -404,11 +404,21 @@ "type": "text", "placeholders": {} }, + "securityKey": "Security key", + "@securityKey": { + "type": "text", + "placeholders": {} + }, "copy": "Copy", "@copy": { "type": "text", "placeholders": {} }, + "copyToClipboard": "Copy to clipboard", + "@copyToClipboard": { + "type": "text", + "placeholders": {} + }, "couldNotDecryptMessage": "Could not decrypt message: {error}", "@couldNotDecryptMessage": { "type": "text", @@ -438,6 +448,36 @@ "type": "text", "placeholders": {} }, + "chatBackup": "Chat backup", + "@chatBackup": { + "type": "text", + "placeholders": {} + }, + "securityKeyLost": "Security key lost?", + "@securityKeyLost": { + "type": "text", + "placeholders": {} + }, + "everythingReady": "Everything ready!", + "@everythingReady": { + "type": "text", + "placeholders": {} + }, + "transferFromAnotherDevice": "Transfer from another device", + "@transferFromAnotherDevice": { + "type": "text", + "placeholders": {} + }, + "pleaseEnterSecurityKey": "Please enter your security key", + "@pleaseEnterSecurityKey": { + "type": "text", + "placeholders": {} + }, + "chatBackupDescription": "Your chat backup is secured with a security key. Please make sure you don't lose it.", + "@chatBackupDescription": { + "type": "text", + "placeholders": {} + }, "createAccountNow": "Create account now", "@createAccountNow": { "type": "text", @@ -2107,6 +2147,16 @@ "type": "text", "placeholders": {} }, + "fontSize": "Font size", + "@fontSize": { + "type": "text", + "placeholders": {} + }, + "wipeChatBackup": "Wipe your chat backup to create a new security key?", + "@wipeChatBackup": { + "type": "text", + "placeholders": {} + }, "userUnknownVerification": "User has an unknown verification status", "@userUnknownVerification": { "type": "text", diff --git a/lib/views/settings.dart b/lib/views/settings.dart index 1734cfaf..867d2b63 100644 --- a/lib/views/settings.dart +++ b/lib/views/settings.dart @@ -510,8 +510,7 @@ class _SettingsState extends State { await showOkCancelAlertDialog( context: context, title: L10n.of(context).keysCached, - message: - 'Wipe your chat backup to create a new security key?', + message: L10n.of(context).wipeChatBackup, isDestructiveAction: true, )) { return BootstrapDialog( diff --git a/lib/views/settings_style.dart b/lib/views/settings_style.dart index 11f46936..6a7c7ed5 100644 --- a/lib/views/settings_style.dart +++ b/lib/views/settings_style.dart @@ -109,7 +109,7 @@ class _SettingsStyleState extends State { Divider(height: 1), ListTile( title: Text( - 'Font size', + L10n.of(context).fontSize, style: TextStyle( color: Theme.of(context).accentColor, fontWeight: FontWeight.bold,