From bdf4f9df732aab720fcf0f294200296970359047 Mon Sep 17 00:00:00 2001 From: Aaron Madlon-Kay Date: Sun, 24 Dec 2023 20:07:45 +0900 Subject: [PATCH] Localize decryption strings See #33 --- lib/l10n/app_en.arb | 12 +++++++++++- lib/l10n/app_ja.arb | 12 +++++++++++- lib/l10n/app_uk.arb | 12 +++++++++++- lib/src/components/banners.dart | 14 ++++++-------- lib/src/components/dialogs.dart | 12 +++++++----- lib/src/pages/document.dart | 11 +++++++---- 6 files changed, 53 insertions(+), 20 deletions(-) diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index d4330ae2..8260a78c 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -94,6 +94,11 @@ "bannerBodyActionSaveNever": "Never", "bannerBodyActionSaveOnce": "Just this time", + "bannerBodyDecryptContent": "This document contains encrypted content. Decrypt it now?", + "bannerBodyActionDecryptNow": "Decrypt", + "bannerBodyActionDecryptNotNow": "Not now", + "bannerBodyActionDecryptNever": "Never", + "saveChangesDialogTitle": "Save changes?", "saveChangesDialogMessage": "Orgro can’t write your changes back to the original file.", "saveActionShare": "Share", @@ -101,6 +106,10 @@ "savedMessage": "Saved", + "inputPasswordDialogTitle": "Enter password", + + "decryptingProgressDialogTitle": "Decrypting…", + "errorCannotResolveRelativePath": "Can’t resolve path relative to this document", "errorPathResolvedToNonFile": "{path} resolved to a non-file: {resolved}", "@errorPathResolvedToNonFile": { @@ -148,5 +157,6 @@ "placeholders": { "item": {} } - } + }, + "errorDecryptionFailed": "Decryption failed" } diff --git a/lib/l10n/app_ja.arb b/lib/l10n/app_ja.arb index 4fb1cd2d..e7211f67 100644 --- a/lib/l10n/app_ja.arb +++ b/lib/l10n/app_ja.arb @@ -84,6 +84,11 @@ "bannerBodyActionSaveNever": "保存しない", "bannerBodyActionSaveOnce": "今回だけ", + "bannerBodyDecryptContent": "本ドキュメントに暗号化されたコンテンツが含まれています。復号しますか?", + "bannerBodyActionDecryptNow": "復号する", + "bannerBodyActionDecryptNotNow": "今は復号しない", + "bannerBodyActionDecryptNever": "復号しない", + "saveChangesDialogTitle": "変更を保存しますか?", "saveChangesDialogMessage": "元ファイルに書き戻しできません。", "saveActionShare": "共有する", @@ -91,6 +96,10 @@ "savedMessage": "保存しました", + "inputPasswordDialogTitle": "パスワード入力", + + "decryptingProgressDialogTitle": "復号中…", + "errorCannotResolveRelativePath": "本ドキュメントからの相対パスは解決できません。", "errorPathResolvedToNonFile": "{path} を解決した結果はファイルではありませんでした。結果: {resolved}", "errorUnknownType": "不明な型: {type}", @@ -122,5 +131,6 @@ "placeholders": { "item": {} } - } + }, + "errorDecryptionFailed": "復号が失敗しました" } diff --git a/lib/l10n/app_uk.arb b/lib/l10n/app_uk.arb index c006f497..4a99e659 100644 --- a/lib/l10n/app_uk.arb +++ b/lib/l10n/app_uk.arb @@ -94,6 +94,11 @@ "bannerBodyActionSaveNever": "Never", "bannerBodyActionSaveOnce": "Just this time", + "bannerBodyDecryptContent": "This document contains encrypted content. Decrypt it now?", + "bannerBodyActionDecryptNow": "Decrypt", + "bannerBodyActionDecryptNotNow": "Not now", + "bannerBodyActionDecryptNever": "Never", + "saveChangesDialogTitle": "Save changes?", "saveChangesDialogMessage": "Orgro can’t write your changes back to the original file.", "saveActionShare": "Share", @@ -101,6 +106,10 @@ "savedMessage": "Saved", + "inputPasswordDialogTitle": "Enter password", + + "decryptingProgressDialogTitle": "Decrypting…", + "errorCannotResolveRelativePath": "Не можливо розвʼязати шлях відносно цього документа", "errorPathResolvedToNonFile": "{path} визначено як не файл: {resolved}", "@errorPathResolvedToNonFile": { @@ -148,5 +157,6 @@ "placeholders": { "item": {} } - } + }, + "errorDecryptionFailed": "Decryption failed" } diff --git a/lib/src/components/banners.dart b/lib/src/components/banners.dart index 4623703e..f337eac0 100644 --- a/lib/src/components/banners.dart +++ b/lib/src/components/banners.dart @@ -186,22 +186,20 @@ class DecryptContentBanner extends StatelessWidget { return _NicelyTimedBanner( visible: visible, child: MaterialBanner( - content: const Text( - 'This document contains encrypted content. Decrypt it now?', - ), + content: Text(AppLocalizations.of(context)!.bannerBodyDecryptContent), leading: const Icon(Icons.lock), actions: [ _BannerButton( - text: 'Decrypt', + text: AppLocalizations.of(context)!.bannerBodyActionDecryptNow, onPressed: onAccept, ), _BannerButton( - text: 'Not now', - onPressed: () => onDeny(DecryptPolicy.deny, persist: false), + text: AppLocalizations.of(context)!.bannerBodyActionDecryptNever, + onPressed: () => onDeny(DecryptPolicy.deny, persist: true), ), _BannerButton( - text: 'Never', - onPressed: () => onDeny(DecryptPolicy.deny, persist: true), + text: AppLocalizations.of(context)!.bannerBodyActionDecryptNotNow, + onPressed: () => onDeny(DecryptPolicy.deny, persist: false), ), ], ), diff --git a/lib/src/components/dialogs.dart b/lib/src/components/dialogs.dart index 3c7bb316..5b5f39ad 100644 --- a/lib/src/components/dialogs.dart +++ b/lib/src/components/dialogs.dart @@ -104,7 +104,7 @@ class InputPasswordDialog extends StatelessWidget { Widget build(BuildContext context) { return AlertDialog( icon: const Icon(Icons.lock), - title: const Text('Password'), + title: Text(AppLocalizations.of(context)!.inputPasswordDialogTitle), content: TextField( autofocus: true, obscureText: true, @@ -115,13 +115,15 @@ class InputPasswordDialog extends StatelessWidget { } class ProgressIndicatorDialog extends StatelessWidget { - const ProgressIndicatorDialog({super.key}); + const ProgressIndicatorDialog({required this.title, super.key}); + + final String title; @override Widget build(BuildContext context) { - return const AlertDialog( - title: Text('Decrypting...'), - content: LinearProgressIndicator(), + return AlertDialog( + title: Text(title), + content: const LinearProgressIndicator(), ); } } diff --git a/lib/src/pages/document.dart b/lib/src/pages/document.dart index 875221b1..9a35b6f0 100644 --- a/lib/src/pages/document.dart +++ b/lib/src/pages/document.dart @@ -657,17 +657,20 @@ class _DocumentPageState extends State { .then((decrypted) => Navigator.pop(context, decrypted)); final result = await showDialog>( context: context, - builder: (context) => const ProgressIndicatorDialog(), + builder: (context) => ProgressIndicatorDialog( + title: AppLocalizations.of(context)!.decryptingProgressDialogTitle), ); if (!mounted) return; if (result == null) { - showErrorSnackBar(context, 'Decryption failed'); + showErrorSnackBar( + context, AppLocalizations.of(context)!.errorDecryptionFailed); return; } OrgTree newDoc = _doc; for (final (i, plaintext) in result.indexed) { if (plaintext == null) { - showErrorSnackBar(context, 'Decryption failed'); + showErrorSnackBar( + context, AppLocalizations.of(context)!.errorDecryptionFailed); continue; } final block = blocks[i]; @@ -678,7 +681,7 @@ class _DocumentPageState extends State { newDoc.editNode(block)!.replace(replacement).commit() as OrgTree; } catch (e, s) { logError(e, s); - showErrorSnackBar(context, 'Failed to parse plaintext'); + showErrorSnackBar(context, e); continue; } }