fontdue-js 3.14.0 → 3.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/dist/__generated__/CartOrderCompleteOrderMutation.graphql.d.ts +1 -1
- package/dist/__generated__/CartOrderCompleteOrderMutation.graphql.js +3 -3
- package/dist/__generated__/CartOrderRemoveDiscountMutation.graphql.d.ts +1 -1
- package/dist/__generated__/CartOrderRemoveDiscountMutation.graphql.js +3 -3
- package/dist/__generated__/CartOrderUpdateMutation.graphql.d.ts +1 -1
- package/dist/__generated__/CartOrderUpdateMutation.graphql.js +3 -3
- package/dist/__generated__/CartQuery.graphql.d.ts +1 -1
- package/dist/__generated__/CartQuery.graphql.js +3 -3
- package/dist/__generated__/CartStateUpdateMutation.graphql.d.ts +5 -1
- package/dist/__generated__/CartStateUpdateMutation.graphql.js +132 -117
- package/dist/__generated__/CartState_order.graphql.d.ts +4 -1
- package/dist/__generated__/CartState_order.graphql.js +11 -2
- package/dist/__generated__/CheckoutUpdateCustomerMutation.graphql.d.ts +1 -1
- package/dist/__generated__/CheckoutUpdateCustomerMutation.graphql.js +3 -3
- package/dist/__generated__/CheckoutUpdateOrderMutation.graphql.d.ts +1 -1
- package/dist/__generated__/CheckoutUpdateOrderMutation.graphql.js +3 -3
- package/dist/__generated__/FamilyList_node.graphql.d.ts +3 -1
- package/dist/__generated__/FamilyList_node.graphql.js +8 -2
- package/dist/__generated__/FontFamiliesQuery.graphql.d.ts +1 -1
- package/dist/__generated__/FontFamiliesQuery.graphql.js +5 -5
- package/dist/__generated__/PrecartAddToCartMutation.graphql.d.ts +1 -1
- package/dist/__generated__/PrecartAddToCartMutation.graphql.js +3 -3
- package/dist/__generated__/StoreModalCartQuery.graphql.d.ts +1 -1
- package/dist/__generated__/StoreModalCartQuery.graphql.js +69 -69
- package/dist/__generated__/StoreModalFamily_collection.graphql.d.ts +2 -1
- package/dist/__generated__/StoreModalFamily_collection.graphql.js +16 -15
- package/dist/__generated__/StoreModalIndexItem_fontCollection.graphql.d.ts +19 -1
- package/dist/__generated__/StoreModalIndexItem_fontCollection.graphql.js +39 -4
- package/dist/__generated__/StoreModalIndexPaginationQuery.graphql.d.ts +1 -1
- package/dist/__generated__/StoreModalIndexPaginationQuery.graphql.js +40 -5
- package/dist/__generated__/StoreModalIndexQuery.graphql.d.ts +1 -1
- package/dist/__generated__/StoreModalIndexQuery.graphql.js +40 -5
- package/dist/__generated__/StoreModalProductContent_collection.graphql.d.ts +19 -1
- package/dist/__generated__/StoreModalProductContent_collection.graphql.js +46 -11
- package/dist/__generated__/StoreModalProductQuery.graphql.d.ts +1 -1
- package/dist/__generated__/StoreModalProductQuery.graphql.js +198 -167
- package/dist/__generated__/StoreModalProductRefetchQuery.graphql.d.ts +1 -1
- package/dist/__generated__/StoreModalProductRefetchQuery.graphql.js +171 -140
- package/dist/__generated__/StoreModalProductSlugQuery.graphql.d.ts +1 -1
- package/dist/__generated__/StoreModalProductSlugQuery.graphql.js +201 -170
- package/dist/__generated__/StripeProviderCreateCheckoutSessionMutation.graphql.d.ts +5 -2
- package/dist/__generated__/StripeProviderCreateCheckoutSessionMutation.graphql.js +41 -22
- package/dist/__generated__/TestFontsFormUpdateCustomerMutation.graphql.d.ts +1 -1
- package/dist/__generated__/TestFontsFormUpdateCustomerMutation.graphql.js +3 -3
- package/dist/__generated__/TypeTesterStandaloneChangedStylesQuery.graphql.d.ts +1 -1
- package/dist/__generated__/TypeTesterStandaloneChangedStylesQuery.graphql.js +9 -3
- package/dist/__generated__/TypeTesterStandaloneQuery.graphql.d.ts +1 -1
- package/dist/__generated__/TypeTesterStandaloneQuery.graphql.js +9 -3
- package/dist/__generated__/TypeTester_fontStyle.graphql.d.ts +3 -1
- package/dist/__generated__/TypeTester_fontStyle.graphql.js +8 -2
- package/dist/__generated__/TypeTestersChangedStylesQuery.graphql.d.ts +1 -1
- package/dist/__generated__/TypeTestersChangedStylesQuery.graphql.js +9 -3
- package/dist/__generated__/TypeTestersIDQuery.graphql.d.ts +1 -1
- package/dist/__generated__/TypeTestersIDQuery.graphql.js +39 -39
- package/dist/__generated__/TypeTestersRefetchQuery.graphql.d.ts +1 -1
- package/dist/__generated__/TypeTestersRefetchQuery.graphql.js +37 -37
- package/dist/__generated__/TypeTestersSlugQuery.graphql.d.ts +1 -1
- package/dist/__generated__/TypeTestersSlugQuery.graphql.js +39 -39
- package/dist/__tests__/cartDiscountRemoved.test.js +195 -0
- package/dist/__tests__/characterViewerCollapse.test.js +199 -0
- package/dist/__tests__/characterViewerStyleSelect.test.js +52 -0
- package/dist/__tests__/checkoutReturn.test.js +66 -0
- package/dist/__tests__/familyStyleCounts.test.js +71 -0
- package/dist/__tests__/i18n.test.js +171 -0
- package/dist/__tests__/i18nComponents.test.js +408 -0
- package/dist/__tests__/localeEnvironments.test.js +275 -0
- package/dist/__tests__/localeMiddleware.test.js +68 -0
- package/dist/__tests__/localeTransport.test.js +209 -0
- package/dist/__tests__/recaptchaLocale.test.js +62 -0
- package/dist/__tests__/serverEntryLocale.test.js +124 -0
- package/dist/__tests__/storeModalIndexUnlisted.test.js +69 -11
- package/dist/__tests__/useSerializablePreloadedQuery.test.js +4 -3
- package/dist/components/AddToCartBanner/index.js +8 -2
- package/dist/components/BuyButton/index.d.ts +1 -0
- package/dist/components/BuyButton/index.js +8 -2
- package/dist/components/BuyButton/index.server.d.ts +1 -0
- package/dist/components/BuyButton/index.server.js +8 -0
- package/dist/components/BuyingOptions/index.js +3 -1
- package/dist/components/Cart/AddressFields.js +5 -3
- package/dist/components/Cart/CartCouponNotice.d.ts +7 -0
- package/dist/components/Cart/CartCouponNotice.js +21 -0
- package/dist/components/Cart/CartItem/CartItemAdditionalLicenses.js +3 -1
- package/dist/components/Cart/CartItem/CartItemLicense.js +3 -1
- package/dist/components/Cart/CartItem/CartItemProduct.js +6 -3
- package/dist/components/Cart/CartItem/VariableTextInput.js +7 -3
- package/dist/components/Cart/CartItem/index.js +5 -1
- package/dist/components/Cart/CartOrder.js +27 -17
- package/dist/components/Cart/CartState.d.ts +1 -0
- package/dist/components/Cart/CartState.js +18 -3
- package/dist/components/Cart/CartTotals.js +17 -9
- package/dist/components/Cart/Checkout.js +18 -15
- package/dist/components/Cart/CouponCodeInput.js +5 -3
- package/dist/components/Cart/CustomerFields.js +6 -4
- package/dist/components/Cart/EmptyCart.js +4 -2
- package/dist/components/Cart/IdentityBox.js +6 -2
- package/dist/components/Cart/ShareCart.js +8 -6
- package/dist/components/Cart/checkoutReturn.d.ts +17 -0
- package/dist/components/Cart/checkoutReturn.js +38 -0
- package/dist/components/CartButton/index.d.ts +2 -1
- package/dist/components/CartButton/index.js +6 -2
- package/dist/components/CharacterViewer/StyleSelect.js +6 -2
- package/dist/components/CharacterViewer/collapse.d.ts +10 -0
- package/dist/components/CharacterViewer/collapse.js +39 -0
- package/dist/components/CharacterViewer/index.d.ts +4 -0
- package/dist/components/CharacterViewer/index.js +78 -24
- package/dist/components/CharacterViewer/index.server.d.ts +1 -0
- package/dist/components/CharacterViewer/index.server.js +4 -0
- package/dist/components/ConfigContext.d.ts +14 -10
- package/dist/components/ConfigContext.js +12 -7
- package/dist/components/ConsentBanner/index.js +6 -5
- package/dist/components/CookieNotification/index.js +11 -5
- package/dist/components/CouponText/index.js +15 -7
- package/dist/components/CustomerLoginForm/index.js +14 -9
- package/dist/components/CustomerSignIn/CustomerSignInElement.d.ts +1 -1
- package/dist/components/CustomerSignIn/CustomerSignInElement.js +8 -2
- package/dist/components/CustomerSignIn/index.d.ts +6 -1
- package/dist/components/CustomerSignIn/index.js +27 -15
- package/dist/components/Family/FamilyList.js +5 -2
- package/dist/components/Family/index.js +21 -12
- package/dist/components/FeatureTester/FeatureTesters.d.ts +2 -1
- package/dist/components/FeatureTester/FeatureTesters.js +4 -1
- package/dist/components/FeatureTester/FeatureTesters.server.js +4 -0
- package/dist/components/FeatureTester/index.d.ts +1 -0
- package/dist/components/FeatureTester/index.js +3 -1
- package/dist/components/FeatureTester/index.server.js +2 -0
- package/dist/components/FontdueContextProvider/index.d.ts +12 -2
- package/dist/components/FontdueContextProvider/index.js +85 -11
- package/dist/components/FontdueProvider/index.js +7 -1
- package/dist/components/FontdueProvider/index.server.js +21 -3
- package/dist/components/LocaleContext.d.ts +9 -0
- package/dist/components/LocaleContext.js +20 -0
- package/dist/components/NewsletterSignup/index.d.ts +2 -1
- package/dist/components/NewsletterSignup/index.js +20 -11
- package/dist/components/NewsletterSignup/index.server.d.ts +1 -0
- package/dist/components/NewsletterSignup/index.server.js +3 -1
- package/dist/components/NodePasswordForm/index.d.ts +6 -1
- package/dist/components/NodePasswordForm/index.js +14 -6
- package/dist/components/OrderVariableSelection/index.js +7 -5
- package/dist/components/Precart/License.js +4 -2
- package/dist/components/Precart/index.js +15 -12
- package/dist/components/Price/index.d.ts +1 -0
- package/dist/components/Price/index.js +15 -5
- package/dist/components/Root/index.js +2 -1
- package/dist/components/Select/index.d.ts +1 -1
- package/dist/components/Select/index.js +4 -1
- package/dist/components/SelectButton/index.js +3 -1
- package/dist/components/SpecimenLink/index.js +3 -1
- package/dist/components/StoreModal/StoreModalCart.js +6 -0
- package/dist/components/StoreModal/StoreModalContainer.js +14 -12
- package/dist/components/StoreModal/StoreModalDownload.js +3 -1
- package/dist/components/StoreModal/StoreModalFamily.js +16 -7
- package/dist/components/StoreModal/StoreModalFamilyButton.js +14 -9
- package/dist/components/StoreModal/StoreModalIndexItem.js +21 -10
- package/dist/components/StoreModal/StoreModalIndexPackItem.js +8 -3
- package/dist/components/StoreModal/StoreModalPackButton.js +5 -2
- package/dist/components/StoreModal/StoreModalProduct.js +14 -5
- package/dist/components/StoreModal/index.d.ts +1 -0
- package/dist/components/StoreModal/index.js +4 -2
- package/dist/components/StoreModal/offered.d.ts +31 -0
- package/dist/components/StoreModal/offered.js +21 -0
- package/dist/components/StoreModal/types.d.ts +9 -0
- package/dist/components/StoreModalProductLicenseSelection/LicenseVariableElement.js +3 -1
- package/dist/components/StoreModalProductLicenseSelection/StoreModalProductLicense.js +5 -1
- package/dist/components/StoreModalProductSummary/index.js +37 -23
- package/dist/components/StripeProvider/index.js +18 -5
- package/dist/components/TestFontsForm/index.d.ts +2 -1
- package/dist/components/TestFontsForm/index.js +28 -16
- package/dist/components/TestFontsForm/index.server.d.ts +1 -0
- package/dist/components/TestFontsForm/index.server.js +3 -1
- package/dist/components/TestModeBanner/index.js +3 -1
- package/dist/components/TypeTester/TypeTesterEditAll.js +3 -1
- package/dist/components/TypeTester/TypeTesterFeaturesButton.js +4 -2
- package/dist/components/TypeTester/TypeTesterStandalone.d.ts +1 -0
- package/dist/components/TypeTester/TypeTesterStandalone.js +6 -2
- package/dist/components/TypeTester/TypeTesterStandalone.server.js +2 -0
- package/dist/components/TypeTester/TypeTesterStyleSelect.js +5 -3
- package/dist/components/TypeTester/TypeTesterStyleSelectData.js +3 -1
- package/dist/components/TypeTester/TypeTesterToolbar.js +12 -6
- package/dist/components/TypeTester/index.js +7 -2
- package/dist/components/TypeTesters/index.d.ts +2 -1
- package/dist/components/TypeTesters/index.js +3 -1
- package/dist/components/TypeTesters/index.server.d.ts +1 -0
- package/dist/components/TypeTesters/index.server.js +4 -0
- package/dist/components/elements/EmptyCart/index.js +4 -2
- package/dist/components/elements/StoreModalCartLayout/index.d.ts +1 -0
- package/dist/components/elements/StoreModalCartLayout/index.js +2 -1
- package/dist/components/elements/StoreModalContainer/index.js +4 -2
- package/dist/components/elements/StoreModalDownloadLayout/index.js +3 -1
- package/dist/components/elements/StoreModalIndexItem/index.js +3 -1
- package/dist/components/elements/StoreModalIndexLoadMore/index.js +3 -1
- package/dist/components/elements/StoreModalLicenseeIsBillingIdentityElement.js +4 -2
- package/dist/components/elements/StoreModalLoadingScreen/index.js +7 -3
- package/dist/components/elements/StoreModalUnifiedCheckout.js +44 -27
- package/dist/fontdue.css +58 -0
- package/dist/hooks/useRecaptchaTimeout.d.ts +1 -1
- package/dist/hooks/useRecaptchaTimeout.js +4 -2
- package/dist/i18n/de.d.ts +3 -0
- package/dist/i18n/de.js +279 -0
- package/dist/i18n/en.d.ts +212 -0
- package/dist/i18n/en.js +261 -0
- package/dist/i18n/index.d.ts +42 -0
- package/dist/i18n/index.js +115 -0
- package/dist/i18n/types.d.ts +28 -0
- package/dist/i18n/types.js +1 -0
- package/dist/i18n/useT.d.ts +15 -0
- package/dist/i18n/useT.js +21 -0
- package/dist/locale.d.ts +20 -0
- package/dist/locale.js +52 -0
- package/dist/next/tenant.d.ts +3 -1
- package/dist/next/tenant.js +11 -2
- package/dist/relay/environment.d.ts +8 -2
- package/dist/relay/environment.js +65 -15
- package/dist/relay/loadSerializableQuery.d.ts +17 -0
- package/dist/relay/loadSerializableQuery.js +14 -2
- package/dist/relay/serverConfig.d.ts +9 -0
- package/dist/relay/serverConfig.js +16 -0
- package/dist/relay/useSerializablePreloadedQuery.js +27 -6
- package/dist/server/index.d.ts +11 -0
- package/dist/server/index.js +7 -0
- package/dist/server/middleware.d.ts +19 -1
- package/dist/server/middleware.js +56 -13
- package/dist/utils.d.ts +0 -1
- package/dist/utils.js +0 -5
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/i18n/en.js
ADDED
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
// English – the source of truth for fontdue-js's fixed UI text. Every other
|
|
2
|
+
// catalogue (de.ts) is typed with exactly these keys.
|
|
3
|
+
//
|
|
4
|
+
// Each message is the exact string the component rendered before the catalogue
|
|
5
|
+
// existed (whitespace, punctuation and quote style included), so a site with no
|
|
6
|
+
// locale configured renders byte for byte what it did. Don't tidy the copy
|
|
7
|
+
// here without meaning to change what every English site shows.
|
|
8
|
+
//
|
|
9
|
+
// `{name}` is interpolated from the params; a message given as
|
|
10
|
+
// `{ one, other }` is a plural, picked by `Intl.PluralRules` from `count`.
|
|
11
|
+
|
|
12
|
+
const en = {
|
|
13
|
+
// Shared
|
|
14
|
+
'common.cancel': 'Cancel',
|
|
15
|
+
'common.next': 'Next',
|
|
16
|
+
'common.edit': 'Edit',
|
|
17
|
+
'common.submittingDots': 'Submitting...',
|
|
18
|
+
'common.loadingDots': 'Loading...',
|
|
19
|
+
'common.styleCount': {
|
|
20
|
+
one: '{count} style',
|
|
21
|
+
other: '{count} styles'
|
|
22
|
+
},
|
|
23
|
+
'common.somethingWentWrong': 'Something went wrong',
|
|
24
|
+
'common.loading': 'Loading…',
|
|
25
|
+
'common.variableFontCount': {
|
|
26
|
+
one: '{count} variable font',
|
|
27
|
+
other: '{count} variable fonts'
|
|
28
|
+
},
|
|
29
|
+
'common.errorOccurred': 'An error occurred',
|
|
30
|
+
'common.fontCount': {
|
|
31
|
+
one: '{count} font',
|
|
32
|
+
other: '{count} fonts'
|
|
33
|
+
},
|
|
34
|
+
'common.submit': 'Submit',
|
|
35
|
+
'common.selectOption': 'Select an option',
|
|
36
|
+
'common.itemCount': {
|
|
37
|
+
one: '{count} item',
|
|
38
|
+
other: '{count} items'
|
|
39
|
+
},
|
|
40
|
+
// Store modal: navigation, index and product pages
|
|
41
|
+
'storeModal.buy': 'Buy',
|
|
42
|
+
'storeModal.loadMore': 'Load more',
|
|
43
|
+
'storeModal.cart': 'Cart',
|
|
44
|
+
'storeModal.close': 'Close',
|
|
45
|
+
'storeModal.allCollections': 'All collections',
|
|
46
|
+
'storeModal.buyingOptions': 'Buying options',
|
|
47
|
+
'storeModal.checkout': 'Checkout',
|
|
48
|
+
'storeModal.review': 'Review',
|
|
49
|
+
'storeModal.familyType': 'Family',
|
|
50
|
+
'storeModal.collectionType': 'Collection',
|
|
51
|
+
'storeModal.fontPack': 'Font pack',
|
|
52
|
+
'storeModal.fontPackWithStyles': 'Font pack • {styles}',
|
|
53
|
+
'storeModal.productNotFound': 'Product not found',
|
|
54
|
+
// Store modal product page: selection summary and Add to cart
|
|
55
|
+
'productSummary.exclTax': ' excl. Tax',
|
|
56
|
+
'productSummary.selection': '{fonts} for {price}',
|
|
57
|
+
'productSummary.calculating': 'Calculating price...',
|
|
58
|
+
'productSummary.selectFonts': 'Please select some fonts',
|
|
59
|
+
'productSummary.selectLicense': 'Please select a license',
|
|
60
|
+
// {nameLower} is the variable's name lowercased for the page's locale, for
|
|
61
|
+
// languages that lowercase a noun mid-sentence; {name} is it as entered.
|
|
62
|
+
'productSummary.selectVariable': 'Please select a {nameLower}',
|
|
63
|
+
'productSummary.selectLicensee': 'Please select the licensee',
|
|
64
|
+
'productSummary.adding': 'Adding...',
|
|
65
|
+
'productSummary.addToCart': 'Add to cart',
|
|
66
|
+
'productSummary.emptyCartAndRetry': 'Empty cart and try again',
|
|
67
|
+
// License selection
|
|
68
|
+
'license.selectVariable': 'Select {name}',
|
|
69
|
+
// Order variables
|
|
70
|
+
'orderVariable.deprecatedOption': '(Deprecated)',
|
|
71
|
+
'orderVariable.removed': 'This variable has been removed from our system and is deprecated',
|
|
72
|
+
'orderVariable.remove': 'Remove',
|
|
73
|
+
// Cart
|
|
74
|
+
'cart.yourCart': 'Your cart',
|
|
75
|
+
'cart.contactInformation': 'Contact information',
|
|
76
|
+
'cart.billingInformation': 'Billing information',
|
|
77
|
+
'cart.licenseeInformation': 'Licensee information',
|
|
78
|
+
'cart.payment': 'Payment',
|
|
79
|
+
'cart.orderProblem': 'There was a problem with your order. {button} to empty your cart and continue shopping.',
|
|
80
|
+
'cart.orderProblemButton': 'Click here',
|
|
81
|
+
'cart.completeWithCoupon': 'Complete order using coupon',
|
|
82
|
+
'cart.submitPayment': 'Submit payment',
|
|
83
|
+
'cart.proceed': 'Proceed',
|
|
84
|
+
'cart.proceedToCheckout': 'Proceed to checkout',
|
|
85
|
+
'cart.paymentRetry': 'We were unable to complete your payment, please re-enter your card details and try again',
|
|
86
|
+
'cart.subtotal': 'Subtotal',
|
|
87
|
+
'cart.discountApplied': 'Discount applied',
|
|
88
|
+
'cart.removeDiscount': 'Remove discount',
|
|
89
|
+
'cart.discountedSubtotal': 'Discounted subtotal',
|
|
90
|
+
'cart.vat': 'VAT',
|
|
91
|
+
'cart.taxNotApplicable': '{tax} not applicable',
|
|
92
|
+
'cart.tax': 'Tax',
|
|
93
|
+
'cart.calculatedAtCheckout': 'Calculated at checkout',
|
|
94
|
+
'cart.total': 'Total',
|
|
95
|
+
'cart.totalIncludingGst': 'Total including GST',
|
|
96
|
+
'cart.empty': 'Your cart is empty',
|
|
97
|
+
'cart.vatNumber': 'VAT: {number}',
|
|
98
|
+
// Cart items
|
|
99
|
+
'cartItem.addLicense': '+ Add:',
|
|
100
|
+
'cartItem.removeLicense': 'Remove license',
|
|
101
|
+
'cartItem.variableFont': 'Variable font',
|
|
102
|
+
'cartItem.updating': 'Updating...',
|
|
103
|
+
'cartItem.enterValue': 'Enter {name}',
|
|
104
|
+
'cartItem.licenseSelectionsError': 'License selections {errors}',
|
|
105
|
+
// Empty cart
|
|
106
|
+
'emptyCart.message': 'Your cart is empty.',
|
|
107
|
+
'emptyCart.continueShopping': 'Continue shopping',
|
|
108
|
+
// Coupons
|
|
109
|
+
'coupon.add': 'Add a coupon code',
|
|
110
|
+
'coupon.placeholder': 'Enter code',
|
|
111
|
+
'coupon.apply': 'Apply',
|
|
112
|
+
'coupon.remaining': '{price} remaining',
|
|
113
|
+
'coupon.percentOff': '{percent}% off',
|
|
114
|
+
'coupon.amountOff': '{price} off',
|
|
115
|
+
'coupon.removed': 'Your discount was removed because it doesn’t apply to the items left in your cart.',
|
|
116
|
+
// Sharing a cart
|
|
117
|
+
'shareCart.failed': 'Failed to create shareable link',
|
|
118
|
+
'shareCart.title': 'Share your cart',
|
|
119
|
+
'shareCart.copy': 'Copy',
|
|
120
|
+
'shareCart.downloadPdfQuote': 'Download PDF quote',
|
|
121
|
+
'shareCart.share': 'Share cart',
|
|
122
|
+
'shareCart.error': 'Cannot share your cart right now. Please try again later.',
|
|
123
|
+
// Checkout
|
|
124
|
+
'checkout.correctErrors': 'Please correct the errors.',
|
|
125
|
+
'checkout.unknownStripeError': 'Unknown Stripe error',
|
|
126
|
+
'checkout.sameBillingDetailsForLicensee': 'Use the same billing details for licensee',
|
|
127
|
+
'checkout.enterCard': 'Please enter your credit card info.',
|
|
128
|
+
'checkout.securePayments': '(Secure payments powered by Stripe)',
|
|
129
|
+
'checkout.change': 'Change',
|
|
130
|
+
'checkout.completeBilling': 'Please complete all billing information above',
|
|
131
|
+
'checkout.paymentFailed': 'Payment failed. Please try another payment method.',
|
|
132
|
+
'checkout.save': 'Save',
|
|
133
|
+
'checkout.continue': 'Continue',
|
|
134
|
+
'checkout.checkout': 'Checkout',
|
|
135
|
+
'checkout.licenseeSelf': 'Yourself',
|
|
136
|
+
'checkout.licenseeClient': 'Your client',
|
|
137
|
+
'checkout.licenseeInformationClient': 'Licensee information (your client)',
|
|
138
|
+
'checkout.paymentInformation': 'Payment information',
|
|
139
|
+
'checkout.poweredBy': 'Powered by {logo}',
|
|
140
|
+
'checkout.completeOrder': 'Complete order',
|
|
141
|
+
'checkout.pay': 'Pay {price}',
|
|
142
|
+
// Address and contact fields
|
|
143
|
+
'address.organization': 'Organization',
|
|
144
|
+
'address.contactEmail': 'Contact email',
|
|
145
|
+
'address.email': 'Email',
|
|
146
|
+
'address.vatNumber': 'VAT number',
|
|
147
|
+
'customerFields.nameRequired': 'Name *',
|
|
148
|
+
'customerFields.namePlaceholder': 'Your name',
|
|
149
|
+
'customerFields.emailRequired': 'Email *',
|
|
150
|
+
'customerFields.emailPlaceholder': 'Your email',
|
|
151
|
+
// After the order
|
|
152
|
+
'download.downloadYourOrder': 'Download your order',
|
|
153
|
+
'download.confirmed': 'Your order was confirmed.',
|
|
154
|
+
'download.ready': 'Your download is ready.',
|
|
155
|
+
'download.preparing': 'Your download is being prepared...',
|
|
156
|
+
'download.receiptSent': 'An email receipt with a download link has been sent to your email address.',
|
|
157
|
+
// Add-to-cart banner
|
|
158
|
+
'addToCart.banner': 'You added {item} to your cart',
|
|
159
|
+
// Precart (legacy buying panel)
|
|
160
|
+
'precart.confirmTitle': 'Do you want to add your selection to your cart?',
|
|
161
|
+
'precart.addSelection': 'Add selection to cart:',
|
|
162
|
+
'precart.clearSelection': 'Clear selection',
|
|
163
|
+
'precart.yourSelection': 'Your Selection',
|
|
164
|
+
'precart.bundleDiscounts': 'Bundle discounts:',
|
|
165
|
+
'precart.startSelecting': 'Start selecting fonts to add to your cart',
|
|
166
|
+
'precart.info': 'Info',
|
|
167
|
+
'precart.selectOne': 'Select one',
|
|
168
|
+
// Buy button
|
|
169
|
+
'buyButton.label': 'Buy {name}',
|
|
170
|
+
// A product whose name isn't known: the English keeps the space it always had.
|
|
171
|
+
'buyButton.labelNoName': 'Buy ',
|
|
172
|
+
// Family listing
|
|
173
|
+
'family.superFamily': '{name} Super family',
|
|
174
|
+
// The plural form has always used a no-break space.
|
|
175
|
+
'family.variableAxisCount': {
|
|
176
|
+
one: '{count} variable axis',
|
|
177
|
+
other: '{count}\u00A0variable axes'
|
|
178
|
+
},
|
|
179
|
+
'family.namedInstanceCount': {
|
|
180
|
+
one: '{count} named instance',
|
|
181
|
+
other: '{count} named instances'
|
|
182
|
+
},
|
|
183
|
+
// Customer sign-in
|
|
184
|
+
'signIn.request': 'Email me a code',
|
|
185
|
+
'signIn.verify': 'Sign in',
|
|
186
|
+
'signIn.rateLimited': 'Too many codes requested. Please wait a few minutes and try again.',
|
|
187
|
+
'signIn.invalidCode': 'That code isn’t right, or it has expired. Ask for a new one.',
|
|
188
|
+
'signIn.codeSent': 'If {email} has an account, a six-digit code is on its way. It works once, and for ten minutes.',
|
|
189
|
+
'signIn.codeLabel': 'Code *',
|
|
190
|
+
'signIn.signingIn': 'Signing in...',
|
|
191
|
+
'signIn.differentEmail': 'Use a different email',
|
|
192
|
+
'signIn.sending': 'Sending...',
|
|
193
|
+
'signIn.signOut': 'Sign out',
|
|
194
|
+
'signIn.signedInAs': 'Signed in as {name}.',
|
|
195
|
+
// Customer login form (sign-in link)
|
|
196
|
+
// HTML: shown after a sign-in link was requested, unless the foundry set its own.
|
|
197
|
+
'loginForm.submittedHtml': '<p>Submitted!</p><p>Please check your email inbox for a link to log in.</p><p>If you don’t receive an email, please contact us to retrieve your order information.</p>',
|
|
198
|
+
// reCAPTCHA
|
|
199
|
+
'recaptcha.unavailable': 'We couldn’t verify that you’re human. Please refresh the page and try again.',
|
|
200
|
+
// Newsletter sign-up
|
|
201
|
+
'newsletter.subscribe': 'Subscribe',
|
|
202
|
+
'newsletter.success': 'Success!',
|
|
203
|
+
// Test fonts form
|
|
204
|
+
'testFonts.downloadStarting': 'The download will start automatically.',
|
|
205
|
+
'testFonts.downloadFallback': 'If it didn’t start, click {link}.',
|
|
206
|
+
'testFonts.downloadFallbackLink': 'here',
|
|
207
|
+
'testFonts.download': 'Download test fonts',
|
|
208
|
+
'testFonts.unavailable': 'Test fonts aren’t available for this family.',
|
|
209
|
+
'testFonts.families': 'Families',
|
|
210
|
+
'testFonts.selectAll': 'Select all',
|
|
211
|
+
// Password-protected collections
|
|
212
|
+
'password.incorrect': 'Incorrect password',
|
|
213
|
+
'password.label': 'Password *',
|
|
214
|
+
'password.placeholder': 'Enter password',
|
|
215
|
+
// Type tester
|
|
216
|
+
'typeTester.select': 'Select',
|
|
217
|
+
'typeTester.size': 'Size',
|
|
218
|
+
'typeTester.lineHeight': 'Line height',
|
|
219
|
+
'typeTester.letterSpacing': 'Letter spacing',
|
|
220
|
+
'typeTester.otFeatures': 'OT Features',
|
|
221
|
+
'typeTester.variableAxes': 'Variable axes...',
|
|
222
|
+
'typeTester.custom': 'Custom',
|
|
223
|
+
'typeTester.affectAllStyles': 'Affect all styles',
|
|
224
|
+
// The standalone type tester's sample text when the site gives none.
|
|
225
|
+
'typeTester.sampleText': 'The quick brown fox...',
|
|
226
|
+
// Character viewer
|
|
227
|
+
'characterViewer.glyphName': 'Glyph name',
|
|
228
|
+
'characterViewer.unicodeName': 'Unicode name',
|
|
229
|
+
'characterViewer.unicodeDecimal': 'Unicode decimal',
|
|
230
|
+
'characterViewer.unicodeHex': 'Unicode hex',
|
|
231
|
+
'characterViewer.openTypeFeatures': {
|
|
232
|
+
one: 'OpenType feature',
|
|
233
|
+
other: 'OpenType features'
|
|
234
|
+
},
|
|
235
|
+
'characterViewer.baseline': 'Baseline',
|
|
236
|
+
'characterViewer.capHeight': 'Cap height',
|
|
237
|
+
'characterViewer.xHeight': 'x-Height',
|
|
238
|
+
'characterViewer.ascender': 'Ascender',
|
|
239
|
+
'characterViewer.descender': 'Descender',
|
|
240
|
+
'characterViewer.fontStyle': 'Font style',
|
|
241
|
+
'characterViewer.loadMore': 'Load more',
|
|
242
|
+
// Select boxes
|
|
243
|
+
'select.placeholder': 'Select',
|
|
244
|
+
// Specimen link
|
|
245
|
+
'specimen.link': 'PDF Specimen',
|
|
246
|
+
// Consent banner
|
|
247
|
+
'consent.message': 'We use cookies to analyze site usage and improve your\u00A0experience.',
|
|
248
|
+
'consent.label': 'Cookie consent',
|
|
249
|
+
'consent.necessaryOnly': 'Necessary only',
|
|
250
|
+
'consent.acceptAll': 'Accept all',
|
|
251
|
+
// Cookie notice (legacy)
|
|
252
|
+
// The legacy cookie notice (CookieNotification); its copy names the domain
|
|
253
|
+
// it was written for.
|
|
254
|
+
'cookies.title': '{siteTitle} website uses cookies',
|
|
255
|
+
'cookies.text': 'We use cookies to ensure that we give you the best experience. By continuing to visit this site you agree to receive cookies from generaltypestudio.com. You can read more about cookies in our {link}.',
|
|
256
|
+
'cookies.privacyPolicy': 'privacy policy',
|
|
257
|
+
'cookies.gotIt': 'Got it',
|
|
258
|
+
// Test mode
|
|
259
|
+
'testMode.banner': 'Viewing test data'
|
|
260
|
+
};
|
|
261
|
+
export default en;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { MessageKey, MessageParams } from './types.js';
|
|
3
|
+
export type { Catalogue, Message, MessageKey, MessageParams, PluralMessage } from './types.js';
|
|
4
|
+
/** The languages fontdue-js ships UI text for. */
|
|
5
|
+
export declare const SUPPORTED_LANGUAGES: string[];
|
|
6
|
+
/**
|
|
7
|
+
* The catalogue language for a configured locale: the exact tag when it has
|
|
8
|
+
* its own catalogue, else its language (`de-AT` → `de`), else English. An
|
|
9
|
+
* unset locale is English.
|
|
10
|
+
*/
|
|
11
|
+
export declare function resolveLanguage(locale: string | null | undefined): string;
|
|
12
|
+
/**
|
|
13
|
+
* A message in the catalogue for `locale` (see `resolveLanguage`), with
|
|
14
|
+
* `{name}` placeholders filled from `params`. A plural message picks its form
|
|
15
|
+
* from `params.count` with `Intl.PluralRules`. For code outside a React render
|
|
16
|
+
* – event handlers can use the hook's `t` too.
|
|
17
|
+
*
|
|
18
|
+
* ```ts
|
|
19
|
+
* translate('de', 'storeModal.styleCount', { count: 3 }) // "3 Schnitte"
|
|
20
|
+
* translate(undefined, 'storeModal.styleCount', { count: 1 }) // "1 style"
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export declare function translate(locale: string | null | undefined, key: MessageKey, params?: MessageParams): string;
|
|
24
|
+
export type RichParams = Record<string, React.ReactNode>;
|
|
25
|
+
export interface Translate {
|
|
26
|
+
(key: MessageKey, params?: MessageParams): string;
|
|
27
|
+
/**
|
|
28
|
+
* Like `t()`, but a placeholder can be filled with a React node (a link, a
|
|
29
|
+
* button) – for a sentence with an element in the middle, so each language
|
|
30
|
+
* can put it where its grammar needs it.
|
|
31
|
+
*/
|
|
32
|
+
rich(key: MessageKey, params: RichParams): React.ReactNode;
|
|
33
|
+
/** The catalogue language in use (`en`, `de`). */
|
|
34
|
+
language: string;
|
|
35
|
+
/** The configured locale, or undefined when none is set. */
|
|
36
|
+
locale: string | undefined;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* A `t` bound to a configured locale – the same function for the same locale,
|
|
40
|
+
* so it is safe in hook dependency lists. `useT()` is the React way to get one.
|
|
41
|
+
*/
|
|
42
|
+
export declare function translatorFor(locale: string | null | undefined): Translate;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import en from './en.js';
|
|
3
|
+
import de from './de.js';
|
|
4
|
+
// fontdue-js's fixed UI text. Every hard-coded default a component renders
|
|
5
|
+
// (button labels, headings, errors, aria-labels) is a key in `en.ts`, and each
|
|
6
|
+
// other language is a catalogue with exactly the same keys (enforced by the
|
|
7
|
+
// `Catalogue` type, so a missing translation fails `npm run build-ts`).
|
|
8
|
+
//
|
|
9
|
+
// Precedence is unchanged by this layer: a label prop, a config label or a
|
|
10
|
+
// foundry-authored settings label still wins, and only the fallback a
|
|
11
|
+
// component used to hard-code goes through `t()`.
|
|
12
|
+
//
|
|
13
|
+
// With no locale configured, `t()` returns the English message, which is the
|
|
14
|
+
// exact string the component used to render – existing sites see no change.
|
|
15
|
+
//
|
|
16
|
+
// Deliberately in-house rather than a dependency: two small catalogues, `{name}`
|
|
17
|
+
// interpolation and `Intl.PluralRules` is all fontdue-js needs, and a package
|
|
18
|
+
// would add weight to every build and another CJS/ESM interop risk across the
|
|
19
|
+
// Next RSC, Astro, React Router and script-tag builds.
|
|
20
|
+
|
|
21
|
+
const CATALOGUES = {
|
|
22
|
+
en,
|
|
23
|
+
de
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/** The languages fontdue-js ships UI text for. */
|
|
27
|
+
export const SUPPORTED_LANGUAGES = Object.keys(CATALOGUES);
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* The catalogue language for a configured locale: the exact tag when it has
|
|
31
|
+
* its own catalogue, else its language (`de-AT` → `de`), else English. An
|
|
32
|
+
* unset locale is English.
|
|
33
|
+
*/
|
|
34
|
+
export function resolveLanguage(locale) {
|
|
35
|
+
const lower = locale === null || locale === void 0 ? void 0 : locale.trim().toLowerCase().replace(/_/g, '-');
|
|
36
|
+
if (!lower) return 'en';
|
|
37
|
+
if (CATALOGUES[lower]) return lower;
|
|
38
|
+
const language = lower.split('-')[0];
|
|
39
|
+
return CATALOGUES[language] ? language : 'en';
|
|
40
|
+
}
|
|
41
|
+
const pluralRules = new Map();
|
|
42
|
+
function pluralForm(language, message, count) {
|
|
43
|
+
let rules = pluralRules.get(language);
|
|
44
|
+
if (!rules) {
|
|
45
|
+
rules = new Intl.PluralRules(language);
|
|
46
|
+
pluralRules.set(language, rules);
|
|
47
|
+
}
|
|
48
|
+
const category = rules.select(count);
|
|
49
|
+
return message[category] ?? message.other;
|
|
50
|
+
}
|
|
51
|
+
function pick(language, key, params) {
|
|
52
|
+
var _CATALOGUES$language;
|
|
53
|
+
const message = ((_CATALOGUES$language = CATALOGUES[language]) === null || _CATALOGUES$language === void 0 ? void 0 : _CATALOGUES$language[key]) ?? en[key];
|
|
54
|
+
if (message === undefined) return key;
|
|
55
|
+
if (typeof message === 'string') return message;
|
|
56
|
+
const count = Number((params === null || params === void 0 ? void 0 : params.count) ?? 0);
|
|
57
|
+
return pluralForm(language, message, count);
|
|
58
|
+
}
|
|
59
|
+
const PARAM = /\{(\w+)\}/g;
|
|
60
|
+
function interpolate(message, params) {
|
|
61
|
+
if (!params) return message;
|
|
62
|
+
return message.replace(PARAM, (match, name) => name in params ? String(params[name]) : match);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* A message in the catalogue for `locale` (see `resolveLanguage`), with
|
|
67
|
+
* `{name}` placeholders filled from `params`. A plural message picks its form
|
|
68
|
+
* from `params.count` with `Intl.PluralRules`. For code outside a React render
|
|
69
|
+
* – event handlers can use the hook's `t` too.
|
|
70
|
+
*
|
|
71
|
+
* ```ts
|
|
72
|
+
* translate('de', 'storeModal.styleCount', { count: 3 }) // "3 Schnitte"
|
|
73
|
+
* translate(undefined, 'storeModal.styleCount', { count: 1 }) // "1 style"
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
export function translate(locale, key, params) {
|
|
77
|
+
return interpolate(pick(resolveLanguage(locale), key, params), params);
|
|
78
|
+
}
|
|
79
|
+
function rich(language, key, params) {
|
|
80
|
+
const countParam = params.count;
|
|
81
|
+
const message = pick(language, key, typeof countParam === 'number' ? {
|
|
82
|
+
count: countParam
|
|
83
|
+
} : undefined);
|
|
84
|
+
// split() with a capture group alternates text and placeholder names.
|
|
85
|
+
const parts = [];
|
|
86
|
+
message.split(/\{(\w+)\}/).forEach((piece, i) => {
|
|
87
|
+
if (i % 2 === 0) {
|
|
88
|
+
if (piece) parts.push(piece);
|
|
89
|
+
} else {
|
|
90
|
+
parts.push(piece in params ? params[piece] : `{${piece}}`);
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
// Children passed as arguments, not an array, so React needs no keys.
|
|
94
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, ...parts);
|
|
95
|
+
}
|
|
96
|
+
const translators = new Map();
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* A `t` bound to a configured locale – the same function for the same locale,
|
|
100
|
+
* so it is safe in hook dependency lists. `useT()` is the React way to get one.
|
|
101
|
+
*/
|
|
102
|
+
export function translatorFor(locale) {
|
|
103
|
+
const cacheKey = locale ?? '';
|
|
104
|
+
let t = translators.get(cacheKey);
|
|
105
|
+
if (!t) {
|
|
106
|
+
const language = resolveLanguage(locale);
|
|
107
|
+
const bound = (key, params) => interpolate(pick(language, key, params), params);
|
|
108
|
+
bound.rich = (key, params) => rich(language, key, params);
|
|
109
|
+
bound.language = language;
|
|
110
|
+
bound.locale = locale ?? undefined;
|
|
111
|
+
t = bound;
|
|
112
|
+
translators.set(cacheKey, t);
|
|
113
|
+
}
|
|
114
|
+
return t;
|
|
115
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type en from './en.js';
|
|
2
|
+
/**
|
|
3
|
+
* A message that varies with a count: one form per `Intl.PluralRules`
|
|
4
|
+
* category the language uses, with `other` always required. `{count}` (and
|
|
5
|
+
* any other `{param}`) is interpolated after the form is picked.
|
|
6
|
+
*/
|
|
7
|
+
export type PluralMessage = {
|
|
8
|
+
readonly zero?: string;
|
|
9
|
+
readonly one?: string;
|
|
10
|
+
readonly two?: string;
|
|
11
|
+
readonly few?: string;
|
|
12
|
+
readonly many?: string;
|
|
13
|
+
readonly other: string;
|
|
14
|
+
};
|
|
15
|
+
export type Message = string | PluralMessage;
|
|
16
|
+
/** Every message key, taken from the English catalogue (the source of truth). */
|
|
17
|
+
export type MessageKey = keyof typeof en;
|
|
18
|
+
type ShapeOf<M> = M extends string ? string : PluralMessage;
|
|
19
|
+
/**
|
|
20
|
+
* The type every other catalogue is declared with: exactly the English keys
|
|
21
|
+
* (a missing key, or one English doesn't have, fails `npm run build-ts`), each
|
|
22
|
+
* with the English message's shape.
|
|
23
|
+
*/
|
|
24
|
+
export type Catalogue = {
|
|
25
|
+
readonly [K in MessageKey]: ShapeOf<(typeof en)[K]>;
|
|
26
|
+
};
|
|
27
|
+
export type MessageParams = Record<string, string | number>;
|
|
28
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type Translate } from './index.js';
|
|
2
|
+
/**
|
|
3
|
+
* `t(key, params?)` for the surrounding provider's locale (English when none
|
|
4
|
+
* is set). Only for hard-coded defaults: a label prop, a config label or a
|
|
5
|
+
* foundry-authored label still takes precedence –
|
|
6
|
+
* `label ?? t('buyButton.label')`.
|
|
7
|
+
*
|
|
8
|
+
* ```tsx
|
|
9
|
+
* const t = useT();
|
|
10
|
+
* <button>{t('cart.checkout')}</button>
|
|
11
|
+
* <span>{t('storeModal.styleCount', { count: 3 })}</span>
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export declare function useT(): Translate;
|
|
15
|
+
export default useT;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useLocale } from '../components/LocaleContext.js';
|
|
4
|
+
import { translatorFor } from './index.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* `t(key, params?)` for the surrounding provider's locale (English when none
|
|
8
|
+
* is set). Only for hard-coded defaults: a label prop, a config label or a
|
|
9
|
+
* foundry-authored label still takes precedence –
|
|
10
|
+
* `label ?? t('buyButton.label')`.
|
|
11
|
+
*
|
|
12
|
+
* ```tsx
|
|
13
|
+
* const t = useT();
|
|
14
|
+
* <button>{t('cart.checkout')}</button>
|
|
15
|
+
* <span>{t('storeModal.styleCount', { count: 3 })}</span>
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export function useT() {
|
|
19
|
+
return translatorFor(useLocale());
|
|
20
|
+
}
|
|
21
|
+
export default useT;
|
package/dist/locale.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { StripeElementLocale } from '@stripe/stripe-js';
|
|
2
|
+
export declare const LOCALE_HEADER = "fontdue-locale";
|
|
3
|
+
/**
|
|
4
|
+
* A configured locale, or undefined when none is set. Blank strings count as
|
|
5
|
+
* unset, so `locale=""` (an empty attribute, an unset env var) behaves exactly
|
|
6
|
+
* like no locale at all.
|
|
7
|
+
*/
|
|
8
|
+
export declare function normalizeLocale(locale: string | null | undefined): string | undefined;
|
|
9
|
+
/**
|
|
10
|
+
* `{ 'fontdue-locale': locale }` for a configured locale, `{}` otherwise –
|
|
11
|
+
* spread into a request's headers so an unset locale adds nothing at all.
|
|
12
|
+
*/
|
|
13
|
+
export declare function localeHeaders(locale: string | null | undefined): Record<string, string>;
|
|
14
|
+
/**
|
|
15
|
+
* The Stripe Elements `locale` for a site's configured locale: the exact
|
|
16
|
+
* Stripe locale when there is one (`pt-BR`), else its language (`de-AT` →
|
|
17
|
+
* `de`), else `'auto'` (Stripe follows the browser). Undefined when the site
|
|
18
|
+
* configured no locale, so Elements is created exactly as before.
|
|
19
|
+
*/
|
|
20
|
+
export declare function stripeElementsLocale(locale: string | undefined): StripeElementLocale | undefined;
|
package/dist/locale.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// The language a site asks Fontdue to answer in. A site that configures a
|
|
2
|
+
// `locale` (FontdueProvider, the server config, createFontdueFetch, the
|
|
3
|
+
// script-tag `initialize`) sends it on every GraphQL request as this header,
|
|
4
|
+
// from all three transports: the Relay network layer (relay/environment.ts),
|
|
5
|
+
// createFontdueFetch (server/index.ts) and the script-tag bootstrap's config
|
|
6
|
+
// fetch (assets/fontdue/index.tsx). With no locale configured the header is
|
|
7
|
+
// never sent, and the server answers in the foundry's default language, so
|
|
8
|
+
// existing sites are unchanged.
|
|
9
|
+
//
|
|
10
|
+
// Deliberately not Accept-Language: browsers attach that to every fetch, so
|
|
11
|
+
// browser fetches would disagree with server-rendered ones (a page in two
|
|
12
|
+
// languages, hydration mismatches), and every deployed site would switch
|
|
13
|
+
// language the day a foundry enabled one.
|
|
14
|
+
export const LOCALE_HEADER = 'fontdue-locale';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* A configured locale, or undefined when none is set. Blank strings count as
|
|
18
|
+
* unset, so `locale=""` (an empty attribute, an unset env var) behaves exactly
|
|
19
|
+
* like no locale at all.
|
|
20
|
+
*/
|
|
21
|
+
export function normalizeLocale(locale) {
|
|
22
|
+
const trimmed = locale === null || locale === void 0 ? void 0 : locale.trim();
|
|
23
|
+
return trimmed ? trimmed : undefined;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* `{ 'fontdue-locale': locale }` for a configured locale, `{}` otherwise –
|
|
28
|
+
* spread into a request's headers so an unset locale adds nothing at all.
|
|
29
|
+
*/
|
|
30
|
+
export function localeHeaders(locale) {
|
|
31
|
+
const normalized = normalizeLocale(locale);
|
|
32
|
+
return normalized ? {
|
|
33
|
+
[LOCALE_HEADER]: normalized
|
|
34
|
+
} : {};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Every locale Stripe Elements accepts (StripeElementLocale in
|
|
38
|
+
// @stripe/stripe-js), keyed lowercase so `de-de` finds `de` via its language.
|
|
39
|
+
const STRIPE_ELEMENT_LOCALES = ['ar', 'bg', 'cs', 'da', 'de', 'el', 'en', 'en-AU', 'en-CA', 'en-NZ', 'en-GB', 'es', 'es-ES', 'es-419', 'et', 'fi', 'fil', 'fr', 'fr-CA', 'fr-FR', 'he', 'hu', 'hr', 'id', 'it', 'it-IT', 'ja', 'ko', 'lt', 'lv', 'ms', 'mt', 'nb', 'nl', 'no', 'pl', 'pt', 'pt-BR', 'ro', 'ru', 'sk', 'sl', 'sv', 'th', 'tr', 'vi', 'zh', 'zh-HK', 'zh-TW'];
|
|
40
|
+
const STRIPE_BY_LOWERCASE = new Map(STRIPE_ELEMENT_LOCALES.map(l => [l.toLowerCase(), l]));
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* The Stripe Elements `locale` for a site's configured locale: the exact
|
|
44
|
+
* Stripe locale when there is one (`pt-BR`), else its language (`de-AT` →
|
|
45
|
+
* `de`), else `'auto'` (Stripe follows the browser). Undefined when the site
|
|
46
|
+
* configured no locale, so Elements is created exactly as before.
|
|
47
|
+
*/
|
|
48
|
+
export function stripeElementsLocale(locale) {
|
|
49
|
+
if (!locale) return undefined;
|
|
50
|
+
const lower = locale.toLowerCase();
|
|
51
|
+
return STRIPE_BY_LOWERCASE.get(lower) ?? STRIPE_BY_LOWERCASE.get(lower.split(/[-_]/)[0]) ?? 'auto';
|
|
52
|
+
}
|
package/dist/next/tenant.d.ts
CHANGED
|
@@ -17,7 +17,9 @@ export interface FontdueEndpoint {
|
|
|
17
17
|
}
|
|
18
18
|
export declare function endpointForDomain(domain: string): FontdueEndpoint;
|
|
19
19
|
export declare function fontdueServerConfig(domain: string): FontdueServerConfig;
|
|
20
|
-
export declare function configureFontdueRender(domain: string
|
|
20
|
+
export declare function configureFontdueRender(domain: string, options?: {
|
|
21
|
+
locale?: string;
|
|
22
|
+
}): FontdueEndpoint | null;
|
|
21
23
|
interface RenderProps {
|
|
22
24
|
params: Promise<Record<string, string | string[] | undefined>>;
|
|
23
25
|
}
|
package/dist/next/tenant.js
CHANGED
|
@@ -30,6 +30,7 @@ import { cookies, draftMode } from 'next/headers';
|
|
|
30
30
|
import { setFontdueServerConfig } from '../relay/serverConfig.js';
|
|
31
31
|
import { PREVIEW_TOKEN_COOKIE, previewAuthHeaders } from '../preview/index.js';
|
|
32
32
|
import { NODE_ACCESS_COOKIE, NODE_ACCESS_HEADER } from '../nodeAccess.js';
|
|
33
|
+
import { normalizeLocale } from '../locale.js';
|
|
33
34
|
export const isMultiTenant = process.env.FONTDUE_MULTI_TENANT === '1';
|
|
34
35
|
export const singleTenantUrl = process.env.NEXT_PUBLIC_FONTDUE_URL;
|
|
35
36
|
const internalOrigin = process.env.FONTDUE_ORIGIN;
|
|
@@ -103,10 +104,18 @@ export function fontdueServerConfig(domain) {
|
|
|
103
104
|
//
|
|
104
105
|
// Call it in a data helper every page goes through, not only in the root
|
|
105
106
|
// layout: an App Router soft navigation re-renders just the page segment,
|
|
106
|
-
// and the per-render config store starts empty on every pass.
|
|
107
|
+
// and the per-render config store starts empty on every pass. The same goes
|
|
108
|
+
// for `locale`: pass the page's language on every call.
|
|
107
109
|
export function configureFontdueRender(domain) {
|
|
110
|
+
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
108
111
|
if (!isValidDomain(domain)) return null;
|
|
109
|
-
|
|
112
|
+
const locale = normalizeLocale(options.locale);
|
|
113
|
+
setFontdueServerConfig({
|
|
114
|
+
...fontdueServerConfig(domain),
|
|
115
|
+
...(locale ? {
|
|
116
|
+
locale
|
|
117
|
+
} : {})
|
|
118
|
+
});
|
|
110
119
|
return endpointForDomain(domain);
|
|
111
120
|
}
|
|
112
121
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Environment, RequestParameters, QueryResponseCache, Variables, GraphQLResponse } from 'relay-runtime';
|
|
1
|
+
import { Environment, RequestParameters, QueryResponseCache, Variables, GraphQLResponse, IEnvironment } from 'relay-runtime';
|
|
2
2
|
import { version } from '../version.js';
|
|
3
3
|
export { version };
|
|
4
4
|
/**
|
|
@@ -18,7 +18,8 @@ export declare class FontdueResponseError extends Error {
|
|
|
18
18
|
export declare function fontdueBaseUrl(): string | undefined;
|
|
19
19
|
export declare function createNetworkFetch(options?: CreateRelayEnvironmentOptions): (request: RequestParameters, variables: Variables) => Promise<GraphQLResponse>;
|
|
20
20
|
export declare const networkFetch: (request: RequestParameters, variables: Variables) => Promise<GraphQLResponse>;
|
|
21
|
-
|
|
21
|
+
/** The response cache of a client environment, or null on the server. */
|
|
22
|
+
export declare function responseCacheFor(environment: IEnvironment): QueryResponseCache | null;
|
|
22
23
|
interface CreateRelayEnvironmentOptions {
|
|
23
24
|
url?: string;
|
|
24
25
|
/**
|
|
@@ -28,6 +29,11 @@ interface CreateRelayEnvironmentOptions {
|
|
|
28
29
|
*/
|
|
29
30
|
headers?: Record<string, string>;
|
|
30
31
|
stripeIntegration?: 'card-element' | 'dynamic';
|
|
32
|
+
/**
|
|
33
|
+
* The language to ask Fontdue for (sent as `fontdue-locale`). On the server
|
|
34
|
+
* it falls back to the render's server config; unset sends no header.
|
|
35
|
+
*/
|
|
36
|
+
locale?: string;
|
|
31
37
|
}
|
|
32
38
|
export declare function createEnvironment(options: CreateRelayEnvironmentOptions): Environment;
|
|
33
39
|
export declare function useCurrentEnvironment(options: CreateRelayEnvironmentOptions): Environment;
|