From 8fa89e12ad2979d257879ce263275742043caf8b Mon Sep 17 00:00:00 2001 From: Pierre Cavin Date: Tue, 12 Dec 2023 12:00:21 +0100 Subject: [PATCH 1/3] Add missing gettext invocations in core components --- installer/templates/phx_web/components/core_components.ex | 8 ++++---- priv/templates/phx.gen.live/core_components.ex | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/installer/templates/phx_web/components/core_components.ex b/installer/templates/phx_web/components/core_components.ex index 6d5841ea48..19d952c9a4 100644 --- a/installer/templates/phx_web/components/core_components.ex +++ b/installer/templates/phx_web/components/core_components.ex @@ -152,23 +152,23 @@ defmodule <%= @web_namespace %>.CoreComponents do <.flash id="client-error" kind={:error} - title="We can't find the internet" + title=<%= if @gettext do %>{dgettext("errors", "We can't find the internet")}<% else %>"We can't find the internet"<% end %> phx-disconnected={show(".phx-client-error #client-error")} phx-connected={hide("#client-error")} hidden > - Attempting to reconnect <.icon name="hero-arrow-path" class="ml-1 h-3 w-3 animate-spin" /> + <%= if @gettext do %><%%= dgettext("errors", "Attempting to reconnect") %><% else %>Attempting to reconnect<% end %> <.icon name="hero-arrow-path" class="ml-1 h-3 w-3 animate-spin" /> <.flash id="server-error" kind={:error} - title="Something went wrong!" + title=<%= if @gettext do %>{dgettext("errors", "Something went wrong!")}<% else %>"Something went wrong!"<% end %> phx-disconnected={show(".phx-server-error #server-error")} phx-connected={hide("#server-error")} hidden > - Hang in there while we get back on track + <%= if @gettext do %><%%= dgettext("errors", "Hang in there while we get back on track") %><% else %>Hang in there while we get back on track<% end %> <.icon name="hero-arrow-path" class="ml-1 h-3 w-3 animate-spin" /> diff --git a/priv/templates/phx.gen.live/core_components.ex b/priv/templates/phx.gen.live/core_components.ex index 6d5841ea48..19d952c9a4 100644 --- a/priv/templates/phx.gen.live/core_components.ex +++ b/priv/templates/phx.gen.live/core_components.ex @@ -152,23 +152,23 @@ defmodule <%= @web_namespace %>.CoreComponents do <.flash id="client-error" kind={:error} - title="We can't find the internet" + title=<%= if @gettext do %>{dgettext("errors", "We can't find the internet")}<% else %>"We can't find the internet"<% end %> phx-disconnected={show(".phx-client-error #client-error")} phx-connected={hide("#client-error")} hidden > - Attempting to reconnect <.icon name="hero-arrow-path" class="ml-1 h-3 w-3 animate-spin" /> + <%= if @gettext do %><%%= dgettext("errors", "Attempting to reconnect") %><% else %>Attempting to reconnect<% end %> <.icon name="hero-arrow-path" class="ml-1 h-3 w-3 animate-spin" /> <.flash id="server-error" kind={:error} - title="Something went wrong!" + title=<%= if @gettext do %>{dgettext("errors", "Something went wrong!")}<% else %>"Something went wrong!"<% end %> phx-disconnected={show(".phx-server-error #server-error")} phx-connected={hide("#server-error")} hidden > - Hang in there while we get back on track + <%= if @gettext do %><%%= dgettext("errors", "Hang in there while we get back on track") %><% else %>Hang in there while we get back on track<% end %> <.icon name="hero-arrow-path" class="ml-1 h-3 w-3 animate-spin" /> From f4e31aa2bbd4d651095fb8ffc8fc4992cb480e1e Mon Sep 17 00:00:00 2001 From: Pierre Cavin Date: Tue, 12 Dec 2023 12:24:51 +0100 Subject: [PATCH 2/3] Fix formatting issues --- installer/templates/phx_web/components/core_components.ex | 2 +- priv/templates/phx.gen.live/core_components.ex | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/installer/templates/phx_web/components/core_components.ex b/installer/templates/phx_web/components/core_components.ex index 19d952c9a4..fec645316b 100644 --- a/installer/templates/phx_web/components/core_components.ex +++ b/installer/templates/phx_web/components/core_components.ex @@ -157,7 +157,7 @@ defmodule <%= @web_namespace %>.CoreComponents do phx-connected={hide("#client-error")} hidden > - <%= if @gettext do %><%%= dgettext("errors", "Attempting to reconnect") %><% else %>Attempting to reconnect<% end %> <.icon name="hero-arrow-path" class="ml-1 h-3 w-3 animate-spin" /> + <%= if @gettext do %><%%= dgettext("errors", "Attempting to reconnect") %><%= "\n" <> String.duplicate("\s", 8) %><% else %>Attempting to reconnect <% end %><.icon name="hero-arrow-path" class="ml-1 h-3 w-3 animate-spin" /> <.flash diff --git a/priv/templates/phx.gen.live/core_components.ex b/priv/templates/phx.gen.live/core_components.ex index 19d952c9a4..fec645316b 100644 --- a/priv/templates/phx.gen.live/core_components.ex +++ b/priv/templates/phx.gen.live/core_components.ex @@ -157,7 +157,7 @@ defmodule <%= @web_namespace %>.CoreComponents do phx-connected={hide("#client-error")} hidden > - <%= if @gettext do %><%%= dgettext("errors", "Attempting to reconnect") %><% else %>Attempting to reconnect<% end %> <.icon name="hero-arrow-path" class="ml-1 h-3 w-3 animate-spin" /> + <%= if @gettext do %><%%= dgettext("errors", "Attempting to reconnect") %><%= "\n" <> String.duplicate("\s", 8) %><% else %>Attempting to reconnect <% end %><.icon name="hero-arrow-path" class="ml-1 h-3 w-3 animate-spin" /> <.flash From 8e4525916909e6d3f336e7e9c154d23e3fb1f9c2 Mon Sep 17 00:00:00 2001 From: Pierre Cavin Date: Tue, 12 Dec 2023 16:56:14 +0100 Subject: [PATCH 3/3] Also translate flash titles! --- priv/templates/phx.gen.live/core_components.ex | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/priv/templates/phx.gen.live/core_components.ex b/priv/templates/phx.gen.live/core_components.ex index fec645316b..61930a1a79 100644 --- a/priv/templates/phx.gen.live/core_components.ex +++ b/priv/templates/phx.gen.live/core_components.ex @@ -147,8 +147,8 @@ defmodule <%= @web_namespace %>.CoreComponents do def flash_group(assigns) do ~H"""
- <.flash kind={:info} title="Success!" flash={@flash} /> - <.flash kind={:error} title="Error!" flash={@flash} /> + <.flash kind={:info} title=<%= if @gettext do %>{dgettext("errors", "Success!")}<% else %>"Success!"<% end %> flash={@flash} /> + <.flash kind={:error} title=<%= if @gettext do %>{dgettext("errors", "Error!")}<% else %>"Error!"<% end %> flash={@flash} /> <.flash id="client-error" kind={:error}