From de0e58b657dc13bd6f77103467df06fd9a0dbd5a Mon Sep 17 00:00:00 2001 From: Kieran Date: Mon, 6 Nov 2023 14:16:19 +0000 Subject: [PATCH] feat: autoTranslate preferences --- .../app/src/Element/Event/NoteContextMenu.tsx | 2 +- packages/app/src/Login/Preferences.ts | 6 ++++++ packages/app/src/Pages/settings/Preferences.tsx | 17 +++++++++++++++++ packages/app/src/lang.json | 6 ++++++ packages/app/src/translations/en.json | 2 ++ 5 files changed, 32 insertions(+), 1 deletion(-) diff --git a/packages/app/src/Element/Event/NoteContextMenu.tsx b/packages/app/src/Element/Event/NoteContextMenu.tsx index ea37e335..7ff1b967 100644 --- a/packages/app/src/Element/Event/NoteContextMenu.tsx +++ b/packages/app/src/Element/Event/NoteContextMenu.tsx @@ -83,7 +83,7 @@ export function NoteContextMenu({ ev, ...props }: NosteContextMenuProps) { useEffect(() => { const sub = getCurrentSubscription(login.subscriptions); - if (sub?.type === SubscriptionType.Premium) { + if (sub?.type === SubscriptionType.Premium && (login.preferences.autoTranslate ?? true)) { translate(); } }, []); diff --git a/packages/app/src/Login/Preferences.ts b/packages/app/src/Login/Preferences.ts index bf2cbdb6..fd49d534 100644 --- a/packages/app/src/Login/Preferences.ts +++ b/packages/app/src/Login/Preferences.ts @@ -91,6 +91,11 @@ export interface UserPreferences { * Check event signatures */ checkSigs: boolean; + + /** + * Auto-translate when available + */ + autoTranslate?: boolean; } export const DefaultPreferences = { @@ -110,4 +115,5 @@ export const DefaultPreferences = { showBadges: false, showStatus: true, checkSigs: false, + autoTranslate: true, } as UserPreferences; diff --git a/packages/app/src/Pages/settings/Preferences.tsx b/packages/app/src/Pages/settings/Preferences.tsx index 1b7af1e2..3d1ebd29 100644 --- a/packages/app/src/Pages/settings/Preferences.tsx +++ b/packages/app/src/Pages/settings/Preferences.tsx @@ -182,6 +182,23 @@ const PreferencesPage = () => { /> +
+
+

+ +

+ + + +
+
+ updatePreferences(login, { ...perf, autoTranslate: e.target.checked })} + /> +
+

diff --git a/packages/app/src/lang.json b/packages/app/src/lang.json index 56370b41..efc9056a 100644 --- a/packages/app/src/lang.json +++ b/packages/app/src/lang.json @@ -552,6 +552,9 @@ "IVbtTS": { "defaultMessage": "Zap all {n} sats" }, + "IWz1ta": { + "defaultMessage": "Auto Translate" + }, "Ig9/a1": { "defaultMessage": "Sent {n} sats to {name}" }, @@ -917,6 +920,9 @@ "WONP5O": { "defaultMessage": "Find your twitter follows on nostr (Data provided by {provider})" }, + "WmZhfL": { + "defaultMessage": "Automatically translate notes to your local language" + }, "WvGmZT": { "defaultMessage": "npub / nprofile / nostr address" }, diff --git a/packages/app/src/translations/en.json b/packages/app/src/translations/en.json index b9b6b574..48b0b47f 100644 --- a/packages/app/src/translations/en.json +++ b/packages/app/src/translations/en.json @@ -181,6 +181,7 @@ "INSqIz": "Twitter username...", "IUZC+0": "This means that nobody can modify notes which you have created and everybody can easily verify that the notes they are reading are created by you.", "IVbtTS": "Zap all {n} sats", + "IWz1ta": "Auto Translate", "Ig9/a1": "Sent {n} sats to {name}", "IoQq+a": "Click here to load anyway", "Ix8l+B": "Trending Notes", @@ -300,6 +301,7 @@ "W2PiAr": "{n} Blocked", "W9355R": "Unmute", "WONP5O": "Find your twitter follows on nostr (Data provided by {provider})", + "WmZhfL": "Automatically translate notes to your local language", "WvGmZT": "npub / nprofile / nostr address", "WxthCV": "e.g. Jack", "X7xU8J": "nsec, npub, nip-05, hex, mnemonic",