Add language option to ConfOptions - #3
Merged
Merged
Conversation
The widget UI language could only be set through the snippet() parameter, which lands on the loader script as data-lang and is therefore fixed for the lifetime of the page. Theme, the other presentation setting, has always been a conf key. Language now works the same way, so integrators can switch it at runtime instead of re-rendering the page. The snippet() parameter stays supported as the initial value; the conf value wins when both are given. The constructor argument is appended last so positional callers keep working.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The widget UI language could only be set through the
snippet()parameter, which lands on the loader script asdata-lang. That value is read once during bootstrap, so the language is fixed for the lifetime of the page.theme— the other presentation setting — has always been a conf key. There is no reason for language to behave differently, and the asymmetry shows up anywhere an integrator builds a settings UI: theme can be switched, language cannot.What
ConfOptions::$language—null(follows the browser, falling back to English),en,cs,sk. Serialization is reflection-driven, so the property plus its#[Docs]attribute is all that is needed forconf()output.$theme, so positional callers are unaffected.snippet(?string $language)stays supported as the initial value — useful when the language is known at render time and the widget should boot into it without waiting forconf(). When both are given, the conf value wins.ConfOptionstable, with a note on how the two paths interact.Client-side counterpart
Requires the matching snippet change in
www.stromcom.cz:languageadded to the dataLayer conf keys, andclientBuilder#decorateAppUrlresolving it asconf → data-lang → browser. Without that, this option serializes but the client ignores it.Tests
139 + 3tests,composer ca(PHPStan + php-cs-fixer) clean.