diff --git a/core/assets/js/feldspar_app.js b/core/assets/js/feldspar_app.js index 2b8a2962e..460beaf00 100644 --- a/core/assets/js/feldspar_app.js +++ b/core/assets/js/feldspar_app.js @@ -2,6 +2,8 @@ export const FeldsparApp = { mounted() { console.log("FeldsparApp MOUNTED"); + console.log(this.el.dataset); + const iframe = this.getIframe(); iframe.addEventListener("load", () => { this.onFrameLoaded(); @@ -19,7 +21,11 @@ export const FeldsparApp = { this.channel.port1.onmessage = (e) => { this.handleMessage(e); }; - this.getIframe().contentWindow.postMessage("init", "*", [ + + let action = "live-init"; + let locale = this.el.dataset.locale; + + this.getIframe().contentWindow.postMessage({ action, locale }, "*", [ this.channel.port2, ]); }, diff --git a/core/lib/core_web/live_locale.ex b/core/lib/core_web/live_locale.ex index 1c94999a9..2eec8d0ed 100644 --- a/core/lib/core_web/live_locale.ex +++ b/core/lib/core_web/live_locale.ex @@ -28,7 +28,6 @@ defmodule CoreWeb.LiveLocale do def mount(params, %{"locale" => locale} = session, socket) do Gettext.put_locale(CoreWeb.Gettext, locale) Gettext.put_locale(Timex.Gettext, locale) - Gettext.get_locale() super(params, session, socket) end end diff --git a/core/systems/feldspar/app_page.ex b/core/systems/feldspar/app_page.ex index 084b6fd28..1d412e27f 100644 --- a/core/systems/feldspar/app_page.ex +++ b/core/systems/feldspar/app_page.ex @@ -24,7 +24,7 @@ defmodule Systems.Feldspar.AppPage do def render(assigns) do ~H""" <.stripped menus={@menus} footer?={false}> - <.app_view url={@app_url} /> + <.app_view url={@app_url} locale={Gettext.get_locale()} /> """ end diff --git a/core/systems/feldspar/app_view.ex b/core/systems/feldspar/app_view.ex index 4ec810bab..cdee6f84b 100644 --- a/core/systems/feldspar/app_view.ex +++ b/core/systems/feldspar/app_view.ex @@ -2,6 +2,7 @@ defmodule Systems.Feldspar.AppView do use CoreWeb, :html attr(:url, :string, required: true) + attr(:locale, :string, required: true) def app_view(assigns) do ~H""" @@ -10,7 +11,7 @@ defmodule Systems.Feldspar.AppView do Changing the preceding siblings of the iframe would result in a reload of the iframe due to Morphdom (https://github.com/patrick-steele-idem/morphdom/issues/200). --%> -
+
diff --git a/core/systems/feldspar/tool_model.ex b/core/systems/feldspar/tool_model.ex index b9d68fd46..cb191f340 100644 --- a/core/systems/feldspar/tool_model.ex +++ b/core/systems/feldspar/tool_model.ex @@ -50,7 +50,10 @@ defmodule Systems.Feldspar.ToolModel do def launcher(%{archive_ref: archive_ref}) when is_binary(archive_ref) do %{ function: &Feldspar.AppView.app_view/1, - props: %{url: archive_ref <> "/index.html"} + props: %{ + url: archive_ref <> "/index.html", + locale: Gettext.get_locale(CoreWeb.Gettext) + } } end