Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## [Unreleased]
### Changed
- Documentation of `language` (on `ConfOptions` and `snippet()`) no longer names a fixed set of codes. Any language code is accepted and one without a translation falls back to the browser language, then English, so the list would only go stale as languages are added

## [0.5.0] - 2026-08-14
### Added
- `language` option on `ConfOptions` — sets the widget UI language through `conf()`, mirroring `theme`. Values: `null` (follows the browser, falling back to English), `en`, `cs`, `sk`. Unlike the `snippet()` parameter it can be changed at runtime; when both are given, the conf value wins
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ $client = new SnippetClient('key', 'secret', codeHasher: new MyCustomHasher());
## Methods
| Method | Description |
|---|---|
| `snippet(?string $language = null)` | Async loader script. Place once per page. Optional UI language (`cs`, `en`, `sk`…), otherwise auto-detected from the browser. |
| `snippet(?string $language = null)` | Async loader script. Place once per page. Optional initial UI language (any code; one without a translation falls back to the browser language, then English). |
| `conf(ConfOptions)` | SDK configuration (notification renderer, CSS, callbacks…). |
| `user(UserOptions)` | Identifies the current user. |
| `thread(string $selector, ThreadOptions)` | Embeds a thread into a DOM element. |
Expand Down Expand Up @@ -284,12 +284,12 @@ See the full list of parameters in [`src/Options/ConfOptions.php`](src/Options/C
| `pageCSSPath` | `?string` | CSS file URL injected into the snippet iframe. |
| `notificationElementTargetElement` | `?string` | JS expression returning the target DOM element. |
| `notificationElementPosition` | `?int` | Icon position: 1=top-left, 2=top-right, 3=bottom-right, 4=bottom-left. |
| `language` | `?string` | UI language of the app. Values: `null` (follows the browser, falling back to English), `en`, `cs`, `sk`. |
| `language` | `?string` | UI language of the app. Any language code is accepted; one without a translation falls back to the browser language, then English. `null` follows the browser. |
| `theme` | `?string` | Light/dark mode for the app. Values: `null` (follows browser preference), `stromcom-light`, `stromcom-dark`. |
| `entityResolve` | `?string` | JS callback resolving business-entity detail (order, ticket…) for the message editor's chip hover-card. Receives `{type, id}`, returns (or resolves to) `{title, url?, fields: [{label, value}]}`. |

### UI language
Set the language on `ConfOptions`, the same way as the theme. When omitted, the widget detects it from the browser, falling back to English.
Set the language on `ConfOptions`, the same way as the theme. Any language code is accepted — the widget uses English for a language it has no translation for, so passing one is never an error. When omitted, the language is detected from the browser.
```php
echo $client->conf(new ConfOptions(language: 'cs'))->getHTML();
```
Expand Down
2 changes: 1 addition & 1 deletion src/Options/ConfOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class ConfOptions extends SnippetOptions {
#[Docs('Callback invoked after the notification element is rendered', null, true, 'Function|null')]
private ?string $notificationElementAfterRender = null;

#[Docs('UI language of the app. Null follows the browser, falling back to English. Available: en, cs, sk', 'cs', true)]
#[Docs('UI language of the app. Any language code is accepted; one without a translation falls back to the browser language, then English. Null follows the browser.', 'cs', true)]
private ?string $language = null;

#[Docs('Theme name applied to the host page via data-theme on <html>. Available: stromcom-default, stromcom-dark', 'stromcom-dark', true)]
Expand Down
5 changes: 3 additions & 2 deletions src/SnippetClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,9 @@ public function csp(): CspPolicy {
* Generates the async loader snippet that bootstraps the SDK.
* Place this once on every page where you want the widget to appear.
*
* @param string|null $language UI language (e.g. "cs", "en", "sk"). Null (default) lets the
* widget detect it from the browser, falling back to English.
* @param string|null $language UI language (e.g. "cs", "en", "sk"). Any code is accepted;
* one without a translation falls back to the browser language,
* then English. Null (default) lets the widget detect it from the browser.
* This is the initial value only — `ConfOptions::$language`
* overrides it and can be changed later at runtime.
*
Expand Down