@sensiblestats/widget-react 0.120.1 → 0.121.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 CHANGED
@@ -1,5 +1,16 @@
1
1
  # @sensiblestats/widget-react
2
2
 
3
+ ## 0.121.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Widget chrome strings now come from the server for the host's language tag, with a bundled en-GB fallback. `locale` accepts any registry tag and wins over `userContext.defaultLanguage`; a host with no language sends none and gets the operator default. English hosts see dates as "1 Nov", Turkish numbers use the decimal comma, and the panel opens once the strings are ready.
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies
12
+ - @sensiblestats/widget-sdk@0.85.0
13
+
3
14
  ## 0.120.1
4
15
 
5
16
  ### Patch Changes
package/README.md CHANGED
@@ -21,7 +21,7 @@ export function App() {
21
21
  operatorId: 'sandbox1',
22
22
  publicKey: 'wgk_…',
23
23
  baseUrl: 'https://widget.sensiblestats.com',
24
- locale: 'en',
24
+ locale: 'en-GB',
25
25
  }}
26
26
  />
27
27
  )
@@ -33,26 +33,28 @@ Common `config` fields:
33
33
  - `operatorId`, `publicKey` — your gateway credentials (both browser-safe; the
34
34
  public key is origin-gated at the gateway).
35
35
  - `baseUrl` — the widget gateway URL.
36
- - `locale` — `'en'` or `'tr'` for the widget's own chrome text; a region (`'tr-TR'`) or
37
- an underscore (`'tr_TR'`) counts as its language. It is also sent as the server
38
- language (`userContext.defaultLanguage`) when it is one of those two; any other
39
- value, or none, sends nothing and the operator's own default language applies.
40
- The chat thread is kept per language: when the language sent to the server is
41
- `en` or `tr` (from `locale`, or from `userContext.defaultLanguage` alone), the thread
42
- key carries `:lang=<language>`, so `'TR '` and `'tr'` are one thread and a change
43
- of language starts that language's own thread. Any other value, or none, keeps the
44
- plain key. A visitor of a host that already sets one of those two languages moves
45
- once to the `:lang=` thread when the host upgrades (threads expire after an hour).
46
- Changing the language while an answer is streaming drops that turn. With an injected `client`, `locale` sets the chrome only;
47
- the client keeps its own conversation context.
36
+ - `locale` — any language tag in the server's registry (`'en-GB'`, `'en-US'`, `'tr-TR'`, `'de'`, ...). It is
37
+ sent whole to the server as the language (`defaultLanguage`) and picks the widget's own chrome text. A host
38
+ with no `locale` sends no language and gets the operator's default (en-GB when the operator has none).
39
+ `locale` wins over `userContext.defaultLanguage`.
40
+ The chrome strings come from the gateway (`/v1/<operatorId>/strings`) for the resolved tag, so a wording
41
+ fix or a new language is a server change. The table is cached in `localStorage` per operator and tag and
42
+ revalidated on every load, so a returning visitor sees chrome at once. Only en-GB is bundled: an English
43
+ or unset tag with an empty cache falls back to it if the request fails; any other tag with a cold cache
44
+ shows a busy launcher and no panel until the strings arrive, then retries with backoff.
45
+ The chat thread is kept per language family of the host's tag: the thread key carries `:lang=<family>`
46
+ (`'tr-TR'` and `'tr'` are one thread, `'de'` has its own), and a change of language starts that
47
+ language's own thread. With no host tag the plain key is used. Changing the language while an answer is
48
+ streaming drops that turn. With an injected `client`, `locale` sets the chrome only; the client keeps its
49
+ own conversation context.
48
50
  - `oddsFormat` — `'decimal'`, `'american'` or `'fractional'`: how the widget shows every price
49
51
  until the visitor picks their own in the widget's settings. Anything else, or none, is
50
52
  decimal. The script embed reads it from `data-odds-format`. The built-in client sends the
51
53
  format in effect with every chat request, so the server writes its sentences in it too. An
52
54
  injected `client` sends only the visitor's own pick, and nothing until they make one.
53
55
  - `userContext` — `{ operatorUserId, defaultLanguage }` to tie the conversation
54
- and personalization to your signed-in user. A `defaultLanguage` set here wins
55
- over `locale`. `operatorUserId` travels from the browser, so make it a random,
56
+ and personalization to your signed-in user. A `locale` set on the config wins
57
+ over this `defaultLanguage`. `operatorUserId` travels from the browser, so make it a random,
56
58
  non-guessable value you map to the user on your side (a UUID works): never an
57
59
  account number, email, username or sequential id.
58
60
  - White-label branding — `logoUrl`, `headerTitle`, `accent`, `cta`, `surface`,