From 9c5d1ea55d61fb76dcb5da9a1b97b4c62425ae6c Mon Sep 17 00:00:00 2001 From: Kieran Date: Thu, 24 Aug 2023 16:55:36 +0100 Subject: [PATCH] Formatting / Intl --- packages/app/src/lang.json | 98 ++++++++++++++----- packages/app/src/translations/en.json | 33 +++++-- packages/system-react/example/example.tsx | 8 +- packages/system-react/src/context.tsx | 2 +- packages/system-react/src/index.ts | 2 +- .../system-react/src/useRequestBuilder.tsx | 2 +- packages/system-react/src/useUserProfile.ts | 2 +- packages/system-react/src/useUserSearch.tsx | 56 +++++------ packages/system/src/index.ts | 2 +- packages/system/src/system-worker.ts | 2 +- 10 files changed, 134 insertions(+), 73 deletions(-) diff --git a/packages/app/src/lang.json b/packages/app/src/lang.json index df2b1a70..53f35850 100644 --- a/packages/app/src/lang.json +++ b/packages/app/src/lang.json @@ -5,6 +5,9 @@ "+PzQ9Y": { "defaultMessage": "Payout Now" }, + "+Vxixo": { + "defaultMessage": "Secret Group Chat" + }, "+aZY2h": { "defaultMessage": "Zap Type" }, @@ -51,9 +54,6 @@ "0BUTMv": { "defaultMessage": "Search..." }, - "0ehN4t": { - "defaultMessage": "Please connect a wallet {here} to be able to pay this invoice" - }, "0jOEtS": { "defaultMessage": "Invalid LNURL" }, @@ -105,10 +105,6 @@ "2ukA4d": { "defaultMessage": "{n} hours" }, - "380eol": { - "defaultMessage": "here", - "description": "Inline link text pointing to another page" - }, "3Rx6Qo": { "defaultMessage": "Advanced" }, @@ -170,6 +166,9 @@ "5u6iEc": { "defaultMessage": "Transfer to Pubkey" }, + "5vMmmR": { + "defaultMessage": "Usernames are not unique on Nostr. The nostr address is your unique human-readable address that is unique to you upon registration." + }, "5ykRmX": { "defaultMessage": "Send zap" }, @@ -231,9 +230,6 @@ "9pMqYs": { "defaultMessage": "Nostr Address" }, - "9qtLJC": { - "defaultMessage": "Payment Required" - }, "9wO4wJ": { "defaultMessage": "Lightning Invoice" }, @@ -329,9 +325,6 @@ "Dh3hbq": { "defaultMessage": "Auto Zap" }, - "DqLx9k": { - "defaultMessage": "You must pay {n} sats to access this file." - }, "DtYelJ": { "defaultMessage": "Transfer" }, @@ -377,6 +370,9 @@ "FS3b54": { "defaultMessage": "Done!" }, + "FSYL8G": { + "defaultMessage": "Trending Users" + }, "FdhSU2": { "defaultMessage": "Claim Now" }, @@ -386,9 +382,6 @@ "FmXUJg": { "defaultMessage": "follows you" }, - "FpxElY": { - "defaultMessage": "Verification" - }, "G/yZLu": { "defaultMessage": "Remove" }, @@ -401,6 +394,9 @@ "GL8aXW": { "defaultMessage": "Bookmarks ({n})" }, + "GSye7T": { + "defaultMessage": "Lightning Address" + }, "GUlSVG": { "defaultMessage": "Claim your included Snort nostr address" }, @@ -456,9 +452,6 @@ "Ig9/a1": { "defaultMessage": "Sent {n} sats to {name}" }, - "Iwm6o2": { - "defaultMessage": "NIP-05 Shop" - }, "Ix8l+B": { "defaultMessage": "Trending Notes" }, @@ -474,6 +467,12 @@ "JPFYIM": { "defaultMessage": "No lightning address" }, + "JeoS4y": { + "defaultMessage": "Repost" + }, + "JjGgXI": { + "defaultMessage": "Search users" + }, "JkLHGw": { "defaultMessage": "Website" }, @@ -516,6 +515,9 @@ "Lu5/Bj": { "defaultMessage": "Open on Zapstr" }, + "Lw+I+J": { + "defaultMessage": "{n,plural,=0{{name} zapped} other{{name} & {n} others zapped}}" + }, "M3Oirc": { "defaultMessage": "Debug Menus" }, @@ -538,6 +540,9 @@ "Mrpkot": { "defaultMessage": "Pay for subscription" }, + "MuVeKe": { + "defaultMessage": "Buy nostr address" + }, "MzRYWH": { "defaultMessage": "Buying {item}" }, @@ -629,8 +634,8 @@ "R1fEdZ": { "defaultMessage": "Forward Zaps" }, - "R2OqnW": { - "defaultMessage": "Delete Account" + "R81upa": { + "defaultMessage": "People you follow" }, "RDZVQL": { "defaultMessage": "Check" @@ -671,6 +676,9 @@ "SYQtZ7": { "defaultMessage": "LN Address Proxy" }, + "ShdEie": { + "defaultMessage": "Mark all read" + }, "Sjo1P4": { "defaultMessage": "Custom" }, @@ -690,15 +698,15 @@ "Tpy00S": { "defaultMessage": "People" }, - "TwyMau": { - "defaultMessage": "Account" - }, "UDYlxu": { "defaultMessage": "Pending Subscriptions" }, "ULotH9": { "defaultMessage": "Amount: {amount} sats" }, + "UT7Nkj": { + "defaultMessage": "New Chat" + }, "UUPFlt": { "defaultMessage": "Users must accept the content warning to show the content of your note." }, @@ -727,6 +735,9 @@ "defaultMessage": "Login with Extension (NIP-07)", "description": "Login button for NIP7 key manager extension" }, + "VvaJst": { + "defaultMessage": "View Wallets" + }, "Vx7Zm2": { "defaultMessage": "How do keys work?" }, @@ -812,6 +823,9 @@ "bep9C3": { "defaultMessage": "Public Key" }, + "bfvyfs": { + "defaultMessage": "Anon" + }, "brAXSu": { "defaultMessage": "Pick a username" }, @@ -878,6 +892,12 @@ "eSzf2G": { "defaultMessage": "A single zap of {nIn} sats will allocate {nOut} sats to the zap pool." }, + "eXT2QQ": { + "defaultMessage": "Group Chat" + }, + "fBI91o": { + "defaultMessage": "Zap" + }, "fOksnD": { "defaultMessage": "Can't vote because LNURL service does not support zaps" }, @@ -917,6 +937,9 @@ "gjBiyj": { "defaultMessage": "Loading..." }, + "grQ+mI": { + "defaultMessage": "Proof of Work" + }, "h8XMJL": { "defaultMessage": "Badges" }, @@ -1000,9 +1023,15 @@ "k7sKNy": { "defaultMessage": "Our very own NIP-05 verification service, help support the development of this site and get a shiny special badge on our site!" }, + "kJYo0u": { + "defaultMessage": "{n,plural,=0{{name} reposted} other{{name} & {n} others reposted}}" + }, "kaaf1E": { "defaultMessage": "now" }, + "kuPHYE": { + "defaultMessage": "{n,plural,=0{{name} liked} other{{name} & {n} others liked}}" + }, "l+ikU1": { "defaultMessage": "Everything in {plan}" }, @@ -1099,12 +1128,18 @@ "defaultMessage": "Login", "description": "Login header" }, + "ojzbwv": { + "defaultMessage": "Hey, it looks like you dont have a Nostr Address yet, you should get one! Check out {link}" + }, "osUr8O": { "defaultMessage": "You can also use these extensions to login to most Nostr sites." }, "oxCa4R": { "defaultMessage": "Getting an identifier helps confirm the real you to people who know you. Many people can have a username @jack, but there is only one jack@cash.app." }, + "p4N05H": { + "defaultMessage": "Upload" + }, "p85Uwy": { "defaultMessage": "Active Subscriptions" }, @@ -1138,6 +1173,9 @@ "qmJ8kD": { "defaultMessage": "Translation failed" }, + "qtWLmt": { + "defaultMessage": "Like" + }, "r3C4x/": { "defaultMessage": "Software" }, @@ -1198,6 +1236,9 @@ "ut+2Cd": { "defaultMessage": "Get a partner identifier" }, + "v8lolG": { + "defaultMessage": "Start chat" + }, "vOKedj": { "defaultMessage": "{n,plural,=1{& {n} other} other{& {n} others}}" }, @@ -1210,9 +1251,15 @@ "vhlWFg": { "defaultMessage": "Poll Options" }, + "vlbWtt": { + "defaultMessage": "Get a free one" + }, "vrTOHJ": { "defaultMessage": "{amount} sats" }, + "vxwnbh": { + "defaultMessage": "Amount of work to apply to all published events" + }, "wEQDC6": { "defaultMessage": "Edit" }, @@ -1236,9 +1283,6 @@ "wtLjP6": { "defaultMessage": "Copy ID" }, - "wvFw6Y": { - "defaultMessage": "Hey, it looks like you dont have a NIP-05 handle yet, you should get one! Check out {link}" - }, "x/Fx2P": { "defaultMessage": "Fund the services that you use by splitting a portion of all your zaps into a pool of funds!" }, diff --git a/packages/app/src/translations/en.json b/packages/app/src/translations/en.json index 136df205..6850017d 100644 --- a/packages/app/src/translations/en.json +++ b/packages/app/src/translations/en.json @@ -1,6 +1,7 @@ { "+D82kt": "Are you sure you want to repost: {id}", "+PzQ9Y": "Payout Now", + "+Vxixo": "Secret Group Chat", "+aZY2h": "Zap Type", "+vA//S": "Logins", "+vIQlC": "Please make sure to save the following password in order to manage your handle in the future", @@ -16,7 +17,6 @@ "08zn6O": "Export Keys", "0Azlrb": "Manage", "0BUTMv": "Search...", - "0ehN4t": "Please connect a wallet {here} to be able to pay this invoice", "0jOEtS": "Invalid LNURL", "0mch2Y": "name has disallowed characters", "0yO7wF": "{n} secs", @@ -34,7 +34,6 @@ "2a2YiP": "{n} Bookmarks", "2k0Cv+": "Dislikes ({n})", "2ukA4d": "{n} hours", - "380eol": "here", "3Rx6Qo": "Advanced", "3cc4Ct": "Light", "3gOsZq": "Translators", @@ -55,6 +54,7 @@ "5oTnfy": "Buy Handle", "5rOdPG": "Once you setup your key manager extension and generated a key, you can follow our new users flow to setup your profile and help you find some interesting people on Nostr to follow.", "5u6iEc": "Transfer to Pubkey", + "5vMmmR": "Usernames are not unique on Nostr. The nostr address is your unique human-readable address that is unique to you upon registration.", "5ykRmX": "Send zap", "65BmHb": "Failed to proxy image from {host}, click here to load directly", "6Yfvvp": "Get an identifier", @@ -75,7 +75,6 @@ "9WRlF4": "Send", "9gqH2W": "Login", "9pMqYs": "Nostr Address", - "9qtLJC": "Payment Required", "9wO4wJ": "Lightning Invoice", "ADmfQT": "Parent", "AGNz71": "Zap All {n} sats", @@ -107,7 +106,6 @@ "DZzCem": "Show latest {n} notes", "DcL8P+": "Supporter", "Dh3hbq": "Auto Zap", - "DqLx9k": "You must pay {n} sats to access this file.", "DtYelJ": "Transfer", "E8a4yq": "Follow some popular accounts", "ELbg9p": "Data Providers", @@ -123,14 +121,15 @@ "FDguSC": "{n} Zaps", "FP+D3H": "LNURL to forward zaps to", "FS3b54": "Done!", + "FSYL8G": "Trending Users", "FdhSU2": "Claim Now", "FfYsOb": "An error has occured!", "FmXUJg": "follows you", - "FpxElY": "Verification", "G/yZLu": "Remove", "G1BGCg": "Select Wallet", "GFOoEE": "Salt", "GL8aXW": "Bookmarks ({n})", + "GSye7T": "Lightning Address", "GUlSVG": "Claim your included Snort nostr address", "Gcn9NQ": "Magnet Link", "GspYR7": "{n} Dislike", @@ -149,12 +148,13 @@ "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.", "Ig9/a1": "Sent {n} sats to {name}", - "Iwm6o2": "NIP-05 Shop", "Ix8l+B": "Trending Notes", "J+dIsA": "Subscriptions", "JCIgkj": "Username", "JHEHCk": "Zaps ({n})", "JPFYIM": "No lightning address", + "JeoS4y": "Repost", + "JjGgXI": "Search users", "JkLHGw": "Website", "JymXbw": "Private Key", "K3r6DQ": "Delete", @@ -169,6 +169,7 @@ "LXxsbk": "Anonymous", "LgbKvU": "Comment", "Lu5/Bj": "Open on Zapstr", + "Lw+I+J": "{n,plural,=0{{name} zapped} other{{name} & {n} others zapped}}", "M3Oirc": "Debug Menus", "MBAYRO": "Shows \"Copy ID\" and \"Copy Event JSON\" in the context menu on each message", "MI2jkA": "Not available:", @@ -176,6 +177,7 @@ "MRp6Ly": "Twitter username", "MWTx65": "Default Page", "Mrpkot": "Pay for subscription", + "MuVeKe": "Buy nostr address", "MzRYWH": "Buying {item}", "N2IrpM": "Confirm", "NAuFNH": "You already have a subscription of this type, please renew or pay", @@ -206,7 +208,7 @@ "Qxv0B2": "You currently have {number} sats in your zap pool.", "R/6nsx": "Subscription", "R1fEdZ": "Forward Zaps", - "R2OqnW": "Delete Account", + "R81upa": "People you follow", "RDZVQL": "Check", "RahCRH": "Expired", "RfhLwC": "By: {author}", @@ -219,15 +221,16 @@ "SP0+yi": "Buy Subscription", "SX58hM": "Copy", "SYQtZ7": "LN Address Proxy", + "ShdEie": "Mark all read", "Sjo1P4": "Custom", "Ss0sWu": "Pay Now", "TDR5ge": "Media in notes will automatically be shown for selected people, otherwise only the link will show", "TMfYfY": "Cashu token", "TpgeGw": "Hex Salt..", "Tpy00S": "People", - "TwyMau": "Account", "UDYlxu": "Pending Subscriptions", "ULotH9": "Amount: {amount} sats", + "UT7Nkj": "New Chat", "UUPFlt": "Users must accept the content warning to show the content of your note.", "Up5U7K": "Block", "VBadwB": "Hmm, can't find a key manager extension.. try reloading the page.", @@ -237,6 +240,7 @@ "VlJkSk": "{n} muted", "VnXp8Z": "Avatar", "VtPV/B": "Login with Extension (NIP-07)", + "VvaJst": "View Wallets", "Vx7Zm2": "How do keys work?", "W1yoZY": "It looks like you dont have any subscriptions, you can get one {link}", "W2PiAr": "{n} Blocked", @@ -265,6 +269,7 @@ "b5vAk0": "Your handle will act like a lightning address and will redirect to your chosen LNURL or Lightning address", "bQdA2k": "Sensitive Content", "bep9C3": "Public Key", + "bfvyfs": "Anon", "brAXSu": "Pick a username", "bxv59V": "Just now", "c+oiJe": "Install Extension", @@ -286,6 +291,8 @@ "eHAneD": "Reaction emoji", "eJj8HD": "Get Verified", "eSzf2G": "A single zap of {nIn} sats will allocate {nOut} sats to the zap pool.", + "eXT2QQ": "Group Chat", + "fBI91o": "Zap", "fOksnD": "Can't vote because LNURL service does not support zaps", "fWZYP5": "Pinned", "filwqD": "Read", @@ -299,6 +306,7 @@ "gXgY3+": "Not all clients support this yet", "gczcC5": "Subscribe", "gjBiyj": "Loading...", + "grQ+mI": "Proof of Work", "h8XMJL": "Badges", "hK5ZDk": "the world", "hMzcSq": "Messages", @@ -326,7 +334,9 @@ "jzgQ2z": "{n} Reactions", "k2veDA": "Write", "k7sKNy": "Our very own NIP-05 verification service, help support the development of this site and get a shiny special badge on our site!", + "kJYo0u": "{n,plural,=0{{name} reposted} other{{name} & {n} others reposted}}", "kaaf1E": "now", + "kuPHYE": "{n,plural,=0{{name} liked} other{{name} & {n} others liked}}", "l+ikU1": "Everything in {plan}", "lBboHo": "If you want to try out some others, check out {link} for more!", "lCILNz": "Buy Now", @@ -358,8 +368,10 @@ "oJ+JJN": "Nothing found :/", "odFwjL": "Follows only", "odhABf": "Login", + "ojzbwv": "Hey, it looks like you dont have a Nostr Address yet, you should get one! Check out {link}", "osUr8O": "You can also use these extensions to login to most Nostr sites.", "oxCa4R": "Getting an identifier helps confirm the real you to people who know you. Many people can have a username @jack, but there is only one jack@cash.app.", + "p4N05H": "Upload", "p85Uwy": "Active Subscriptions", "pI+77w": "Downloadable backups from Snort relay", "puLNUJ": "Pin", @@ -371,6 +383,7 @@ "qdGuQo": "Your Private Key Is (do not share this with anyone)", "qkvYUb": "Add to Profile", "qmJ8kD": "Translation failed", + "qtWLmt": "Like", "r3C4x/": "Software", "r5srDR": "Enter wallet password", "rT14Ow": "Add Relays", @@ -391,11 +404,14 @@ "uSV4Ti": "Reposts need to be manually confirmed", "usAvMr": "Edit Profile", "ut+2Cd": "Get a partner identifier", + "v8lolG": "Start chat", "vOKedj": "{n,plural,=1{& {n} other} other{& {n} others}}", "vU71Ez": "Paying with {wallet}", "vZ4quW": "NIP-05 is a DNS based verification spec which helps to validate you as a real user.", "vhlWFg": "Poll Options", + "vlbWtt": "Get a free one", "vrTOHJ": "{amount} sats", + "vxwnbh": "Amount of work to apply to all published events", "wEQDC6": "Edit", "wLtRCF": "Your key", "wWLwvh": "Anon", @@ -403,7 +419,6 @@ "wih7iJ": "name is blocked", "wqyN/i": "Find out more info about {service} at {link}", "wtLjP6": "Copy ID", - "wvFw6Y": "Hey, it looks like you dont have a NIP-05 handle yet, you should get one! Check out {link}", "x/Fx2P": "Fund the services that you use by splitting a portion of all your zaps into a pool of funds!", "x/q8d5": "This note has been marked as sensitive, click here to reveal", "x82IOl": "Mute", diff --git a/packages/system-react/example/example.tsx b/packages/system-react/example/example.tsx index 5b3807a1..f1ebb542 100644 --- a/packages/system-react/example/example.tsx +++ b/packages/system-react/example/example.tsx @@ -38,7 +38,9 @@ export function UserPosts(props: { pubkey: string }) { } export function MyApp() { - return - - ; + return ( + + + + ); } diff --git a/packages/system-react/src/context.tsx b/packages/system-react/src/context.tsx index 74254ef2..4815ca3f 100644 --- a/packages/system-react/src/context.tsx +++ b/packages/system-react/src/context.tsx @@ -1,4 +1,4 @@ import { createContext } from "react"; import { NostrSystem, SystemInterface } from "@snort/system"; -export const SnortContext = createContext(new NostrSystem({})); \ No newline at end of file +export const SnortContext = createContext(new NostrSystem({})); diff --git a/packages/system-react/src/index.ts b/packages/system-react/src/index.ts index a8f4fbfd..7a4d18ca 100644 --- a/packages/system-react/src/index.ts +++ b/packages/system-react/src/index.ts @@ -2,4 +2,4 @@ export * from "./useRequestBuilder"; export * from "./useSystemState"; export * from "./useUserProfile"; export * from "./context"; -export * from "./useUserSearch"; \ No newline at end of file +export * from "./useUserSearch"; diff --git a/packages/system-react/src/useRequestBuilder.tsx b/packages/system-react/src/useRequestBuilder.tsx index 24c48acc..e8f9f18b 100644 --- a/packages/system-react/src/useRequestBuilder.tsx +++ b/packages/system-react/src/useRequestBuilder.tsx @@ -7,7 +7,7 @@ import { SnortContext } from "./context"; * Send a query to the relays and wait for data */ const useRequestBuilder = >( - type: { new(): TStore }, + type: { new (): TStore }, rb: RequestBuilder | null, ) => { const system = useContext(SnortContext); diff --git a/packages/system-react/src/useUserProfile.ts b/packages/system-react/src/useUserProfile.ts index 33df9f98..5d718761 100644 --- a/packages/system-react/src/useUserProfile.ts +++ b/packages/system-react/src/useUserProfile.ts @@ -6,7 +6,7 @@ import { SnortContext } from "./context"; * Gets a profile from cache or requests it from the relays */ export function useUserProfile(pubKey?: HexKey): MetadataCache | undefined { - const system = useContext(SnortContext); + const system = useContext(SnortContext); return useSyncExternalStore( h => { if (pubKey) { diff --git a/packages/system-react/src/useUserSearch.tsx b/packages/system-react/src/useUserSearch.tsx index 1ba4b687..e8c3d2c6 100644 --- a/packages/system-react/src/useUserSearch.tsx +++ b/packages/system-react/src/useUserSearch.tsx @@ -4,34 +4,34 @@ import { fetchNip05Pubkey } from "@snort/shared"; import { SnortContext } from "./context"; export function useUserSearch() { - const system = useContext(SnortContext); - const cache = system.ProfileLoader.Cache as UserProfileCache; + const system = useContext(SnortContext); + const cache = system.ProfileLoader.Cache as UserProfileCache; - async function search(input: string): Promise> { - // try exact match first - if (input.length === 64 && [...input].every(c => !isNaN(parseInt(c, 16)))) { - return [input]; - } - - if (input.startsWith(NostrPrefix.PublicKey) || input.startsWith(NostrPrefix.Profile)) { - const link = tryParseNostrLink(input); - if (link) { - return [link.id] - } - } - - if (input.includes("@")) { - const [name, domain] = input.split("@"); - const pk = await fetchNip05Pubkey(name, domain); - if (pk) { - return [pk]; - } - } - - // search cache - const cacheResults = await cache.search(input); - return cacheResults.map(v => v.pubkey); + async function search(input: string): Promise> { + // try exact match first + if (input.length === 64 && [...input].every(c => !isNaN(parseInt(c, 16)))) { + return [input]; } - return search; -} \ No newline at end of file + if (input.startsWith(NostrPrefix.PublicKey) || input.startsWith(NostrPrefix.Profile)) { + const link = tryParseNostrLink(input); + if (link) { + return [link.id]; + } + } + + if (input.includes("@")) { + const [name, domain] = input.split("@"); + const pk = await fetchNip05Pubkey(name, domain); + if (pk) { + return [pk]; + } + } + + // search cache + const cacheResults = await cache.search(input); + return cacheResults.map(v => v.pubkey); + } + + return search; +} diff --git a/packages/system/src/index.ts b/packages/system/src/index.ts index ec5605b1..3064fb4c 100644 --- a/packages/system/src/index.ts +++ b/packages/system/src/index.ts @@ -47,7 +47,7 @@ export interface SystemInterface { DisconnectRelay(address: string): void; BroadcastEvent(ev: NostrEvent): void; WriteOnceToRelay(relay: string, ev: NostrEvent): Promise; - get ProfileLoader(): ProfileLoaderService + get ProfileLoader(): ProfileLoaderService; } export interface SystemSnapshot { diff --git a/packages/system/src/system-worker.ts b/packages/system/src/system-worker.ts index d42cd08f..2697c0cb 100644 --- a/packages/system/src/system-worker.ts +++ b/packages/system/src/system-worker.ts @@ -20,7 +20,7 @@ export class SystemWorker extends ExternalStore implements Syste throw new Error("SharedWorker is not supported"); } } - + get ProfileLoader(): ProfileLoaderService { throw new Error("Method not implemented."); }