Line data Source code
1 : import type { AddCreditsAmountError } from './addCreditsAmount'
2 : import type { AddCreditsWait } from './addCreditsRefusal'
3 :
4 : /** One English table every host translates by key; `{support}` marks where the support link renders. */
5 2356 : export const ADD_CREDITS_COPY = {
6 : title: 'Add credits',
7 : customAmountLabel: 'Or enter an amount',
8 : 'amountError.below_min': 'Minimum is {amount}.',
9 : 'amountError.above_max':
10 : 'The largest top-up is {amount}. Add more with another top-up.',
11 : 'amountError.whole_dollars': 'Whole dollars only.',
12 : negativeBalance:
13 : 'Your balance is −{credits} credits. This top-up covers that first.',
14 : 'planLine.no_plan':
15 : "Buying credits doesn't start a Cloud plan. Subscribe to run workflows on Cloud.",
16 : 'planLine.ended':
17 : "Buying credits doesn't restart your Cloud plan. Resubscribe to run workflows on Cloud.",
18 : 'planLine.free_runs':
19 : "Buying credits doesn't start a Cloud plan. Subscribe to keep running workflows once your free runs are used.",
20 : credits: '{credits} credits',
21 : creditsUnavailable: '— credits',
22 : paidAtCheckout: '{amount}, paid at checkout',
23 : continue: 'Continue',
24 : opening: 'Opening…',
25 : 'processing.title': 'A {amount} payment is still processing',
26 : 'processing.titleNoAmount': 'A payment is still processing',
27 : 'processing.body': 'No need to pay again.',
28 : 'needsVerification.title': 'Your {amount} payment needs verification',
29 : 'needsVerification.titleNoAmount': 'Your payment needs verification',
30 : 'needsVerification.body':
31 : 'Your bank is waiting for you to confirm it. Verify it to finish this top-up.',
32 : 'needsVerification.footer': '{amount}, unverified',
33 : 'needsVerification.action': 'Verify payment',
34 : 'notVerified.title': "Your {amount} payment wasn't verified",
35 : 'notVerified.titleNoAmount': "Your payment wasn't verified",
36 : 'notVerified.body':
37 : "Your bank didn't confirm it. Try again later, or contact support.",
38 : 'notVerified.footerTitle': '{amount} top-up',
39 : 'notVerified.footer': 'Not verified',
40 : 'notVerified.action': 'Contact support',
41 : 'checkoutFailed.title': "Couldn't open checkout",
42 : 'checkoutFailed.body': 'Nothing was charged. Try again.',
43 : 'notAllowed.title': "You can't add credits right now",
44 : 'notAllowed.body': 'Check Billing settings to see why.',
45 : 'rateLimited.title': "You've hit the top-up limit for now",
46 : 'rateLimited.body': 'Try again in {wait}, or {support}.',
47 : 'rateLimited.bodyNoWait': 'Try again later, or {support}.',
48 : 'purchasesPaused.title': "Buying credits isn't available right now",
49 : 'purchasesPaused.body': 'Try again later, or {support}.',
50 : messageSupport: 'message support',
51 : 'wait.minute': 'a minute',
52 : 'wait.minutes': '{count} minutes',
53 : 'wait.hour': 'an hour',
54 : 'wait.hours': '{count} hours',
55 : 'wait.day': 'a day',
56 : 'wait.days': '{count} days',
57 : 'opened.title': 'Checkout opened in a new tab',
58 : 'opened.titleBrowser': 'Checkout opened in your browser',
59 : 'opened.body':
60 : 'Credits are added to this workspace as soon as your payment goes through.',
61 : 'opened.credits': 'Credits',
62 : 'opened.amount': 'Amount',
63 : 'opened.reopen': 'Reopen checkout',
64 : close: 'Close',
65 : 'blocked.title': "Checkout didn't open",
66 : 'blocked.body':
67 : 'Your browser blocked the new tab. Open checkout to finish paying.',
68 : 'blocked.action': 'Open checkout',
69 : 'autoTopUpOffer.body':
70 : 'Buy credits automatically when you run low, so workflows and API calls keep running.',
71 : 'autoTopUpOffer.setUp': 'Set up',
72 : 'autoTopUpOffer.notNow': 'Not now',
73 : 'autoTopUp.label': 'Turn on auto top-up',
74 : 'autoTopUp.body':
75 : 'Buy credits automatically when you run low, so workflows keep running.',
76 : 'autoTopUp.threshold': 'When credits drop below',
77 : 'autoTopUp.thresholdHint': 'Counts plan credits and credits you’ve bought.',
78 : 'autoTopUp.target': 'Top up to',
79 : 'autoTopUp.targetHint': '{target} credits. Each top-up is at least {amount}.',
80 : 'autoTopUp.limit': 'Monthly limit',
81 : 'autoTopUp.limitOff':
82 : 'Up to {max} a month, the maximum. Turn on to set a lower limit.',
83 : 'autoTopUp.limitHint': 'Most you can set here: {max} a month.',
84 : 'autoTopUp.consentNoCard':
85 : 'Top-ups are charged to the card you pay with at checkout, up to {max} a month. Turn this off anytime in {billing}.',
86 : 'autoTopUp.consentDefaultCard':
87 : 'Top-ups are charged to your default card, {card}, up to {max} a month. Turn this off anytime in {billing}.',
88 : 'autoTopUp.card': '{brand} ···· {last4}',
89 : 'autoTopUp.billing': 'Billing',
90 : 'autoTopUp.invalid': 'Enter a valid value.',
91 : 'autoTopUp.fieldError.notWhole': 'Enter a whole number of credits.',
92 : 'autoTopUp.fieldError.belowMinimum': 'Must be at least 1 credit.',
93 : 'autoTopUp.fieldError.belowTarget':
94 : 'Must be at least {minimum} credits, about {usd} above your threshold.',
95 : 'autoTopUp.fieldError.aboveTarget':
96 : 'Can’t be more than {max} credits (about {usd}).',
97 : 'autoTopUp.fieldError.belowTopUp':
98 : 'Can’t cover one top-up. Set at least {amount}.',
99 : 'autoTopUp.isOn': 'Auto top-up is on.',
100 : 'autoTopUp.manage': 'Manage',
101 : 'autoTopUpOn.title': 'Auto top-up is on',
102 : 'autoTopUpOn.summary': 'Below {threshold} credits, tops up to {target}.',
103 : 'autoTopUpOn.limit': 'Up to {limit} a month.',
104 : 'autoTopUpOn.noLimit': 'No monthly limit.',
105 : 'autoTopUpOn.done': 'Done',
106 : 'autoTopUpFailed.title': "Auto top-up didn't turn on",
107 : 'autoTopUpFailed.body':
108 : 'Your credits were added. Set up auto top-up in Billing to try again.'
109 : } as const satisfies Record<string, string>
110 :
111 : export type AddCreditsCopyKey = keyof typeof ADD_CREDITS_COPY
112 :
113 : /** The surface-only plan line a host passes in from its served plan state. */
114 : export type AddCreditsPlanLine = 'no_plan' | 'ended' | 'free_runs'
115 :
116 : export type AddCreditsCopyParams = Readonly<Record<string, string | number>>
117 :
118 : /** The host's translator; the default fills the English table. */
119 : export type AddCreditsTranslate = (
120 : key: AddCreditsCopyKey,
121 : params?: AddCreditsCopyParams
122 : ) => string
123 :
124 2356 : export const translateAddCreditsDefault: AddCreditsTranslate = (
125 : key,
126 : params = {}
127 : ) =>
128 : ADD_CREDITS_COPY[key].replace(/\{(\w+)\}/g, (token, name: string) =>
129 : name in params ? String(params[name]) : token
130 : )
131 :
132 0 : export function amountErrorCopyKey(
133 : error: AddCreditsAmountError
134 : ): AddCreditsCopyKey {
135 0 : return `amountError.${error}`
136 : }
137 :
138 2356 : const WAIT_KEYS = {
139 : minute: ['wait.minute', 'wait.minutes'],
140 : hour: ['wait.hour', 'wait.hours'],
141 : day: ['wait.day', 'wait.days']
142 : } as const satisfies Record<
143 : Exclude<AddCreditsWait['unit'], 'later'>,
144 : readonly [AddCreditsCopyKey, AddCreditsCopyKey]
145 : >
146 :
147 0 : export function waitCopy(
148 : wait: Exclude<AddCreditsWait, { readonly unit: 'later' }>,
149 : translate: AddCreditsTranslate
150 : ): string {
151 0 : const [one, many] = WAIT_KEYS[wait.unit]
152 0 : return wait.count === 1
153 : ? translate(one)
154 : : translate(many, { count: wait.count })
155 : }
|