Skip to content

Commit

Permalink
Localize decryption strings
Browse files Browse the repository at this point in the history
See #33
  • Loading branch information
amake committed Dec 24, 2023
1 parent 4b8a6af commit bdf4f9d
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 20 deletions.
12 changes: 11 additions & 1 deletion lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,22 @@
"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",
"saveActionDiscard": "Discard",

"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": {
Expand Down Expand Up @@ -148,5 +157,6 @@
"placeholders": {
"item": {}
}
}
},
"errorDecryptionFailed": "Decryption failed"
}
12 changes: 11 additions & 1 deletion lib/l10n/app_ja.arb
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,22 @@
"bannerBodyActionSaveNever": "保存しない",
"bannerBodyActionSaveOnce": "今回だけ",

"bannerBodyDecryptContent": "本ドキュメントに暗号化されたコンテンツが含まれています。復号しますか?",
"bannerBodyActionDecryptNow": "復号する",
"bannerBodyActionDecryptNotNow": "今は復号しない",
"bannerBodyActionDecryptNever": "復号しない",

"saveChangesDialogTitle": "変更を保存しますか?",
"saveChangesDialogMessage": "元ファイルに書き戻しできません。",
"saveActionShare": "共有する",
"saveActionDiscard": "破棄する",

"savedMessage": "保存しました",

"inputPasswordDialogTitle": "パスワード入力",

"decryptingProgressDialogTitle": "復号中…",

"errorCannotResolveRelativePath": "本ドキュメントからの相対パスは解決できません。",
"errorPathResolvedToNonFile": "{path} を解決した結果はファイルではありませんでした。結果: {resolved}",
"errorUnknownType": "不明な型: {type}",
Expand Down Expand Up @@ -122,5 +131,6 @@
"placeholders": {
"item": {}
}
}
},
"errorDecryptionFailed": "復号が失敗しました"
}
12 changes: 11 additions & 1 deletion lib/l10n/app_uk.arb
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,22 @@
"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",
"saveActionDiscard": "Discard",

"savedMessage": "Saved",

"inputPasswordDialogTitle": "Enter password",

"decryptingProgressDialogTitle": "Decrypting…",

"errorCannotResolveRelativePath": "Не можливо розвʼязати шлях відносно цього документа",
"errorPathResolvedToNonFile": "{path} визначено як не файл: {resolved}",
"@errorPathResolvedToNonFile": {
Expand Down Expand Up @@ -148,5 +157,6 @@
"placeholders": {
"item": {}
}
}
},
"errorDecryptionFailed": "Decryption failed"
}
14 changes: 6 additions & 8 deletions lib/src/components/banners.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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),
),
],
),
Expand Down
12 changes: 7 additions & 5 deletions lib/src/components/dialogs.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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(),
);
}
}
11 changes: 7 additions & 4 deletions lib/src/pages/document.dart
Original file line number Diff line number Diff line change
Expand Up @@ -657,17 +657,20 @@ class _DocumentPageState extends State<DocumentPage> {
.then((decrypted) => Navigator.pop(context, decrypted));
final result = await showDialog<List<String?>>(
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];
Expand All @@ -678,7 +681,7 @@ class _DocumentPageState extends State<DocumentPage> {
newDoc.editNode(block)!.replace(replacement).commit() as OrgTree;
} catch (e, s) {
logError(e, s);
showErrorSnackBar(context, 'Failed to parse plaintext');
showErrorSnackBar(context, e);
continue;
}
}
Expand Down

0 comments on commit bdf4f9d

Please sign in to comment.