Skip to content

Add language prop to StromcomConf - #4

Merged
stromcom merged 1 commit into
masterfrom
feature/conf-language
Aug 14, 2026
Merged

Add language prop to StromcomConf#4
stromcom merged 1 commit into
masterfrom
feature/conf-language

Conversation

@stromcom

Copy link
Copy Markdown
Owner

Why

The UI language could only be set on <StromcomProvider>, where it lands on the loader script as data-lang and is read once during bootstrap. theme — the other presentation setting — is a <StromcomConf> prop and applies whenever it re-renders.

That asymmetry is visible to anyone building a settings UI: examples/08-theme-switcher.jsx shows a runtime theme toggle, and there is no way to write the same thing for language. Changing the provider's language prop re-runs the injection effect, which removes and re-adds the loader script — not something to build on.

What

  • language prop on StromcomConf, sent through conf() like every other option ('en' | 'cs' | 'sk' | null, null follows the browser and falls back to English).
  • The provider's language prop stays supported as the initial value, for when the language is known at mount and the widget should boot into it without waiting for the first conf(). The conf value wins when both are given — documented on both props.
  • Types in src/index.d.ts and both README prop tables updated.

Client-side counterpart

Requires the matching snippet change in www.stromcom.cz: language added to the dataLayer conf keys, and clientBuilder#decorateAppUrl resolving it as conf → data-lang → browser. Without that, the prop is sent but the client ignores it. The equivalent PHP change is stromcom/php-snippet#3.

Tests

3 new tests (set, null, re-send on change), 32 total passing; lint and format:check clean.

The UI language could only be set on StromcomProvider, where it lands on
the loader script as data-lang and is read once during bootstrap. Theme,
the other presentation setting, is a StromcomConf prop and can be changed
whenever it re-renders. Language now works the same way.

The provider prop stays supported as the initial value; the conf value
wins when both are given.
@stromcom
stromcom merged commit b90950e into master Aug 14, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant