feat: autoTranslate preferences
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Kieran 2023-11-06 14:16:19 +00:00
parent 3d69762359
commit de0e58b657
Signed by: Kieran
GPG Key ID: DE71CEB3925BE941
5 changed files with 32 additions and 1 deletions

View File

@ -83,7 +83,7 @@ export function NoteContextMenu({ ev, ...props }: NosteContextMenuProps) {
useEffect(() => { useEffect(() => {
const sub = getCurrentSubscription(login.subscriptions); const sub = getCurrentSubscription(login.subscriptions);
if (sub?.type === SubscriptionType.Premium) { if (sub?.type === SubscriptionType.Premium && (login.preferences.autoTranslate ?? true)) {
translate(); translate();
} }
}, []); }, []);

View File

@ -91,6 +91,11 @@ export interface UserPreferences {
* Check event signatures * Check event signatures
*/ */
checkSigs: boolean; checkSigs: boolean;
/**
* Auto-translate when available
*/
autoTranslate?: boolean;
} }
export const DefaultPreferences = { export const DefaultPreferences = {
@ -110,4 +115,5 @@ export const DefaultPreferences = {
showBadges: false, showBadges: false,
showStatus: true, showStatus: true,
checkSigs: false, checkSigs: false,
autoTranslate: true,
} as UserPreferences; } as UserPreferences;

View File

@ -182,6 +182,23 @@ const PreferencesPage = () => {
/> />
</div> </div>
</div> </div>
<div className="flex justify-between w-max">
<div className="flex flex-col g8">
<h4>
<FormattedMessage defaultMessage="Auto Translate" />
</h4>
<small>
<FormattedMessage defaultMessage="Automatically translate notes to your local language" />
</small>
</div>
<div>
<input
type="checkbox"
checked={perf.autoTranslate}
onChange={e => updatePreferences(login, { ...perf, autoTranslate: e.target.checked })}
/>
</div>
</div>
<div className="flex justify-between w-max"> <div className="flex justify-between w-max">
<div className="flex flex-col g8"> <div className="flex flex-col g8">
<h4> <h4>

View File

@ -552,6 +552,9 @@
"IVbtTS": { "IVbtTS": {
"defaultMessage": "Zap all {n} sats" "defaultMessage": "Zap all {n} sats"
}, },
"IWz1ta": {
"defaultMessage": "Auto Translate"
},
"Ig9/a1": { "Ig9/a1": {
"defaultMessage": "Sent {n} sats to {name}" "defaultMessage": "Sent {n} sats to {name}"
}, },
@ -917,6 +920,9 @@
"WONP5O": { "WONP5O": {
"defaultMessage": "Find your twitter follows on nostr (Data provided by {provider})" "defaultMessage": "Find your twitter follows on nostr (Data provided by {provider})"
}, },
"WmZhfL": {
"defaultMessage": "Automatically translate notes to your local language"
},
"WvGmZT": { "WvGmZT": {
"defaultMessage": "npub / nprofile / nostr address" "defaultMessage": "npub / nprofile / nostr address"
}, },

View File

@ -181,6 +181,7 @@
"INSqIz": "Twitter username...", "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.", "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", "IVbtTS": "Zap all {n} sats",
"IWz1ta": "Auto Translate",
"Ig9/a1": "Sent {n} sats to {name}", "Ig9/a1": "Sent {n} sats to {name}",
"IoQq+a": "Click here to load anyway", "IoQq+a": "Click here to load anyway",
"Ix8l+B": "Trending Notes", "Ix8l+B": "Trending Notes",
@ -300,6 +301,7 @@
"W2PiAr": "{n} Blocked", "W2PiAr": "{n} Blocked",
"W9355R": "Unmute", "W9355R": "Unmute",
"WONP5O": "Find your twitter follows on nostr (Data provided by {provider})", "WONP5O": "Find your twitter follows on nostr (Data provided by {provider})",
"WmZhfL": "Automatically translate notes to your local language",
"WvGmZT": "npub / nprofile / nostr address", "WvGmZT": "npub / nprofile / nostr address",
"WxthCV": "e.g. Jack", "WxthCV": "e.g. Jack",
"X7xU8J": "nsec, npub, nip-05, hex, mnemonic", "X7xU8J": "nsec, npub, nip-05, hex, mnemonic",