From c42a03c9e287e80f4ae7ee0f41cfac1bf4a3d068 Mon Sep 17 00:00:00 2001 From: Dain Nilsson Date: Wed, 1 Mar 2023 10:30:32 +0100 Subject: [PATCH] USe parameterized strings for "foo: bar". --- lib/about_page.dart | 4 +- lib/fido/views/add_fingerprint_dialog.dart | 2 +- lib/fido/views/delete_credential_dialog.dart | 2 +- lib/fido/views/delete_fingerprint_dialog.dart | 2 +- lib/fido/views/pin_dialog.dart | 2 +- lib/fido/views/rename_fingerprint_dialog.dart | 2 +- lib/fido/views/reset_dialog.dart | 2 +- lib/l10n/app_en.arb | 70 ++++++++++++++++--- lib/oath/views/add_account_page.dart | 4 +- lib/oath/views/delete_account_dialog.dart | 2 +- lib/oath/views/rename_account_dialog.dart | 2 +- 11 files changed, 72 insertions(+), 22 deletions(-) diff --git a/lib/about_page.dart b/lib/about_page.dart index 125c1ffe..da7f3da4 100755 --- a/lib/about_page.dart +++ b/lib/about_page.dart @@ -216,8 +216,8 @@ class LoggingPanel extends ConsumerWidget { value: logLevel, items: Levels.LEVELS, selected: logLevel != Level.INFO, - labelBuilder: (value) => Text( - '${l10n.l_log_level}: ${value.name[0]}${value.name.substring(1).toLowerCase()}'), + labelBuilder: (value) => Text(l10n.l_log_level( + value.name[0] + value.name.substring(1).toLowerCase())), itemBuilder: (value) => Text('${value.name[0]}${value.name.substring(1).toLowerCase()}'), onChanged: (level) { diff --git a/lib/fido/views/add_fingerprint_dialog.dart b/lib/fido/views/add_fingerprint_dialog.dart index a1f01ad0..d97533b2 100755 --- a/lib/fido/views/add_fingerprint_dialog.dart +++ b/lib/fido/views/add_fingerprint_dialog.dart @@ -157,7 +157,7 @@ class _AddFingerprintDialogState extends ConsumerState } showMessage( context, - '${l10n.l_setting_name_failed}: $errorMessage', + l10n.l_setting_name_failed(errorMessage), duration: const Duration(seconds: 4), ); } diff --git a/lib/fido/views/delete_credential_dialog.dart b/lib/fido/views/delete_credential_dialog.dart index f126e64c..46d8d9a7 100755 --- a/lib/fido/views/delete_credential_dialog.dart +++ b/lib/fido/views/delete_credential_dialog.dart @@ -45,7 +45,7 @@ class DeleteCredentialDialog extends ConsumerWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text(l10n.p_warning_delete_credential), - Text('${l10n.w_credential}: $label'), + Text(l10n.l_credential(label)), ] .map((e) => Padding( child: e, diff --git a/lib/fido/views/delete_fingerprint_dialog.dart b/lib/fido/views/delete_fingerprint_dialog.dart index c1235f2e..18862984 100755 --- a/lib/fido/views/delete_fingerprint_dialog.dart +++ b/lib/fido/views/delete_fingerprint_dialog.dart @@ -57,7 +57,7 @@ class DeleteFingerprintDialog extends ConsumerWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text(l10n.l_warning_delete_fingerprint), - Text('${l10n.w_fingerprint}: $label'), + Text(l10n.l_fingerprint(label)), ] .map((e) => Padding( padding: const EdgeInsets.symmetric(vertical: 8.0), diff --git a/lib/fido/views/pin_dialog.dart b/lib/fido/views/pin_dialog.dart index 8985a36c..f78c3b7f 100755 --- a/lib/fido/views/pin_dialog.dart +++ b/lib/fido/views/pin_dialog.dart @@ -183,7 +183,7 @@ class _FidoPinDialogState extends ConsumerState { } showMessage( context, - '${l10n.l_set_pin_failed}: $errorMessage', + l10n.l_set_pin_failed(errorMessage), duration: const Duration(seconds: 4), ); } diff --git a/lib/fido/views/rename_fingerprint_dialog.dart b/lib/fido/views/rename_fingerprint_dialog.dart index 72066b11..28966e96 100755 --- a/lib/fido/views/rename_fingerprint_dialog.dart +++ b/lib/fido/views/rename_fingerprint_dialog.dart @@ -65,7 +65,7 @@ class _RenameAccountDialogState extends ConsumerState { } showMessage( context, - '${l10n.l_rename_fp_failed}: $errorMessage', + l10n.l_rename_fp_failed(errorMessage), duration: const Duration(seconds: 4), ); } diff --git a/lib/fido/views/reset_dialog.dart b/lib/fido/views/reset_dialog.dart index a06eb9b1..a9f72357 100755 --- a/lib/fido/views/reset_dialog.dart +++ b/lib/fido/views/reset_dialog.dart @@ -94,7 +94,7 @@ class _ResetDialogState extends ConsumerState { } showMessage( context, - '${l10n.l_reset_failed}: $errorMessage', + l10n.l_reset_failed(errorMessage), duration: const Duration(seconds: 4), ); }); diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index bf614331..80273eb3 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -45,7 +45,12 @@ "l_require_touch": "Require touch", "q_have_account_info": "Have account info?", "l_run_diagnostics": "Run diagnostics", - "l_log_level": "Log level", + "l_log_level": "Log level: {level}", + "@l_log_level": { + "placeholders": { + "level": {} + } + }, "l_character_count": "Character count", "l_learn_more": "Learn\u00a0more", @@ -147,7 +152,12 @@ } }, "l_pin_set": "PIN set", - "l_set_pin_failed": "Failed to set PIN", + "l_set_pin_failed": "Failed to set PIN: {message}", + "@l_set_pin_failed" : { + "placeholders": { + "message": {} + } + }, "l_wrong_pin_attempts_remaining": "Wrong PIN. {retries} attempt(s) remaining.", "@l_wrong_pin_attempts_remaining" : { "placeholders": { @@ -193,12 +203,22 @@ "p_enter_new_password": "Enter your new password. A password may contain letters, numbers and special characters.", "@_oath_accounts": {}, - "w_account": "Account", + "l_account": "Account: {label}", + "@l_account" : { + "placeholders": { + "label": {} + } + }, "w_accounts": "Accounts", "l_no_accounts": "No accounts", "l_add_account": "Add account", "l_account_added": "Account added", - "l_account_add_failed": "Failed adding account", + "l_account_add_failed": "Failed adding account: {message}", + "@l_account_add_failed" : { + "placeholders": { + "message": {} + } + }, "l_account_name_required": "Your account must have a name", "l_name_already_exists": "This name already exists for the Issuer", "l_invalid_character_issuer": "Invalid character: ':' is not allowed in issuer", @@ -238,7 +258,12 @@ "l_issuer_optional": "Issuer (optional)", "@_fido_credentials": {}, - "w_credential": "Credential", + "l_credential": "Credential: {label}", + "@l_credential" : { + "placeholders": { + "label": {} + } + }, "w_credentials": "Credentials", "l_ready_to_use": "Ready to use", "l_register_sk_on_websites": "Register as a Security Key on websites", @@ -248,11 +273,21 @@ "p_warning_delete_credential": "This will delete the credential from your YubiKey.", "@_fingerprints": {}, - "w_fingerprint": "Fingerprint", + "l_fingerprint": "Fingerprint: {label}", + "@l_fingerprint" : { + "placeholders": { + "label": {} + } + }, "w_fingerprints": "Fingerprints", "l_fingerprint_captured": "Fingerprint captured successfully!", "l_fingerprint_added": "Fingerprint added", - "l_setting_name_failed": "Error setting name", + "l_setting_name_failed": "Error setting name: {message}", + "@l_setting_name_failed" : { + "placeholders": { + "message": {} + } + }, "l_add_fingerprint": "Add fingerprint", "l_fp_step_1_capture": "Step 1/2: Capture fingerprint", "l_fp_step_2_name": "Step 2/2: Name fingerprint", @@ -263,7 +298,12 @@ "l_set_pin_fingerprints": "Set a PIN to register fingerprints", "l_no_fps_added": "No fingerprints have been added", "l_fingerprint_renamed": "Fingerprint renamed", - "l_rename_fp_failed": "Error renaming", + "l_rename_fp_failed": "Error renaming: {message}", + "@l_rename_fp_failed" : { + "placeholders": { + "message": {} + } + }, "l_rename_fp": "Rename fingerprint", "l_add_one_or_more_fps": "Add one or more (up to five) fingerprints", "l_fingerprints_used": "{used}/5 fingerprints registered", @@ -289,7 +329,12 @@ "l_qr_scanned": "Scanned QR code", "l_invalid_qr": "Invalid QR code", "l_qr_not_found": "No QR code found", - "l_qr_not_read": "Failed reading QR code", + "l_qr_not_read": "Failed reading QR code: {message}", + "@l_qr_not_read" : { + "placeholders": { + "message": {} + } + }, "l_point_camera_scan": "Point your camera at a QR code to scan it", "q_want_to_scan": "Would like to scan?", "q_no_qr": "No QR code?", @@ -304,7 +349,12 @@ "l_reset_fido": "Reset FIDO", "l_fido_app_reset": "FIDO application reset", "l_press_reset_to_begin": "Press reset to begin\u2026", - "l_reset_failed": "Error performing reset", + "l_reset_failed": "Error performing reset: {message}", + "@l_reset_failed" : { + "placeholders": { + "message": {} + } + }, "p_warning_factory_reset": "Warning! This will irrevocably delete all OATH TOTP/HOTP accounts from your YubiKey.", "p_warning_disable_credentials": "Your OATH credentials, as well as any password set, will be removed from this YubiKey. Make sure to first disable these from their respective web sites to avoid being locked out of your accounts.", "p_warning_deletes_accounts": "Warning! This will irrevocably delete all U2F and FIDO2 accounts from your YubiKey.", diff --git a/lib/oath/views/add_account_page.dart b/lib/oath/views/add_account_page.dart index 9479772c..fe1b904b 100755 --- a/lib/oath/views/add_account_page.dart +++ b/lib/oath/views/add_account_page.dart @@ -146,7 +146,7 @@ class _OathAddAccountPageState extends ConsumerState { if (e is! CancellationException) { showMessage( context, - '${l10n.l_qr_not_read}: $errorMessage', + l10n.l_qr_not_read(errorMessage), duration: const Duration(seconds: 4), ); } @@ -204,7 +204,7 @@ class _OathAddAccountPageState extends ConsumerState { } showMessage( context, - '${l10n.l_account_add_failed}: $errorMessage', + l10n.l_account_add_failed(errorMessage), duration: const Duration(seconds: 4), ); } diff --git a/lib/oath/views/delete_account_dialog.dart b/lib/oath/views/delete_account_dialog.dart index e53e30b8..b93a5add 100755 --- a/lib/oath/views/delete_account_dialog.dart +++ b/lib/oath/views/delete_account_dialog.dart @@ -69,7 +69,7 @@ class DeleteAccountDialog extends ConsumerWidget { l10n.p_warning_disable_credential, style: Theme.of(context).textTheme.bodyLarge, ), - Text('${l10n.w_account} ${getTextName(credential)}'), + Text(l10n.l_account(getTextName(credential))), ] .map((e) => Padding( padding: const EdgeInsets.symmetric(vertical: 8.0), diff --git a/lib/oath/views/rename_account_dialog.dart b/lib/oath/views/rename_account_dialog.dart index b1071fbd..4291ae1d 100755 --- a/lib/oath/views/rename_account_dialog.dart +++ b/lib/oath/views/rename_account_dialog.dart @@ -87,7 +87,7 @@ class _RenameAccountDialogState extends ConsumerState { } showMessage( context, - '${l10n.l_account_add_failed}: $errorMessage', + l10n.l_account_add_failed(errorMessage), duration: const Duration(seconds: 4), ); }