Skip to content

Commit

Permalink
Merge pull request #4741 from open-formulieren/issue/4600-reload-page…
Browse files Browse the repository at this point in the history
…-on-language-change

🐛 [#4600] Perform reload on language change
  • Loading branch information
sergei-maertens authored Oct 8, 2024
2 parents e25afd6 + 7d3482b commit ae24371
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
12 changes: 10 additions & 2 deletions docs/developers/embedding.rst
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,14 @@ Available options
the ``lang`` attribute of the ``html`` element in the DOM - if this is not set, the
default value of ``'nl'`` is used.

``onLanguageChange``:
Optional function to call on language changes. By default, the SDK reloads the
content and changes the active language of the form. When using ``onLanguageChange``,
your function will be executed on language change, instead of the default logic.

The new active language will be passed as an argument to the ``onLanguageChange``
function as a two-letter identifier.

``sentryDSN``:
Optional `Sentry DSN <https://docs.sentry.io/>`_ to monitor the SDK.

Expand Down Expand Up @@ -129,7 +137,7 @@ Minimal example
<html>
<head>
<!-- Required for icons used by Open Forms -->
<meta charset="utf-8">
<meta charset="utf-8">

<!-- Load stylesheet and SDK bundle -->
<link rel="stylesheet" href="https://openforms.example.com/sdk/1.0.0/open-forms-sdk.css" />
Expand Down Expand Up @@ -161,7 +169,7 @@ Full example
<html lang="nl">
<head>
<!-- Required for icons used by Open Forms -->
<meta charset="utf-8">
<meta charset="utf-8">

<!-- Load stylesheet and SDK bundle -->
<link rel="stylesheet" href="https://openforms.example.com/sdk/1.0.0/open-forms-sdk.css" />
Expand Down
1 change: 1 addition & 0 deletions src/openforms/forms/templates/forms/sdk_snippet.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
{% if sdk_sentry_dsn %}sentryDSN,{% endif %}
{% if sdk_sentry_env %}sentryEnv,{% endif %}
languageSelectorTarget: '#react-portal--language-selection',
onlanguagechange: () => window.location.reload(),
}
);
form.init();
Expand Down

0 comments on commit ae24371

Please sign in to comment.