@mrcharles/sdk 0.1.0 → 0.2.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/README.md +20 -1
- package/dist/mrcharles.esm.js +685 -19
- package/dist/mrcharles.esm.js.map +12 -10
- package/dist/mrcharles.min.js +2 -2
- package/dist/mrcharles.min.js.map +12 -10
- package/dist/types/client.d.ts +16 -0
- package/dist/types/embed.d.ts +3 -1
- package/dist/types/env.d.ts +7 -1
- package/dist/types/format.d.ts +24 -0
- package/dist/types/http.d.ts +1 -1
- package/dist/types/i18n.d.ts +50 -0
- package/dist/types/index.d.ts +3 -1
- package/dist/types/links.d.ts +4 -3
- package/dist/types/rooms.d.ts +15 -3
- package/dist/types/types.d.ts +8 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -90,11 +90,30 @@ const site = await mc.sites.get('studio-uno-madrid'); // at build / on request
|
|
|
90
90
|
Availability and holds must run in the browser (or forward the guest's IP in
|
|
91
91
|
`headers: { 'X-Forwarded-For': ip }` when you proxy them).
|
|
92
92
|
|
|
93
|
+
## Languages
|
|
94
|
+
|
|
95
|
+
One `locale` on the client drives everything: the hosted screen's language, the guest's SMS/email, `Accept-Language`, the SDK's own strings and its formatting.
|
|
96
|
+
|
|
97
|
+
```js
|
|
98
|
+
const mc = createClient({ locale: 'ca' }); // any BCP-47 tag: 'ca-ES', 'pt-BR'…
|
|
99
|
+
mc.mountRoomBooking('#book', { slug, roomId }); // screen in Catalan, code in Catalan
|
|
100
|
+
mc.t('action.confirm'); // "Confirmar la reserva"
|
|
101
|
+
mc.format.price(2500, 'EUR'); // "25,00 €"
|
|
102
|
+
mc.format.date('2026-10-20'); // "dimarts, 20 d’octubre"
|
|
103
|
+
mc.format.duration(90); // "1 h 30 min"
|
|
104
|
+
mc.pick(site.site.content.tagline, site.site.defaultLocale);
|
|
105
|
+
mc.setLocale('en'); // a language switcher: links, embeds, new flows follow
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
- **Hosted screen and messages** speak **es, ca, en** (what the studio's site offers).
|
|
109
|
+
- **The SDK** speaks **es, ca, en, fr, pt, it, de**: labels and error sentences for a custom UI (`flow.t()`, `flow.state.errorMessage`, `mc.errorMessage(err)`, `messageFor()`), formatting for any tag. A French site gets French labels; the guest's code arrives in English, the closest hosted language.
|
|
110
|
+
- No `locale` → each site's default language, so a Spanish studio stays Spanish without configuration.
|
|
111
|
+
|
|
93
112
|
## API surface
|
|
94
113
|
|
|
95
114
|
| | |
|
|
96
115
|
|---|---|
|
|
97
|
-
| `createClient({ fetch, locale, headers })` | one client |
|
|
116
|
+
| `createClient({ fetch, locale, headers })` | one client; `setLocale`, `t`, `format`, `pick`, `errorMessage` |
|
|
98
117
|
| `sites.get / resolve / availability` | studio payload, custom-domain lookup, free spans |
|
|
99
118
|
| `holds.create / verify / resend / confirm` | the raw calls, if you manage state yourself |
|
|
100
119
|
| `bookings.get / cancel` | a guest's booking by manage token |
|