~nicolaskempf57/elixir-starter-explaned

59587f878a9190058461e607c7995ab5d6372fa5 — Nicolas KEMPF 5 months ago 5b28abe main
feat: Translating component

Obviously, you can also translate your own component !
1 files changed, 5 insertions(+), 6 deletions(-)

M apps/starter_web/lib/starter_web/components/menu.ex
M apps/starter_web/lib/starter_web/components/menu.ex => apps/starter_web/lib/starter_web/components/menu.ex +5 -6
@@ 1,17 1,16 @@
defmodule Menu do
  use Phoenix.Component
  use Phoenix.HTML
  use StarterWeb, :component
  alias StarterWeb.Router.Helpers, as: Routes

  def menu(assigns) do
    ~H"""
    <%= if @current_user do %>
      <.item content={@current_user.email}/>
      <.item content="Settings" route={Routes.user_settings_path(@conn, :edit)} />
      <.item content="Log out" route={Routes.user_session_path(@conn, :delete)} method={:delete} />
      <.item content={gettext "Settings"} route={Routes.user_settings_path(@conn, :edit)} />
      <.item content={gettext "Log out"} route={Routes.user_session_path(@conn, :delete)} method={:delete} />
    <% else %>
      <.item content="Register" route={Routes.user_registration_path(@conn, :new)}/>
      <.item content="Log in" route={Routes.user_session_path(@conn, :new)}/>
      <.item content={gettext "Register"} route={Routes.user_registration_path(@conn, :new)}/>
      <.item content={gettext "Log in"} route={Routes.user_session_path(@conn, :new)}/>
    <% end %>
    """
  end